-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change logic so that instead of using catches, a background script is…
… used to check for already injected scripts. Now works with firefox
- Loading branch information
1 parent
d6d8276
commit 274d5f9
Showing
4 changed files
with
66 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// initialize object containing ids of tabs who have been injected | ||
let injected = {}; | ||
browser.runtime.onMessage.addListener(gotMessage); | ||
function gotMessage(message) { | ||
console.log(injected); | ||
if (message.type === "get-injected") { | ||
return Promise.resolve(injected); | ||
} else if (message.type === "injection-update") { | ||
if (message.content.task === "append") { | ||
injected[message.content.value] = true; | ||
} else if (message.content.task === "delete") { | ||
delete injected[message.content.value]; | ||
} | ||
} | ||
} | ||
|
||
// remove tabs from injected obj when they are closed | ||
browser.tabs.onRemoved.addListener(handleRemoved); | ||
function handleRemoved(tabId) { | ||
if (injected[tabId]) delete injected[tabId]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters