this fixes #224 for Chromium

This commit is contained in:
gorhill 2015-03-09 12:57:52 -04:00
parent cfadf76345
commit 2478bd4f61
5 changed files with 104 additions and 12 deletions

View File

@ -36,6 +36,15 @@
"js": ["js/contentscript-end.js"],
"run_at": "document_end",
"all_frames": true
},
{
"matches": [
"https://*.adblockplus.org/*",
"https://*.adblockplus.me/*",
"https://www.fanboy.co.nz/*"
],
"js": ["js/subscriber.js"],
"run_at": "document_idle"
}
],
"minimum_chrome_version": "22.0",

View File

@ -55,6 +55,11 @@ const contentObserver = {
cpMessageName: hostName + ':shouldLoad',
ignoredPopups: new WeakMap(),
uniqueSandboxId: 1,
subscriberTargets: {
'adblockplus.org': true,
'adblockplus.me': true,
'fanboy.co.nz': true
},
get componentRegistrar() {
return Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
@ -295,6 +300,27 @@ const contentObserver = {
};
subject.addEventListener('DOMContentLoaded', docReady, true);
/* Does not work, I do not know why
let docIdle = function(e) {
this.removeEventListener(e.type, docIdle);
lss(this.contentBaseURI + 'subscriber.js', sandbox);
};
var target = loc.host;
while ( target !== '' ) {
if ( this.subscriberTargets.hasOwnProperty(target) ) {
subject.addEventListener('load', docIdle);
break;
}
let pos = target.indexOf('.');
if ( pos === -1 ) {
break;
}
target = target.slice(pos + 1);
}
*/
}
};

View File

@ -519,6 +519,10 @@
"message":"Unable to connect to {{url}}",
"description":"English: Network error: unable to connect to {{url}}"
},
"subscriberConfirm":{
"message":"µBlock: Add the following resource to your selection of filter lists?\n\nTitle: \"{{title}}\"\nURL: {{url}}",
"description":"English: Network error: unable to connect to {{url}}"
},
"dummy":{
"message":"This entry must be the last one",
"description":"so we dont need to deal with comma for last entry"

View File

@ -19,7 +19,7 @@
Home: https://github.com/gorhill/uBlock
*/
/* global µBlock, vAPI, YaMD5 */
/* global µBlock, vAPI */
/******************************************************************************/
/******************************************************************************/
@ -279,6 +279,7 @@ var onMessage = function(request, sender, callback) {
}
// Sync
var pageStore;
var response;
switch ( request.what ) {
@ -290,7 +291,7 @@ var onMessage = function(request, sender, callback) {
break;
case 'hasPopupContentChanged':
var pageStore = µb.pageStoreFromTabId(request.tabId);
pageStore = µb.pageStoreFromTabId(request.tabId);
var lastModified = pageStore ? pageStore.contentLastModified : 0;
response = lastModified !== request.contentLastModified;
break;
@ -310,7 +311,7 @@ var onMessage = function(request, sender, callback) {
break;
case 'toggleNetFiltering':
var pageStore = µb.pageStoreFromTabId(request.tabId);
pageStore = µb.pageStoreFromTabId(request.tabId);
if ( pageStore ) {
pageStore.toggleNetFilteringSwitch(request.url, request.scope, request.state);
µb.updateBadgeAsync(request.tabId);
@ -666,9 +667,6 @@ var onMessage = function(request, sender, callback) {
case 'purgeAllCaches':
return µb.assets.purgeAll(callback);
case 'writeUserUbiquitousBlockRules':
return µb.assets.put(µb.userFiltersPath, request.content, callback);
default:
break;
}
@ -1133,3 +1131,47 @@ vAPI.messaging.listen('devtool-log.js', onMessage);
// https://www.youtube.com/watch?v=3_WcygKJP1k
/******************************************************************************/
/******************************************************************************/
// subscriber.js
(function() {
'use strict';
/******************************************************************************/
var onMessage = function(request, sender, callback) {
// Async
switch ( request.what ) {
default:
break;
}
// Sync
var response;
switch ( request.what ) {
case 'subscriberData':
response = {
confirmStr: vAPI.i18n('subscriberConfirm'),
externalLists: µBlock.userSettings.externalLists
};
break;
default:
return vAPI.messaging.UNHANDLED;
}
callback(response);
};
vAPI.messaging.listen('subscriber.js', onMessage);
/******************************************************************************/
})();
// https://www.youtube.com/watch?v=3_WcygKJP1k
/******************************************************************************/

View File

@ -527,15 +527,27 @@
return;
}
// Only the lists referenced by the switches are touched.
var filterLists = µb.remoteBlacklists;
var entry, state, location;
var i = switches.length;
while ( i-- ) {
if ( filterLists.hasOwnProperty(switches[i].location) === false ) {
entry = switches[i];
state = entry.off === true;
location = entry.location;
if ( filterLists.hasOwnProperty(location) === false ) {
if ( state !== true ) {
filterLists[location] = { off: state };
}
continue;
}
filterLists[switches[i].location].off = !!switches[i].off;
if ( filterLists[location].off === state ) {
continue;
}
// Save switch states
filterLists[location].off = state;
}
vAPI.storage.set({ 'remoteBlacklists': filterLists }, onFilterListsReady);
};
@ -564,9 +576,8 @@
µb.purgeCompiledFilterList(path);
}
// Purge obsolete PSL
if ( metadata.hasOwnProperty(µb.pslPath) === false ) {
entry = metadata[µb.pslPath];
if ( entry.repoObsolete === true ) {
if ( metadata.hasOwnProperty(µb.pslPath) ) {
if ( metadata[µb.pslPath].repoObsolete === true ) {
µb.assets.purge('cache://compiled-publicsuffixlist');
}
}