mirror of https://github.com/gorhill/uBlock.git
this fixes #418; also remove last chrome API reference from portable code
This commit is contained in:
parent
8ea558e41e
commit
5019f241df
|
@ -19,7 +19,7 @@
|
|||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
/* global self */
|
||||
/* global self, µBlock */
|
||||
|
||||
// For background page
|
||||
|
||||
|
@ -394,6 +394,57 @@ vAPI.lastError = function() {
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
// This is called only once, when everything has been loaded in memory after
|
||||
// the extension was launched. It can be used to inject content scripts
|
||||
// in already opened web pages, to remove whatever nuisance could make it to
|
||||
// the web pages before uBlock was ready.
|
||||
|
||||
vAPI.onLoadAllCompleted = function() {
|
||||
// http://code.google.com/p/chromium/issues/detail?id=410868#c11
|
||||
// Need to be sure to access `vAPI.lastError()` to prevent
|
||||
// spurious warnings in the console.
|
||||
var scriptDone = function() {
|
||||
vAPI.lastError();
|
||||
};
|
||||
var scriptEnd = function(tabId) {
|
||||
if ( vAPI.lastError() ) {
|
||||
return;
|
||||
}
|
||||
vAPI.tabs.injectScript(tabId, {
|
||||
file: 'js/contentscript-end.js',
|
||||
allFrames: true,
|
||||
runAt: 'document_idle'
|
||||
}, scriptDone);
|
||||
};
|
||||
var scriptStart = function(tabId) {
|
||||
vAPI.tabs.injectScript(tabId, {
|
||||
file: 'js/vapi-client.js',
|
||||
allFrames: true,
|
||||
runAt: 'document_start'
|
||||
}, function(){ });
|
||||
vAPI.tabs.injectScript(tabId, {
|
||||
file: 'js/contentscript-start.js',
|
||||
allFrames: true,
|
||||
runAt: 'document_idle'
|
||||
}, function(){ scriptEnd(tabId); });
|
||||
};
|
||||
var bindToTabs = function(tabs) {
|
||||
var µb = µBlock;
|
||||
var i = tabs.length, tab;
|
||||
while ( i-- ) {
|
||||
tab = tabs[i];
|
||||
µb.bindTabToPageStats(tab.id, tab.url);
|
||||
// https://github.com/gorhill/uBlock/issues/129
|
||||
scriptStart(tab.id);
|
||||
}
|
||||
};
|
||||
|
||||
chrome.tabs.query({ url: 'http://*/*' }, bindToTabs);
|
||||
chrome.tabs.query({ url: 'https://*/*' }, bindToTabs);
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
})();
|
||||
|
||||
/******************************************************************************/
|
||||
|
|
|
@ -811,4 +811,14 @@ vAPI.lastError = function() {
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
// This is called only once, when everything has been loaded in memory after
|
||||
// the extension was launched. It can be used to inject content scripts
|
||||
// in already opened web pages, to remove whatever nuisance could make it to
|
||||
// the web pages before uBlock was ready.
|
||||
|
||||
vAPI.onLoadAllCompleted = function() {
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
})();
|
||||
|
|
|
@ -212,11 +212,18 @@
|
|||
} catch (e) {
|
||||
locations = {};
|
||||
}
|
||||
var entry;
|
||||
for ( location in locations ) {
|
||||
if ( locations.hasOwnProperty(location) === false ) {
|
||||
continue;
|
||||
}
|
||||
availableLists['assets/thirdparties/' + location] = locations[location];
|
||||
entry = locations[location];
|
||||
// https://github.com/gorhill/uBlock/issues/418
|
||||
// We now support built-in external filter lists
|
||||
if ( /^https?:/.test(location) === false ) {
|
||||
location = 'assets/thirdparties/' + location;
|
||||
}
|
||||
availableLists[location] = entry;
|
||||
}
|
||||
|
||||
// Now get user's selection of lists
|
||||
|
@ -584,48 +591,7 @@
|
|||
// - Initialize internal state with maybe already existing tabs.
|
||||
// - Schedule next update operation.
|
||||
var onAllDone = function() {
|
||||
if (vAPI.chrome) {
|
||||
// http://code.google.com/p/chromium/issues/detail?id=410868#c11
|
||||
// Need to be sure to access `vAPI.lastError()` to prevent
|
||||
// spurious warnings in the console.
|
||||
var scriptDone = function() {
|
||||
vAPI.lastError();
|
||||
};
|
||||
var scriptEnd = function(tabId) {
|
||||
if ( vAPI.lastError() ) {
|
||||
return;
|
||||
}
|
||||
vAPI.tabs.injectScript(tabId, {
|
||||
file: 'js/contentscript-end.js',
|
||||
allFrames: true,
|
||||
runAt: 'document_idle'
|
||||
}, scriptDone);
|
||||
};
|
||||
var scriptStart = function(tabId) {
|
||||
vAPI.tabs.injectScript(tabId, {
|
||||
file: 'js/vapi-client.js',
|
||||
allFrames: true,
|
||||
runAt: 'document_start'
|
||||
}, function(){ });
|
||||
vAPI.tabs.injectScript(tabId, {
|
||||
file: 'js/contentscript-start.js',
|
||||
allFrames: true,
|
||||
runAt: 'document_idle'
|
||||
}, function(){ scriptEnd(tabId); });
|
||||
};
|
||||
var bindToTabs = function(tabs) {
|
||||
var i = tabs.length, tab;
|
||||
while ( i-- ) {
|
||||
tab = tabs[i];
|
||||
µb.bindTabToPageStats(tab.id, tab.url);
|
||||
// https://github.com/gorhill/uBlock/issues/129
|
||||
scriptStart(tab.id);
|
||||
}
|
||||
};
|
||||
|
||||
chrome.tabs.query({ url: 'http://*/*' }, bindToTabs);
|
||||
chrome.tabs.query({ url: 'https://*/*' }, bindToTabs);
|
||||
}
|
||||
vAPI.onLoadAllCompleted();
|
||||
|
||||
// https://github.com/gorhill/uBlock/issues/184
|
||||
// If we restored a selfie, check for updates not too far
|
||||
|
|
Loading…
Reference in New Issue