Index: background.js |
=================================================================== |
--- a/background.js |
+++ b/background.js |
@@ -73,7 +73,8 @@ |
addSubscription: false, |
filterError: false, |
downloadStatus: "synchronize_ok", |
- showNotificationUI: false |
+ showNotificationUI: false, |
+ showPageOptions: false |
}; |
updateFromURL(params); |
@@ -161,7 +162,7 @@ |
{ |
this._lastDownload = value; |
modules.filterNotifier.FilterNotifier.emit("subscription.lastDownload", |
- this); |
+ this); |
} |
}; |
Subscription.fromURL = function(url) |
@@ -215,7 +216,7 @@ |
{ |
knownSubscriptions[subscription.url] = fromURL(subscription.url); |
modules.filterNotifier.FilterNotifier.emit("subscription.added", |
- subscription); |
+ subscription); |
} |
}, |
@@ -227,7 +228,7 @@ |
{ |
delete knownSubscriptions[subscription.url]; |
modules.filterNotifier.FilterNotifier.emit("subscription.removed", |
- subscription); |
+ subscription); |
} |
}, |
@@ -250,7 +251,7 @@ |
{ |
customSubscription.filters.splice(i, 1); |
modules.filterNotifier.FilterNotifier.emit("filter.removed", |
- filter); |
+ filter); |
return; |
} |
} |
@@ -438,17 +439,32 @@ |
]; |
let knownFilters = filters.map(modules.filterClasses.Filter.fromText); |
+ let subscriptionServer = "https://easylist-downloads.adblockplus.org"; |
let subscriptions = [ |
- "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt", |
- "https://easylist-downloads.adblockplus.org/exceptionrules.txt", |
- "https://easylist-downloads.adblockplus.org/fanboy-social.txt", |
- "~user~786254" |
+ { |
+ title: "EasyList Germany+EasyList", |
+ url: `${subscriptionServer}/easylistgermany+easylist.txt` |
+ }, |
+ { |
+ title: "Allow non-intrusive advertising", |
+ url: `${subscriptionServer}/exceptionrules.txt` |
+ }, |
+ { |
+ title: "Fanboy's Social Blocking List", |
+ url: `${subscriptionServer}/fanboy-social.txt` |
+ }, |
+ { |
+ title: null, |
+ url: "~user~786254" |
+ } |
]; |
let knownSubscriptions = Object.create(null); |
- for (let subscriptionUrl of subscriptions) |
+ for (let {title, url} of subscriptions) |
{ |
- knownSubscriptions[subscriptionUrl] = |
- modules.subscriptionClasses.Subscription.fromURL(subscriptionUrl); |
+ let subscription = |
+ modules.subscriptionClasses.Subscription.fromURL(url); |
+ subscription.title = title; |
+ knownSubscriptions[url] = subscription; |
} |
let customSubscription = knownSubscriptions["~user~786254"]; |
@@ -470,6 +486,32 @@ |
}, 1000); |
} |
+ if (params.showPageOptions) |
+ { |
+ // We don't know how long it will take for the page to fully load |
+ // so we'll post the message after one second |
+ setTimeout(() => |
+ { |
+ let host = "example.com"; |
+ let isWhitelisted = customSubscription.filters |
+ .some((filter) => filter.text == `@@||${host}^$document`); |
+ window.postMessage({ |
+ type: "message", |
+ payload: { |
+ type: "app.open", |
+ what: "options", |
+ action: "showPageOptions", |
+ args: [ |
+ { |
+ host, |
+ whitelisted: isWhitelisted |
+ } |
+ ] |
+ } |
+ }, "*"); |
+ }, 1000); |
+ } |
+ |
ext.devtools.onCreated.addListener((panel) => |
{ |
// blocked request |