This commit is contained in:
gorhill 2017-11-16 10:55:28 -05:00
parent b02fcb1b31
commit 387eaa0b21
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
5 changed files with 27 additions and 24 deletions

View File

@ -38,13 +38,13 @@
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*"],
"js": ["js/vapi.js", "js/vapi-client.js", "js/contentscript.js"],
"js": ["/js/vapi.js", "/js/vapi-client.js", "/js/contentscript.js"],
"run_at": "document_start",
"all_frames": true
},
{
"matches": ["http://*/*", "https://*/*"],
"js": ["js/scriptlets/subscriber.js"],
"js": ["/js/scriptlets/subscriber.js"],
"run_at": "document_idle",
"all_frames": false
}

View File

@ -1031,20 +1031,21 @@ 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() {
var onScriptInjected = function() {
vAPI.lastError();
};
var scriptStart = function(tabId) {
vAPI.tabs.injectScript(tabId, {
file: 'js/vapi-client.js',
allFrames: true,
runAt: 'document_idle'
}, function(){ });
vAPI.tabs.injectScript(tabId, {
file: 'js/contentscript.js',
allFrames: true,
runAt: 'document_idle'
}, scriptDone);
var manifest = chrome.runtime.getManifest();
if ( manifest instanceof Object === false ) { return; }
for ( var contentScript of manifest.content_scripts ) {
for ( var file of contentScript.js ) {
vAPI.tabs.injectScript(tabId, {
file: file,
allFrames: contentScript.all_frames,
runAt: contentScript.run_at
}, onScriptInjected);
}
}
};
var bindToTabs = function(tabs) {
var µb = µBlock;

View File

@ -28,7 +28,7 @@
/******************************************************************************/
// https://bugzilla.mozilla.org/show_bug.cgi?id=1408996#c9
var vAPI; // jshint ignore:line
var vAPI = window.vAPI; // jshint ignore:line
// https://github.com/chrisaljoudi/uBlock/issues/464
// https://github.com/chrisaljoudi/uBlock/issues/1528
@ -48,7 +48,9 @@ if (
) &&
(/^image\/|^text\/plain/.test(document.contentType || '') === false)
) {
vAPI = vAPI instanceof Object && vAPI.uBO === true ? vAPI : { uBO: true };
vAPI = window.vAPI = vAPI instanceof Object && vAPI.uBO === true
? vAPI
: { uBO: true };
}
/******************************************************************************/

View File

@ -37,9 +37,9 @@
"file://*/*"
],
"js":[
"js/vapi.js",
"js/vapi-client.js",
"js/contentscript.js"
"/js/vapi.js",
"/js/vapi-client.js",
"/js/contentscript.js"
],
"run_at":"document_start",
"all_frames":true
@ -50,7 +50,7 @@
"https://*/*"
],
"js":[
"js/scriptlets/subscriber.js"
"/js/scriptlets/subscriber.js"
],
"run_at":"document_idle",
"all_frames":false

View File

@ -46,6 +46,11 @@ var exports = {};
var onBeforeReady = null;
µBlock.onStartCompletedQueue.push(function(callback) {
vAPI.onLoadAllCompleted();
callback();
});
if ( µBlock.hiddenSettings.suspendTabsUntilReady ) {
onBeforeReady = (function() {
var suspendedTabs = new Set();
@ -66,11 +71,6 @@ if ( µBlock.hiddenSettings.suspendTabsUntilReady ) {
}
};
})();
} else {
µBlock.onStartCompletedQueue.push(function(callback) {
vAPI.onLoadAllCompleted();
callback();
});
}
/******************************************************************************/