Skip to content

Commit

Permalink
Merge pull request #879 from DarkFlorist/injection-guard
Browse files Browse the repository at this point in the history
injection guard
  • Loading branch information
KillariDev authored Mar 1, 2024
2 parents 65e1ac4 + 8f9a060 commit 3062cf6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/inpage/ts/document_start.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// required so this file is seen as a module by TypeScript, which lets us extend the `globalThis` definition
export {}

function listenInContentScript(conectionName: string | undefined) {
/**
* this script executed within the context of the active tab when the user clicks the extension bar button
Expand Down Expand Up @@ -50,7 +53,14 @@ function listenInContentScript(conectionName: string | undefined) {
})
}

function injectScript(content: any) {
declare global {
var interceptorInjected: true | undefined
}

function injectScript(content: string) {
if (globalThis.interceptorInjected) return
globalThis.interceptorInjected = true

try {
const container = document.head || document.documentElement
const scriptTag = document.createElement('script')
Expand Down

0 comments on commit 3062cf6

Please sign in to comment.