-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add custom injection rule settings for ffz and bttv
See #2
- Loading branch information
1 parent
e3816e9
commit 0a06b76
Showing
4 changed files
with
44 additions
and
19 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,14 @@ | ||
browser.runtime.onMessage.addListener((request, sender, sendResponse) => { | ||
// Store action for settings change | ||
if (request.type === "SetStoreExecution") { | ||
browser.storage.local.set({[request.id]: request.value}).then(res => { | ||
sendResponse({ result: {[request.id]: request.value} }) | ||
}) | ||
// Retrieve action for settings change | ||
} else if (request.type === "GetStoreExecution"){ | ||
browser.storage.local.get(request.id).then((res) => { | ||
sendResponse({ checked: res[request.id] }) | ||
}) | ||
} | ||
return true; | ||
}); |
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 |
---|---|---|
@@ -1,14 +1,22 @@ | ||
// Inject BBTV Script | ||
const bttvScript = document.createElement('script'); | ||
bttvScript.type = 'text/javascript'; | ||
bttvScript.src = 'https://cdn.betterttv.net/betterttv.js'; | ||
// Head to append scripts to | ||
const head = document.getElementsByTagName('head')[0]; | ||
|
||
// Inject FFZ script | ||
const ffzScript = document.createElement('script'); | ||
ffzScript.type = 'text/javascript'; | ||
ffzScript.src = 'https://cdn.frankerfacez.com/static/ffz_injector.user.js'; | ||
// Inject BTTV if enabled | ||
browser.runtime.sendMessage({ type: "GetStoreExecution", id: "bttvEnabled" }).then((response) => { | ||
if (response.checked) { | ||
const bttvScript = document.createElement('script'); | ||
bttvScript.type = 'text/javascript'; | ||
bttvScript.src = 'https://cdn.betterttv.net/betterttv.js'; | ||
head.appendChild(bttvScript); | ||
} | ||
}); | ||
|
||
// Append scripts to head | ||
const head = document.getElementsByTagName('head')[0]; | ||
head.appendChild(bttvScript); | ||
head.appendChild(ffzScript); | ||
// Inject FFZ if enabled | ||
browser.runtime.sendMessage({ type: "GetStoreExecution", id: "ffzEnabled" }).then((response) => { | ||
if (response.checked) { | ||
const ffzScript = document.createElement('script'); | ||
ffzScript.type = 'text/javascript'; | ||
ffzScript.src = 'https://cdn.frankerfacez.com/static/ffz_injector.user.js'; | ||
head.appendChild(ffzScript); | ||
} | ||
}); |
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
Large diffs are not rendered by default.
Oops, something went wrong.