| LEFT | RIGHT |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 (function(global) | 18 "use strict"; |
| 19 |
| 20 (function() |
| 19 { | 21 { |
| 20 function EventEmitter() | 22 function EventEmitter() |
| 21 { | 23 { |
| 22 this._listeners = Object.create(null); | 24 this._listeners = Object.create(null); |
| 23 } | 25 } |
| 24 EventEmitter.prototype = { | 26 EventEmitter.prototype = { |
| 25 on: function(name, listener) | 27 on(name, listener) |
| 26 { | 28 { |
| 27 if (name in this._listeners) | 29 if (name in this._listeners) |
| 28 this._listeners[name].push(listener); | 30 this._listeners[name].push(listener); |
| 29 else | 31 else |
| 30 this._listeners[name] = [listener]; | 32 this._listeners[name] = [listener]; |
| 31 }, | 33 }, |
| 32 off: function(name, listener) | 34 off(name, listener) |
| 33 { | 35 { |
| 34 var listeners = this._listeners[name]; | 36 let listeners = this._listeners[name]; |
| 35 if (listeners) | 37 if (listeners) |
| 36 { | 38 { |
| 37 var idx = listeners.indexOf(listener); | 39 let idx = listeners.indexOf(listener); |
| 38 if (idx != -1) | 40 if (idx != -1) |
| 39 listeners.splice(idx, 1); | 41 listeners.splice(idx, 1); |
| 40 } | 42 } |
| 41 }, | 43 }, |
| 42 emit: function(name) | 44 emit(name, ...args) |
| 43 { | 45 { |
| 44 var listeners = this._listeners[name]; | 46 let listeners = this._listeners[name]; |
| 45 if (listeners) | 47 if (listeners) |
| 46 { | 48 { |
| 47 for (var i = 0; i < listeners.length; i++) | 49 for (let listener of listeners) |
| 48 listeners[i].apply(null, Array.prototype.slice.call(arguments, 1)); | 50 listener(...args); |
| 49 } | 51 } |
| 50 } | 52 } |
| 51 }; | 53 }; |
| 52 | 54 |
| 53 function updateFromURL(data) | 55 function updateFromURL(data) |
| 54 { | 56 { |
| 55 if (window.location.search) | 57 if (window.location.search) |
| 56 { | 58 { |
| 57 var params = window.location.search.substr(1).split("&"); | 59 let params = window.location.search.substr(1).split("&"); |
| 58 for (var i = 0; i < params.length; i++) | 60 |
| 59 { | 61 for (let param of params) |
| 60 var parts = params[i].split("=", 2); | 62 { |
| 63 let parts = param.split("=", 2); |
| 61 if (parts.length == 2 && parts[0] in data) | 64 if (parts.length == 2 && parts[0] in data) |
| 62 data[parts[0]] = decodeURIComponent(parts[1]); | 65 data[parts[0]] = decodeURIComponent(parts[1]); |
| 63 } | 66 } |
| 64 } | 67 } |
| 65 } | 68 } |
| 66 | 69 |
| 67 var params = { | 70 let params = { |
| 68 blockedURLs: "", | 71 blockedURLs: "", |
| 69 seenDataCorruption: false, | |
| 70 filterlistsReinitialized: false, | 72 filterlistsReinitialized: false, |
| 71 addSubscription: false, | 73 addSubscription: false, |
| 72 filterError: false, | 74 filterError: false, |
| 73 downloadStatus: "synchronize_ok", | 75 downloadStatus: "synchronize_ok", |
| 74 showNotificationUI: false, | 76 showNotificationUI: false |
| 75 safariContentBlocker: false | |
| 76 }; | 77 }; |
| 77 updateFromURL(params); | 78 updateFromURL(params); |
| 78 | 79 |
| 79 var modules = {}; | 80 let modules = {}; |
| 80 global.require = function(module) | 81 window.require = function(module) |
| 81 { | 82 { |
| 82 return modules[module]; | 83 return modules[module]; |
| 83 }; | 84 }; |
| 84 | 85 |
| 85 modules.utils = { | 86 modules.utils = { |
| 86 Utils: { | 87 Utils: { |
| 87 getDocLink: function(link) | 88 getDocLink(link) |
| 88 { | 89 { |
| 89 return "https://adblockplus.org/redirect?link=" + encodeURIComponent(lin
k); | 90 return "https://adblockplus.org/redirect?link=" + encodeURIComponent(lin
k); |
| 90 }, | 91 }, |
| 91 get appLocale() | 92 get appLocale() |
| 92 { | 93 { |
| 93 return parent.ext.i18n.getMessage("@@ui_locale").replace(/_/g, "-"); | 94 return parent.ext.i18n.locale.replace(/_/g, "-"); |
| 94 }, | 95 }, |
| 95 get readingDirection() | 96 get readingDirection() |
| 96 { | 97 { |
| 97 return parent.ext.i18n.getMessage("@@bidi_dir"); | 98 return /^(?:ar|fa|he|ug|ur)\b/.test(this.appLocale) ? "rtl" : "ltr"; |
| 98 } | 99 } |
| 99 | |
| 100 } | 100 } |
| 101 }; | 101 }; |
| 102 | 102 |
| 103 modules.prefs = {Prefs: new EventEmitter()}; | 103 modules.prefs = {Prefs: new EventEmitter()}; |
| 104 var prefs = { | 104 let prefs = { |
| 105 notifications_ignoredcategories: (params.showNotificationUI) ? ["*"] : [], | 105 notifications_ignoredcategories: (params.showNotificationUI) ? ["*"] : [], |
| 106 notifications_showui: params.showNotificationUI, | 106 notifications_showui: params.showNotificationUI, |
| 107 safari_contentblocker: false, | |
| 108 shouldShowBlockElementMenu: true, | 107 shouldShowBlockElementMenu: true, |
| 109 show_devtools_panel: true, | 108 show_devtools_panel: true, |
| 110 subscriptions_exceptionsurl: "https://easylist-downloads.adblockplus.org/exc
eptionrules.txt" | 109 subscriptions_exceptionsurl: "https://easylist-downloads.adblockplus.org/exc
eptionrules.txt", |
| 111 }; | 110 subscriptions_exceptionsurl_privacy: "https://easylist-downloads.adblockplus
.org/exceptionrules-privacy.txt" |
| 112 Object.keys(prefs).forEach(function(key) | 111 }; |
| 112 for (let key of Object.keys(prefs)) |
| 113 { | 113 { |
| 114 Object.defineProperty(modules.prefs.Prefs, key, { | 114 Object.defineProperty(modules.prefs.Prefs, key, { |
| 115 get: function() | 115 get() |
| 116 { | 116 { |
| 117 return prefs[key]; | 117 return prefs[key]; |
| 118 }, | 118 }, |
| 119 set: function(value) | 119 set(value) |
| 120 { | 120 { |
| 121 prefs[key] = value; | 121 prefs[key] = value; |
| 122 modules.prefs.Prefs.emit(key); | 122 modules.prefs.Prefs.emit(key); |
| 123 } | 123 } |
| 124 }); | 124 }); |
| 125 }); | 125 } |
| 126 | 126 |
| 127 modules.notification = { | 127 modules.notification = { |
| 128 Notification: { | 128 Notification: { |
| 129 toggleIgnoreCategory: function(category) | 129 toggleIgnoreCategory(category) |
| 130 { | 130 { |
| 131 var categories = prefs.notifications_ignoredcategories; | 131 let categories = prefs.notifications_ignoredcategories; |
| 132 var index = categories.indexOf(category); | 132 let index = categories.indexOf(category); |
| 133 if (index == -1) | 133 if (index == -1) |
| 134 categories.push(category); | 134 categories.push(category); |
| 135 else | 135 else |
| 136 categories.splice(index, 1); | 136 categories.splice(index, 1); |
| 137 modules.prefs.Prefs.notifications_ignoredcategories = categories; | 137 modules.prefs.Prefs.notifications_ignoredcategories = categories; |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 }; | 140 }; |
| 141 | 141 |
| 142 modules.subscriptionClasses = { | 142 function Subscription(url) |
| 143 Subscription: function(url) | 143 { |
| 144 { | 144 this.url = url; |
| 145 this.url = url; | 145 this._disabled = false; |
| 146 this._disabled = false; | 146 this._lastDownload = 1234; |
| 147 this._lastDownload = 1234; | 147 this.homepage = "https://easylist.adblockplus.org/"; |
| 148 this.homepage = "https://easylist.adblockplus.org/"; | 148 this.downloadStatus = params.downloadStatus; |
| 149 this.downloadStatus = params.downloadStatus; | 149 |
| 150 }, | 150 if (subscriptions[this.url] && subscriptions[this.url].title) |
| 151 | 151 { |
| 152 SpecialSubscription: function(url) | 152 this.title = subscriptions[this.url].title; |
| 153 { | 153 } |
| 154 this.url = url; | 154 if (this.url == prefs.subscriptions_exceptionsurl_privacy) |
| 155 this.disabled = false; | 155 { |
| 156 this.filters = knownFilters.slice(); | 156 this.title = "Allow only nonintrusive ads that are privacy-friendly"; |
| 157 } | 157 } |
| 158 }; | 158 } |
| 159 modules.subscriptionClasses.Subscription.fromURL = function(url) | 159 Subscription.prototype = |
| 160 { |
| 161 get disabled() |
| 162 { |
| 163 return this._disabled; |
| 164 }, |
| 165 set disabled(value) |
| 166 { |
| 167 this._disabled = value; |
| 168 modules.filterNotifier.FilterNotifier.emit("subscription.disabled", this); |
| 169 }, |
| 170 get lastDownload() |
| 171 { |
| 172 return this._lastDownload; |
| 173 }, |
| 174 set lastDownload(value) |
| 175 { |
| 176 this._lastDownload = value; |
| 177 modules.filterNotifier.FilterNotifier.emit("subscription.lastDownload", |
| 178 this); |
| 179 } |
| 180 }; |
| 181 Subscription.fromURL = function(url) |
| 160 { | 182 { |
| 161 if (url in knownSubscriptions) | 183 if (url in knownSubscriptions) |
| 162 return knownSubscriptions[url]; | 184 return knownSubscriptions[url]; |
| 163 | 185 |
| 164 if (/^https?:\/\//.test(url)) | 186 if (/^https?:\/\//.test(url)) |
| 165 return new modules.subscriptionClasses.Subscription(url); | 187 return new modules.subscriptionClasses.Subscription(url); |
| 166 else | 188 return new modules.subscriptionClasses.SpecialSubscription(url); |
| 167 return new modules.subscriptionClasses.SpecialSubscription(url); | 189 }; |
| 168 }; | 190 |
| 169 modules.subscriptionClasses.DownloadableSubscription = modules.subscriptionCla
sses.Subscription; | 191 function SpecialSubscription(url) |
| 170 | 192 { |
| 171 modules.subscriptionClasses.Subscription.prototype = | 193 this.url = url; |
| 172 { | 194 this.disabled = false; |
| 173 get disabled() | 195 this.filters = knownFilters.slice(); |
| 174 { | 196 } |
| 175 return this._disabled; | 197 |
| 176 }, | 198 modules.subscriptionClasses = { |
| 177 set disabled(value) | 199 Subscription, |
| 178 { | 200 SpecialSubscription, |
| 179 this._disabled = value; | 201 DownloadableSubscription: Subscription |
| 180 modules.filterNotifier.FilterNotifier.emit("subscription.disabled", this); | 202 }; |
| 181 }, | |
| 182 get lastDownload() | |
| 183 { | |
| 184 return this._lastDownload; | |
| 185 }, | |
| 186 set lastDownload(value) | |
| 187 { | |
| 188 this._lastDownload = value; | |
| 189 modules.filterNotifier.FilterNotifier.emit("subscription.lastDownload", th
is); | |
| 190 } | |
| 191 }; | |
| 192 | |
| 193 | 203 |
| 194 modules.filterStorage = { | 204 modules.filterStorage = { |
| 195 FilterStorage: { | 205 FilterStorage: { |
| 196 get subscriptions() | 206 get subscriptions() |
| 197 { | 207 { |
| 198 var subscriptions = []; | 208 let subscriptions = []; |
| 199 for (var url in modules.filterStorage.FilterStorage.knownSubscriptions) | 209 for (let url in modules.filterStorage.FilterStorage.knownSubscriptions) |
| 200 subscriptions.push(modules.filterStorage.FilterStorage.knownSubscripti
ons[url]); | 210 { |
| 211 subscriptions.push( |
| 212 modules.filterStorage.FilterStorage.knownSubscriptions[url] |
| 213 ); |
| 214 } |
| 201 return subscriptions; | 215 return subscriptions; |
| 202 }, | 216 }, |
| 203 | 217 |
| 204 get knownSubscriptions() | 218 get knownSubscriptions() |
| 205 { | 219 { |
| 206 return knownSubscriptions; | 220 return knownSubscriptions; |
| 207 }, | 221 }, |
| 208 | 222 |
| 209 addSubscription: function(subscription) | 223 addSubscription(subscription) |
| 210 { | 224 { |
| 211 if (!(subscription.url in modules.filterStorage.FilterStorage.knownSubsc
riptions)) | 225 let {fromURL} = Subscription; |
| 226 let {FilterStorage} = modules.filterStorage; |
| 227 |
| 228 if (!(subscription.url in FilterStorage.knownSubscriptions)) |
| 212 { | 229 { |
| 213 knownSubscriptions[subscription.url] = modules.subscriptionClasses.Sub
scription.fromURL(subscription.url); | 230 knownSubscriptions[subscription.url] = fromURL(subscription.url); |
| 214 modules.filterNotifier.FilterNotifier.emit("subscription.added", subsc
ription); | 231 modules.filterNotifier.FilterNotifier.emit("subscription.added", |
| 232 subscription); |
| 215 } | 233 } |
| 216 }, | 234 }, |
| 217 | 235 |
| 218 removeSubscription: function(subscription) | 236 removeSubscription(subscription) |
| 219 { | 237 { |
| 220 if (subscription.url in modules.filterStorage.FilterStorage.knownSubscri
ptions) | 238 let {FilterStorage} = modules.filterStorage; |
| 239 |
| 240 if (subscription.url in FilterStorage.knownSubscriptions) |
| 221 { | 241 { |
| 222 delete knownSubscriptions[subscription.url]; | 242 delete knownSubscriptions[subscription.url]; |
| 223 modules.filterNotifier.FilterNotifier.emit("subscription.removed", sub
scription); | 243 modules.filterNotifier.FilterNotifier.emit("subscription.removed", |
| 244 subscription); |
| 224 } | 245 } |
| 225 }, | 246 }, |
| 226 | 247 |
| 227 addFilter: function(filter) | 248 addFilter(filter) |
| 228 { | 249 { |
| 229 for (var i = 0; i < customSubscription.filters.length; i++) | 250 for (let customFilter of customSubscription.filters) |
| 230 { | 251 { |
| 231 if (customSubscription.filters[i].text == filter.text) | 252 if (customFilter.text == filter.text) |
| 232 return; | 253 return; |
| 233 } | 254 } |
| 234 customSubscription.filters.push(filter); | 255 customSubscription.filters.push(filter); |
| 235 modules.filterNotifier.FilterNotifier.emit("filter.added", filter); | 256 modules.filterNotifier.FilterNotifier.emit("filter.added", filter); |
| 236 }, | 257 }, |
| 237 | 258 |
| 238 removeFilter: function(filter) | 259 removeFilter(filter) |
| 239 { | 260 { |
| 240 for (var i = 0; i < customSubscription.filters.length; i++) | 261 for (let i = 0; i < customSubscription.filters.length; i++) |
| 241 { | 262 { |
| 242 if (customSubscription.filters[i].text == filter.text) | 263 if (customSubscription.filters[i].text == filter.text) |
| 243 { | 264 { |
| 244 customSubscription.filters.splice(i, 1); | 265 customSubscription.filters.splice(i, 1); |
| 245 modules.filterNotifier.FilterNotifier.emit("filter.removed", filter)
; | 266 modules.filterNotifier.FilterNotifier.emit("filter.removed", |
| 267 filter); |
| 246 return; | 268 return; |
| 247 } | 269 } |
| 248 } | 270 } |
| 249 } | 271 } |
| 250 } | 272 } |
| 251 }; | 273 }; |
| 252 | 274 |
| 275 function Filter(text) |
| 276 { |
| 277 this.text = text; |
| 278 this.disabled = false; |
| 279 } |
| 280 Filter.fromText = (text) => new Filter(text); |
| 281 |
| 282 function BlockingFilter() |
| 283 { |
| 284 } |
| 285 |
| 286 function RegExpFilter() |
| 287 { |
| 288 } |
| 289 RegExpFilter.typeMap = Object.create(null); |
| 290 |
| 253 modules.filterClasses = { | 291 modules.filterClasses = { |
| 254 BlockingFilter: function() {}, | 292 BlockingFilter, |
| 255 Filter: function(text) | 293 Filter, |
| 256 { | 294 RegExpFilter |
| 257 this.text = text; | 295 }; |
| 258 this.disabled = false; | 296 |
| 259 }, | 297 modules.filterValidation = |
| 260 RegExpFilter: function() {} | 298 { |
| 261 }; | 299 parseFilter(text) |
| 262 modules.filterClasses.Filter.fromText = function(text) | |
| 263 { | |
| 264 return new modules.filterClasses.Filter(text); | |
| 265 }; | |
| 266 modules.filterClasses.RegExpFilter.typeMap = Object.create(null); | |
| 267 | |
| 268 modules.filterValidation = | |
| 269 { | |
| 270 parseFilter: function(text) | |
| 271 { | 300 { |
| 272 if (params.filterError) | 301 if (params.filterError) |
| 273 return {error: "Invalid filter"}; | 302 return {error: "Invalid filter"}; |
| 274 return {filter: modules.filterClasses.Filter.fromText(text)}; | 303 return {filter: modules.filterClasses.Filter.fromText(text)}; |
| 275 }, | 304 }, |
| 276 parseFilters: function(text) | 305 parseFilters(text) |
| 277 { | 306 { |
| 278 if (params.filterError) | 307 if (params.filterError) |
| 279 return {errors: ["Invalid filter"]}; | 308 return {errors: ["Invalid filter"]}; |
| 280 return { | 309 return { |
| 281 filters: text.split("\n") | 310 filters: text.split("\n") |
| 282 .filter(function(filter) {return !!filter;}) | 311 .filter((filter) => !!filter) |
| 283 .map(modules.filterClasses.Filter.fromText), | 312 .map(modules.filterClasses.Filter.fromText), |
| 284 errors: [] | 313 errors: [] |
| 285 }; | 314 }; |
| 286 } | 315 } |
| 287 }; | 316 }; |
| 288 | 317 |
| 289 modules.synchronizer = { | 318 modules.synchronizer = { |
| 290 Synchronizer: { | 319 Synchronizer: { |
| 291 _downloading: false, | 320 _downloading: false, |
| 292 execute: function(subscription, manual) | 321 execute(subscription, manual) |
| 293 { | 322 { |
| 294 modules.synchronizer.Synchronizer._downloading = true; | 323 modules.synchronizer.Synchronizer._downloading = true; |
| 295 modules.filterNotifier.FilterNotifier.emit( | 324 modules.filterNotifier.FilterNotifier.emit( |
| 296 "subscription.downloading", subscription | 325 "subscription.downloading", subscription |
| 297 ); | 326 ); |
| 298 setTimeout(function() | 327 setTimeout(() => |
| 299 { | 328 { |
| 300 modules.synchronizer.Synchronizer._downloading = false; | 329 modules.synchronizer.Synchronizer._downloading = false; |
| 301 subscription.lastDownload = Date.now() / 1000; | 330 subscription.lastDownload = Date.now() / 1000; |
| 302 }, 500); | 331 }, 500); |
| 303 }, | 332 }, |
| 304 isExecuting: function(url) | 333 isExecuting(url) |
| 305 { | 334 { |
| 306 return modules.synchronizer.Synchronizer._downloading; | 335 return modules.synchronizer.Synchronizer._downloading; |
| 307 } | 336 } |
| 308 } | 337 } |
| 309 }; | 338 }; |
| 310 | 339 |
| 311 modules.matcher = { | 340 modules.matcher = { |
| 312 defaultMatcher: { | 341 defaultMatcher: { |
| 313 matchesAny: function(url, requestType, docDomain, thirdParty) | 342 matchesAny(url, requestType, docDomain, thirdParty) |
| 314 { | 343 { |
| 315 var blocked = params.blockedURLs.split(","); | 344 let blocked = params.blockedURLs.split(","); |
| 316 if (blocked.indexOf(url) >= 0) | 345 if (blocked.indexOf(url) >= 0) |
| 317 return new modules.filterClasses.BlockingFilter(); | 346 return new modules.filterClasses.BlockingFilter(); |
| 318 else | 347 return null; |
| 319 return null; | 348 } |
| 320 } | 349 } |
| 321 } | 350 }; |
| 322 }; | 351 |
| 323 | 352 modules.elemHideEmulation = { |
| 324 modules.cssRules = { | 353 ElemHideEmulation: {} |
| 325 CSSRules: { | |
| 326 getRulesForDomain: function(domain) { } | |
| 327 } | |
| 328 }; | 354 }; |
| 329 | 355 |
| 330 modules.filterNotifier = { | 356 modules.filterNotifier = { |
| 331 FilterNotifier: new EventEmitter() | 357 FilterNotifier: new EventEmitter() |
| 332 }; | 358 }; |
| 333 | 359 |
| 334 modules.info = { | 360 modules.info = { |
| 335 platform: "gecko", | 361 platform: "gecko", |
| 336 platformVersion: "34.0", | 362 platformVersion: "34.0", |
| 337 application: "firefox", | 363 application: "firefox", |
| 338 applicationVersion: "34.0", | 364 applicationVersion: "34.0", |
| 339 addonName: "adblockplus", | 365 addonName: "adblockplus", |
| 340 addonVersion: "2.6.7" | 366 addonVersion: "2.6.7" |
| 341 }; | 367 }; |
| 342 updateFromURL(modules.info); | 368 updateFromURL(modules.info); |
| 343 | 369 |
| 344 global.Services = { | 370 modules.subscriptionInit = { |
| 371 reinitialized: params.filterlistsReinitialized |
| 372 }; |
| 373 |
| 374 modules.messaging = { |
| 375 port: new EventEmitter() |
| 376 }; |
| 377 |
| 378 window.addEventListener("message", (event) => |
| 379 { |
| 380 if (event.data.type != "message") |
| 381 return; |
| 382 let message = event.data.payload; |
| 383 let {messageId} = event.data; |
| 384 let sender = { |
| 385 page: new ext.Page(event.source) |
| 386 }; |
| 387 |
| 388 let listeners = modules.messaging.port._listeners[message.type]; |
| 389 if (!listeners) |
| 390 return; |
| 391 |
| 392 function reply(responseMessage) |
| 393 { |
| 394 event.source.postMessage({ |
| 395 type: "response", |
| 396 messageId, |
| 397 payload: responseMessage |
| 398 }, "*"); |
| 399 } |
| 400 |
| 401 for (let listener of listeners) |
| 402 { |
| 403 let response = listener(message, sender); |
| 404 if (response && typeof response.then == "function") |
| 405 { |
| 406 response.then( |
| 407 reply, |
| 408 (reason) => |
| 409 { |
| 410 console.error(reason); |
| 411 reply(undefined); |
| 412 } |
| 413 ); |
| 414 } |
| 415 else if (typeof response != "undefined") |
| 416 { |
| 417 reply(response); |
| 418 } |
| 419 } |
| 420 }); |
| 421 |
| 422 window.Services = { |
| 345 vc: { | 423 vc: { |
| 346 compare: function(v1, v2) | 424 compare(v1, v2) |
| 347 { | 425 { |
| 348 return parseFloat(v1) - parseFloat(v2); | 426 return parseFloat(v1) - parseFloat(v2); |
| 349 } | 427 } |
| 350 } | 428 } |
| 351 }; | 429 }; |
| 352 | 430 |
| 353 var filters = [ | 431 let filters = [ |
| 354 "@@||alternate.de^$document", | 432 "@@||alternate.de^$document", |
| 355 "@@||der.postillion.com^$document", | 433 "@@||der.postillion.com^$document", |
| 356 "@@||taz.de^$document", | 434 "@@||taz.de^$document", |
| 357 "@@||amazon.de^$document", | 435 "@@||amazon.de^$document", |
| 358 "||biglemon.am/bg_poster/banner.jpg", | 436 "||biglemon.am/bg_poster/banner.jpg", |
| 359 "winfuture.de###header_logo_link", | 437 "winfuture.de###header_logo_link", |
| 360 "###WerbungObenRechts10_GesamtDIV", | 438 "###WerbungObenRechts10_GesamtDIV", |
| 361 "###WerbungObenRechts8_GesamtDIV", | 439 "###WerbungObenRechts8_GesamtDIV", |
| 362 "###WerbungObenRechts9_GesamtDIV", | 440 "###WerbungObenRechts9_GesamtDIV", |
| 363 "###WerbungUntenLinks4_GesamtDIV", | 441 "###WerbungUntenLinks4_GesamtDIV", |
| 364 "###WerbungUntenLinks7_GesamtDIV", | 442 "###WerbungUntenLinks7_GesamtDIV", |
| 365 "###WerbungUntenLinks8_GesamtDIV", | 443 "###WerbungUntenLinks8_GesamtDIV", |
| 366 "###WerbungUntenLinks9_GesamtDIV", | 444 "###WerbungUntenLinks9_GesamtDIV", |
| 367 "###Werbung_Sky", | 445 "###Werbung_Sky", |
| 368 "###Werbung_Wide", | 446 "###Werbung_Wide", |
| 369 "###__ligatus_placeholder__", | 447 "###__ligatus_placeholder__", |
| 370 "###ad-bereich1-08", | 448 "###ad-bereich1-08", |
| 371 "###ad-bereich1-superbanner", | 449 "###ad-bereich1-superbanner", |
| 372 "###ad-bereich2-08", | 450 "###ad-bereich2-08", |
| 373 "###ad-bereich2-skyscrapper" | 451 "###ad-bereich2-skyscrapper" |
| 374 ]; | 452 ]; |
| 375 var knownFilters = filters.map(modules.filterClasses.Filter.fromText); | 453 let knownFilters = filters.map(modules.filterClasses.Filter.fromText); |
| 376 | 454 |
| 377 var subscriptions = [ | 455 let subscriptions = { |
| 378 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt", | 456 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt": { |
| 379 "https://easylist-downloads.adblockplus.org/exceptionrules.txt", | 457 title: "EasyList Germany+EasyList" |
| 380 "https://easylist-downloads.adblockplus.org/fanboy-social.txt", | 458 }, |
| 381 "~user~786254" | 459 "https://easylist-downloads.adblockplus.org/exceptionrules.txt": { |
| 382 ]; | 460 title: "Allow non-intrusive advertising" |
| 383 var knownSubscriptions = Object.create(null); | 461 }, |
| 384 for (var subscriptionUrl of subscriptions) | 462 "https://easylist-downloads.adblockplus.org/fanboy-social.txt": { |
| 385 knownSubscriptions[subscriptionUrl] = modules.subscriptionClasses.Subscripti
on.fromURL(subscriptionUrl); | 463 title: "Fanboy's Social Blocking List", |
| 386 var customSubscription = knownSubscriptions["~user~786254"]; | 464 type: "social" |
| 387 | 465 }, |
| 388 global.seenDataCorruption = params.seenDataCorruption; | 466 "https://easylist-downloads.adblockplus.org/antiadblockfilters.txt": { |
| 389 global.filterlistsReinitialized = params.filterlistsReinitialized; | 467 title: "Adblock Warning Removal List" |
| 468 }, |
| 469 "~user~78625": { |
| 470 title: "My filter list" |
| 471 } |
| 472 }; |
| 473 |
| 474 let knownSubscriptions = Object.create(null); |
| 475 for (let subscriptionUrl in subscriptions) |
| 476 { |
| 477 knownSubscriptions[subscriptionUrl] = |
| 478 modules.subscriptionClasses.Subscription.fromURL(subscriptionUrl); |
| 479 } |
| 480 let customSubscription = knownSubscriptions["~user~78625"]; |
| 390 | 481 |
| 391 if (params.addSubscription) | 482 if (params.addSubscription) |
| 392 { | 483 { |
| 393 // We don't know how long it will take for the page to fully load | 484 // We don't know how long it will take for the page to fully load |
| 394 // so we'll post the message after one second | 485 // so we'll post the message after one second |
| 395 setTimeout(function() | 486 setTimeout(() => |
| 396 { | 487 { |
| 397 window.postMessage({ | 488 window.postMessage({ |
| 398 type: "message", | 489 type: "message", |
| 399 payload: { | 490 payload: { |
| 400 title: "Custom subscription", | 491 title: "Custom subscription", |
| 401 url: "http://example.com/custom.txt", | 492 url: "http://example.com/custom.txt", |
| 402 confirm: true, | 493 confirm: true, |
| 403 type: "subscriptions.add" | 494 type: "subscriptions.add" |
| 404 } | 495 } |
| 405 }, "*"); | 496 }, "*"); |
| 406 }, 1000); | 497 }, 1000); |
| 407 } | 498 } |
| 408 | 499 |
| 409 ext.devtools.onCreated.addListener(function(panel) | 500 ext.devtools.onCreated.addListener((panel) => |
| 410 { | 501 { |
| 411 // blocked request | 502 // blocked request |
| 412 panel.sendMessage({ | 503 panel.sendMessage({ |
| 413 type: "add-record", | 504 type: "add-record", |
| 414 request: { | 505 request: { |
| 415 url: "http://adserver.example.com/ad_banner.png", | 506 url: "http://adserver.example.com/ad_banner.png", |
| 416 type: "IMAGE", | 507 type: "IMAGE", |
| 417 docDomain: "example.com" | 508 docDomain: "example.com" |
| 418 }, | 509 }, |
| 419 filter: { | 510 filter: { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 docDomain: "example.com" | 566 docDomain: "example.com" |
| 476 }, | 567 }, |
| 477 filter: { | 568 filter: { |
| 478 text: "||example.com/some-annoying-popup$popup", | 569 text: "||example.com/some-annoying-popup$popup", |
| 479 whitelisted: false, | 570 whitelisted: false, |
| 480 userDefined: true, | 571 userDefined: true, |
| 481 subscription: null | 572 subscription: null |
| 482 } | 573 } |
| 483 }); | 574 }); |
| 484 }); | 575 }); |
| 485 | 576 }()); |
| 486 if (params.safariContentBlocker) | |
| 487 { | |
| 488 global.safari = { | |
| 489 extension: { | |
| 490 setContentBlocker: function() {} | |
| 491 } | |
| 492 }; | |
| 493 } | |
| 494 })(this); | |
| LEFT | RIGHT |