mirror of
https://github.com/iamadamdev/bypass-paywalls-chrome
synced 2025-04-30 02:14:26 +02:00
Avoid injecting script to unrelated sites (#665)
* Avoid injecting script to unrelated sites * unnecessary comment
This commit is contained in:
parent
ad1afe9b63
commit
e33f019c1f
@ -348,13 +348,18 @@ extensionApi.webRequest.onBeforeSendHeaders.addListener(function (details) {
|
||||
}
|
||||
|
||||
if (tabId !== -1) {
|
||||
// run contentScript inside tab
|
||||
extensionApi.tabs.executeScript(tabId, {
|
||||
file: 'src/js/contentScript.js',
|
||||
runAt: 'document_start'
|
||||
}, function (res) {
|
||||
if (extensionApi.runtime.lastError || res[0]) {
|
||||
extensionApi.tabs.get(tabId, function (currentTab) {
|
||||
// Validate url of current tab to avoid injecting script to unrelated sites
|
||||
if (currentTab && isSiteEnabled(currentTab)) {
|
||||
// run contentScript inside tab
|
||||
extensionApi.tabs.executeScript(tabId, {
|
||||
file: 'src/js/contentScript.js',
|
||||
runAt: 'document_start'
|
||||
}, function (res) {
|
||||
if (extensionApi.runtime.lastError || res[0]) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user