Fix contentScript in background tab
This commit is contained in:
parent
a881e0a6cf
commit
bfb9cd8e72
@ -47,6 +47,7 @@ var allow_cookies = [
|
|||||||
'intelligentinvestor.com.au',
|
'intelligentinvestor.com.au',
|
||||||
'knack.be',
|
'knack.be',
|
||||||
'lc.nl',
|
'lc.nl',
|
||||||
|
'lesechos.fr',
|
||||||
'lesoir.be',
|
'lesoir.be',
|
||||||
'limesonline.com',
|
'limesonline.com',
|
||||||
'lrb.co.uk',
|
'lrb.co.uk',
|
||||||
@ -591,13 +592,26 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tabId !== -1) {
|
||||||
|
ext_api.tabs.get(tabId, function (currentTab) {
|
||||||
|
if (isSiteEnabled(currentTab) || medium_custom_domain) {
|
||||||
|
ext_api.tabs.executeScript(tabId, {
|
||||||
|
file: 'contentScript.js',
|
||||||
|
runAt: 'document_start'
|
||||||
|
}, function (res) {
|
||||||
|
if (ext_api.runtime.lastError || res[0]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {//mercuriovalpo.cl
|
||||||
ext_api.tabs.query({
|
ext_api.tabs.query({
|
||||||
active: true,
|
active: true,
|
||||||
currentWindow: true
|
currentWindow: true
|
||||||
}, function (tabs) {
|
}, function (tabs) {
|
||||||
if (tabs.length > 0 && tabs[0].url && tabs[0].url.indexOf("http") !== -1) {
|
if (tabs.length > 0 && tabs[0].url && tabs[0].url.indexOf("http") !== -1) {
|
||||||
if (isSiteEnabled({url: tabs[0].url}) || medium_custom_domain) {
|
if (isSiteEnabled({url: tabs[0].url}) || medium_custom_domain) {
|
||||||
// run contentScript inside tab
|
|
||||||
ext_api.tabs.executeScript({
|
ext_api.tabs.executeScript({
|
||||||
file: 'contentScript.js',
|
file: 'contentScript.js',
|
||||||
runAt: 'document_start'
|
runAt: 'document_start'
|
||||||
@ -609,6 +623,7 @@ ext_api.webRequest.onBeforeSendHeaders.addListener(function(details) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return { requestHeaders: requestHeaders };
|
return { requestHeaders: requestHeaders };
|
||||||
}, {
|
}, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user