MCPcopy Create free account
hub / github.com/ecomfe/tempad-dev / replaceScript

Function replaceScript

packages/extension/rewrite/runtime.ts:17–22  ·  view source on GitHub ↗
(current: HTMLScriptElement, src: string)

Source from the content-addressed store, hash-verified

15}
16
17function replaceScript(current: HTMLScriptElement, src: string): void {
18 const script = document.createElement('script')
19 script.src = src
20 script.defer = true
21 current.replaceWith(script)
22}
23
24function withCurrentScript(current: HTMLScriptElement, run: () => void): void {
25 const descriptor = Object.getOwnPropertyDescriptor(Document.prototype, 'currentScript')

Callers 1

rewriteCurrentScriptFunction · 0.85

Calls 2

createElementMethod · 0.80
replaceWithMethod · 0.80

Tested by

no test coverage detected