From 77504cb561fd597efe38365eb6f8d06f15923b73 Mon Sep 17 00:00:00 2001 From: gorhill Date: Fri, 20 Nov 2015 08:47:29 -0500 Subject: [PATCH] this fixes #951 --- platform/chromium/manifest.json | 12 ++++-------- platform/firefox/frameModule.js | 4 ++-- platform/opera/manifest.json | 11 ++++------- src/3p-filters.html | 5 ++++- src/js/background.js | 6 +----- src/js/{ => scriptlets}/subscriber.js | 16 +++++++--------- 6 files changed, 22 insertions(+), 32 deletions(-) rename src/js/{ => scriptlets}/subscriber.js (89%) diff --git a/platform/chromium/manifest.json b/platform/chromium/manifest.json index c3c618dae..bdd08ae48 100644 --- a/platform/chromium/manifest.json +++ b/platform/chromium/manifest.json @@ -38,14 +38,10 @@ "all_frames": true }, { - "matches": [ - "https://*.adblockplus.org/*", - "https://*.adblockplus.me/*", - "https://www.fanboy.co.nz/*", - "https://github.com/gorhill/uBlock/wiki/Filter-lists-from-around-the-web" - ], - "js": ["js/subscriber.js"], - "run_at": "document_idle" + "matches": ["http://*/*", "https://*/*"], + "js": ["js/scriptlets/subscriber.js"], + "run_at": "document_idle", + "all_frames": false } ], "incognito": "split", diff --git a/platform/firefox/frameModule.js b/platform/firefox/frameModule.js index 82c41b2f1..8e95d023c 100644 --- a/platform/firefox/frameModule.js +++ b/platform/firefox/frameModule.js @@ -421,10 +421,10 @@ var contentObserver = { lss(this.contentBaseURI + 'contentscript-end.js', sandbox); if ( - doc.querySelector('a[href^="abp:"]') || + doc.querySelector('a[href^="abp:"],a[href^="https://subscribe.adblockplus.org/?"]') || loc.href === 'https://github.com/gorhill/uBlock/wiki/Filter-lists-from-around-the-web' ) { - lss(this.contentBaseURI + 'subscriber.js', sandbox); + lss(this.contentBaseURI + 'scriptlets/subscriber.js', sandbox); } }; diff --git a/platform/opera/manifest.json b/platform/opera/manifest.json index 53cabebd2..3388ff89b 100644 --- a/platform/opera/manifest.json +++ b/platform/opera/manifest.json @@ -38,13 +38,10 @@ "all_frames": true }, { - "matches": [ - "https://*.adblockplus.org/*", - "https://*.adblockplus.me/*", - "https://www.fanboy.co.nz/*" - ], - "js": ["js/subscriber.js"], - "run_at": "document_idle" + "matches": ["http://*/*", "https://*/*"], + "js": ["js/scriptlets/subscriber.js"], + "run_at": "document_idle", + "all_frames": false } ], "incognito": "split", diff --git a/src/3p-filters.html b/src/3p-filters.html index b62bc46a0..f9327304e 100644 --- a/src/3p-filters.html +++ b/src/3p-filters.html @@ -28,7 +28,10 @@
-

+

+ + +

diff --git a/src/js/background.js b/src/js/background.js index 8ff3b2b63..808cd03e5 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -40,12 +40,8 @@ var oneHour = 60 * oneMinute; var defaultExternalLists = [ '! Examples:', '! https://easylist-downloads.adblockplus.org/fb_annoyances_full.txt', - '! https://easylist-downloads.adblockplus.org/fb_annoyances_sidebar.txt', - '! https://easylist-downloads.adblockplus.org/fb_annoyances_newsfeed.txt', '! https://easylist-downloads.adblockplus.org/yt_annoyances_full.txt', - '! https://easylist-downloads.adblockplus.org/yt_annoyances_comments.txt', - '! https://easylist-downloads.adblockplus.org/yt_annoyances_suggestions.txt', - '! https://easylist-downloads.adblockplus.org/yt_annoyances_other.txt' + '' ].join('\n'); /******************************************************************************/ diff --git a/src/js/subscriber.js b/src/js/scriptlets/subscriber.js similarity index 89% rename from src/js/subscriber.js rename to src/js/scriptlets/subscriber.js index 529165ed9..8eb3f2827 100644 --- a/src/js/subscriber.js +++ b/src/js/scriptlets/subscriber.js @@ -48,12 +48,10 @@ if ( typeof vAPI !== 'object' ) { /******************************************************************************/ -// Only if at least one relevant link exists on the page -// The links look like this: -// abp:subscribe?location=https://easylist-downloads.adblockplus.org/easyprivacy.txt[...] +// Only if at least one subscribe link exists on the page. if ( - document.querySelector('a[href^="abp:"]') === null && + document.querySelector('a[href^="abp:"],a[href^="https://subscribe.adblockplus.org/?"]') === null && window.location.href !== 'https://github.com/gorhill/uBlock/wiki/Filter-lists-from-around-the-web' ) { return; @@ -117,17 +115,17 @@ var onAbpLinkClicked = function(ev) { // List already subscribed to? // https://github.com/chrisaljoudi/uBlock/issues/1033 // Split on line separators, not whitespaces. - var externalLists = details.externalLists.trim().split(/\s*[\n\r]+\s*/); - if ( externalLists.indexOf(location) !== -1 ) { + var text = details.externalLists.trim(); + var lines = text !== '' ? text.split(/\s*[\n\r]+\s*/) : []; + if ( lines.indexOf(location) !== -1 ) { return; } - - externalLists.push(location); + lines.push(location, ''); messager.send({ what: 'userSettings', name: 'externalLists', - value: externalLists.join('\n') + value: lines.join('\n') }, onExternalListsSaved); };