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.locale.replace(/_/g, "-"); | 94 return parent.ext.i18n.locale.replace(/_/g, "-"); |
94 }, | 95 }, |
95 get readingDirection() | 96 get readingDirection() |
96 { | 97 { |
97 return bidiDir = /^(ar|fa|he|ug|ur)(-|$)/.test(this.appLocale) ? "rtl" :
"ltr"; | 98 return /^(?:ar|fa|he|ug|ur)\b/.test(this.appLocale) ? "rtl" : "ltr"; |
98 } | 99 } |
99 } | 100 } |
100 }; | 101 }; |
101 | 102 |
102 modules.prefs = {Prefs: new EventEmitter()}; | 103 modules.prefs = {Prefs: new EventEmitter()}; |
103 var prefs = { | 104 let prefs = { |
104 notifications_ignoredcategories: (params.showNotificationUI) ? ["*"] : [], | 105 notifications_ignoredcategories: (params.showNotificationUI) ? ["*"] : [], |
105 notifications_showui: params.showNotificationUI, | 106 notifications_showui: params.showNotificationUI, |
106 safari_contentblocker: false, | |
107 shouldShowBlockElementMenu: true, | 107 shouldShowBlockElementMenu: true, |
108 show_devtools_panel: true, | 108 show_devtools_panel: true, |
109 subscriptions_exceptionsurl: "https://easylist-downloads.adblockplus.org/exc
eptionrules.txt" | 109 subscriptions_exceptionsurl: "https://easylist-downloads.adblockplus.org/exc
eptionrules.txt", |
110 }; | 110 subscriptions_exceptionsurl_privacy: "https://easylist-downloads.adblockplus
.org/exceptionrules-privacy.txt" |
111 Object.keys(prefs).forEach(function(key) | 111 }; |
| 112 for (let key of Object.keys(prefs)) |
112 { | 113 { |
113 Object.defineProperty(modules.prefs.Prefs, key, { | 114 Object.defineProperty(modules.prefs.Prefs, key, { |
114 get: function() | 115 get() |
115 { | 116 { |
116 return prefs[key]; | 117 return prefs[key]; |
117 }, | 118 }, |
118 set: function(value) | 119 set(value) |
119 { | 120 { |
120 prefs[key] = value; | 121 prefs[key] = value; |
121 modules.prefs.Prefs.emit(key); | 122 modules.prefs.Prefs.emit(key); |
122 } | 123 } |
123 }); | 124 }); |
124 }); | 125 } |
125 | 126 |
126 modules.notification = { | 127 modules.notification = { |
127 Notification: { | 128 Notification: { |
128 toggleIgnoreCategory: function(category) | 129 toggleIgnoreCategory(category) |
129 { | 130 { |
130 var categories = prefs.notifications_ignoredcategories; | 131 let categories = prefs.notifications_ignoredcategories; |
131 var index = categories.indexOf(category); | 132 let index = categories.indexOf(category); |
132 if (index == -1) | 133 if (index == -1) |
133 categories.push(category); | 134 categories.push(category); |
134 else | 135 else |
135 categories.splice(index, 1); | 136 categories.splice(index, 1); |
136 modules.prefs.Prefs.notifications_ignoredcategories = categories; | 137 modules.prefs.Prefs.notifications_ignoredcategories = categories; |
137 } | 138 } |
138 } | 139 } |
139 }; | 140 }; |
140 | 141 |
141 modules.subscriptionClasses = { | 142 function Subscription(url) |
142 Subscription: function(url) | 143 { |
143 { | 144 this.url = url; |
144 this.url = url; | 145 this._disabled = false; |
145 this._disabled = false; | 146 this._lastDownload = 1234; |
146 this._lastDownload = 1234; | 147 this.homepage = "https://easylist.adblockplus.org/"; |
147 this.homepage = "https://easylist.adblockplus.org/"; | 148 this.downloadStatus = params.downloadStatus; |
148 this.downloadStatus = params.downloadStatus; | 149 |
149 }, | 150 if (subscriptions[this.url] && subscriptions[this.url].title) |
150 | 151 { |
151 SpecialSubscription: function(url) | 152 this.title = subscriptions[this.url].title; |
152 { | 153 } |
153 this.url = url; | 154 if (this.url == prefs.subscriptions_exceptionsurl_privacy) |
154 this.disabled = false; | 155 { |
155 this.filters = knownFilters.slice(); | 156 this.title = "Allow only nonintrusive ads that are privacy-friendly"; |
156 } | 157 } |
157 }; | 158 } |
158 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) |
159 { | 182 { |
160 if (url in knownSubscriptions) | 183 if (url in knownSubscriptions) |
161 return knownSubscriptions[url]; | 184 return knownSubscriptions[url]; |
162 | 185 |
163 if (/^https?:\/\//.test(url)) | 186 if (/^https?:\/\//.test(url)) |
164 return new modules.subscriptionClasses.Subscription(url); | 187 return new modules.subscriptionClasses.Subscription(url); |
165 else | 188 return new modules.subscriptionClasses.SpecialSubscription(url); |
166 return new modules.subscriptionClasses.SpecialSubscription(url); | 189 }; |
167 }; | 190 |
168 modules.subscriptionClasses.DownloadableSubscription = modules.subscriptionCla
sses.Subscription; | 191 function SpecialSubscription(url) |
169 | 192 { |
170 modules.subscriptionClasses.Subscription.prototype = | 193 this.url = url; |
171 { | 194 this.disabled = false; |
172 get disabled() | 195 this.filters = knownFilters.slice(); |
173 { | 196 } |
174 return this._disabled; | 197 |
175 }, | 198 modules.subscriptionClasses = { |
176 set disabled(value) | 199 Subscription, |
177 { | 200 SpecialSubscription, |
178 this._disabled = value; | 201 DownloadableSubscription: Subscription |
179 modules.filterNotifier.FilterNotifier.emit("subscription.disabled", this); | 202 }; |
180 }, | |
181 get lastDownload() | |
182 { | |
183 return this._lastDownload; | |
184 }, | |
185 set lastDownload(value) | |
186 { | |
187 this._lastDownload = value; | |
188 modules.filterNotifier.FilterNotifier.emit("subscription.lastDownload", th
is); | |
189 } | |
190 }; | |
191 | |
192 | 203 |
193 modules.filterStorage = { | 204 modules.filterStorage = { |
194 FilterStorage: { | 205 FilterStorage: { |
195 get subscriptions() | 206 get subscriptions() |
196 { | 207 { |
197 var subscriptions = []; | 208 let subscriptions = []; |
198 for (var url in modules.filterStorage.FilterStorage.knownSubscriptions) | 209 for (let url in modules.filterStorage.FilterStorage.knownSubscriptions) |
199 subscriptions.push(modules.filterStorage.FilterStorage.knownSubscripti
ons[url]); | 210 { |
| 211 subscriptions.push( |
| 212 modules.filterStorage.FilterStorage.knownSubscriptions[url] |
| 213 ); |
| 214 } |
200 return subscriptions; | 215 return subscriptions; |
201 }, | 216 }, |
202 | 217 |
203 get knownSubscriptions() | 218 get knownSubscriptions() |
204 { | 219 { |
205 return knownSubscriptions; | 220 return knownSubscriptions; |
206 }, | 221 }, |
207 | 222 |
208 addSubscription: function(subscription) | 223 addSubscription(subscription) |
209 { | 224 { |
210 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)) |
211 { | 229 { |
212 knownSubscriptions[subscription.url] = modules.subscriptionClasses.Sub
scription.fromURL(subscription.url); | 230 knownSubscriptions[subscription.url] = fromURL(subscription.url); |
213 modules.filterNotifier.FilterNotifier.emit("subscription.added", subsc
ription); | 231 modules.filterNotifier.FilterNotifier.emit("subscription.added", |
| 232 subscription); |
214 } | 233 } |
215 }, | 234 }, |
216 | 235 |
217 removeSubscription: function(subscription) | 236 removeSubscription(subscription) |
218 { | 237 { |
219 if (subscription.url in modules.filterStorage.FilterStorage.knownSubscri
ptions) | 238 let {FilterStorage} = modules.filterStorage; |
| 239 |
| 240 if (subscription.url in FilterStorage.knownSubscriptions) |
220 { | 241 { |
221 delete knownSubscriptions[subscription.url]; | 242 delete knownSubscriptions[subscription.url]; |
222 modules.filterNotifier.FilterNotifier.emit("subscription.removed", sub
scription); | 243 modules.filterNotifier.FilterNotifier.emit("subscription.removed", |
| 244 subscription); |
223 } | 245 } |
224 }, | 246 }, |
225 | 247 |
226 addFilter: function(filter) | 248 addFilter(filter) |
227 { | 249 { |
228 for (var i = 0; i < customSubscription.filters.length; i++) | 250 for (let customFilter of customSubscription.filters) |
229 { | 251 { |
230 if (customSubscription.filters[i].text == filter.text) | 252 if (customFilter.text == filter.text) |
231 return; | 253 return; |
232 } | 254 } |
233 customSubscription.filters.push(filter); | 255 customSubscription.filters.push(filter); |
234 modules.filterNotifier.FilterNotifier.emit("filter.added", filter); | 256 modules.filterNotifier.FilterNotifier.emit("filter.added", filter); |
235 }, | 257 }, |
236 | 258 |
237 removeFilter: function(filter) | 259 removeFilter(filter) |
238 { | 260 { |
239 for (var i = 0; i < customSubscription.filters.length; i++) | 261 for (let i = 0; i < customSubscription.filters.length; i++) |
240 { | 262 { |
241 if (customSubscription.filters[i].text == filter.text) | 263 if (customSubscription.filters[i].text == filter.text) |
242 { | 264 { |
243 customSubscription.filters.splice(i, 1); | 265 customSubscription.filters.splice(i, 1); |
244 modules.filterNotifier.FilterNotifier.emit("filter.removed", filter)
; | 266 modules.filterNotifier.FilterNotifier.emit("filter.removed", |
| 267 filter); |
245 return; | 268 return; |
246 } | 269 } |
247 } | 270 } |
248 } | 271 } |
249 } | 272 } |
250 }; | 273 }; |
251 | 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 |
252 modules.filterClasses = { | 291 modules.filterClasses = { |
253 BlockingFilter: function() {}, | 292 BlockingFilter, |
254 Filter: function(text) | 293 Filter, |
255 { | 294 RegExpFilter |
256 this.text = text; | 295 }; |
257 this.disabled = false; | 296 |
258 }, | 297 modules.filterValidation = |
259 RegExpFilter: function() {} | 298 { |
260 }; | 299 parseFilter(text) |
261 modules.filterClasses.Filter.fromText = function(text) | |
262 { | |
263 return new modules.filterClasses.Filter(text); | |
264 }; | |
265 modules.filterClasses.RegExpFilter.typeMap = Object.create(null); | |
266 | |
267 modules.filterValidation = | |
268 { | |
269 parseFilter: function(text) | |
270 { | 300 { |
271 if (params.filterError) | 301 if (params.filterError) |
272 return {error: "Invalid filter"}; | 302 return {error: "Invalid filter"}; |
273 return {filter: modules.filterClasses.Filter.fromText(text)}; | 303 return {filter: modules.filterClasses.Filter.fromText(text)}; |
274 }, | 304 }, |
275 parseFilters: function(text) | 305 parseFilters(text) |
276 { | 306 { |
277 if (params.filterError) | 307 if (params.filterError) |
278 return {errors: ["Invalid filter"]}; | 308 return {errors: ["Invalid filter"]}; |
279 return { | 309 return { |
280 filters: text.split("\n") | 310 filters: text.split("\n") |
281 .filter(function(filter) {return !!filter;}) | 311 .filter((filter) => !!filter) |
282 .map(modules.filterClasses.Filter.fromText), | 312 .map(modules.filterClasses.Filter.fromText), |
283 errors: [] | 313 errors: [] |
284 }; | 314 }; |
285 } | 315 } |
286 }; | 316 }; |
287 | 317 |
288 modules.synchronizer = { | 318 modules.synchronizer = { |
289 Synchronizer: { | 319 Synchronizer: { |
290 _downloading: false, | 320 _downloading: false, |
291 execute: function(subscription, manual) | 321 execute(subscription, manual) |
292 { | 322 { |
293 modules.synchronizer.Synchronizer._downloading = true; | 323 modules.synchronizer.Synchronizer._downloading = true; |
294 modules.filterNotifier.FilterNotifier.emit( | 324 modules.filterNotifier.FilterNotifier.emit( |
295 "subscription.downloading", subscription | 325 "subscription.downloading", subscription |
296 ); | 326 ); |
297 setTimeout(function() | 327 setTimeout(() => |
298 { | 328 { |
299 modules.synchronizer.Synchronizer._downloading = false; | 329 modules.synchronizer.Synchronizer._downloading = false; |
300 subscription.lastDownload = Date.now() / 1000; | 330 subscription.lastDownload = Date.now() / 1000; |
301 }, 500); | 331 }, 500); |
302 }, | 332 }, |
303 isExecuting: function(url) | 333 isExecuting(url) |
304 { | 334 { |
305 return modules.synchronizer.Synchronizer._downloading; | 335 return modules.synchronizer.Synchronizer._downloading; |
306 } | 336 } |
307 } | 337 } |
308 }; | 338 }; |
309 | 339 |
310 modules.matcher = { | 340 modules.matcher = { |
311 defaultMatcher: { | 341 defaultMatcher: { |
312 matchesAny: function(url, requestType, docDomain, thirdParty) | 342 matchesAny(url, requestType, docDomain, thirdParty) |
313 { | 343 { |
314 var blocked = params.blockedURLs.split(","); | 344 let blocked = params.blockedURLs.split(","); |
315 if (blocked.indexOf(url) >= 0) | 345 if (blocked.indexOf(url) >= 0) |
316 return new modules.filterClasses.BlockingFilter(); | 346 return new modules.filterClasses.BlockingFilter(); |
317 else | 347 return null; |
318 return null; | 348 } |
319 } | 349 } |
320 } | 350 }; |
321 }; | 351 |
322 | 352 modules.elemHideEmulation = { |
323 modules.cssRules = { | 353 ElemHideEmulation: {} |
324 CSSRules: { | |
325 getRulesForDomain: function(domain) { } | |
326 } | |
327 }; | 354 }; |
328 | 355 |
329 modules.filterNotifier = { | 356 modules.filterNotifier = { |
330 FilterNotifier: new EventEmitter() | 357 FilterNotifier: new EventEmitter() |
331 }; | 358 }; |
332 | 359 |
333 modules.info = { | 360 modules.info = { |
334 platform: "gecko", | 361 platform: "gecko", |
335 platformVersion: "34.0", | 362 platformVersion: "34.0", |
336 application: "firefox", | 363 application: "firefox", |
337 applicationVersion: "34.0", | 364 applicationVersion: "34.0", |
338 addonName: "adblockplus", | 365 addonName: "adblockplus", |
339 addonVersion: "2.6.7" | 366 addonVersion: "2.6.7" |
340 }; | 367 }; |
341 updateFromURL(modules.info); | 368 updateFromURL(modules.info); |
342 | 369 |
343 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 = { |
344 vc: { | 423 vc: { |
345 compare: function(v1, v2) | 424 compare(v1, v2) |
346 { | 425 { |
347 return parseFloat(v1) - parseFloat(v2); | 426 return parseFloat(v1) - parseFloat(v2); |
348 } | 427 } |
349 } | 428 } |
350 }; | 429 }; |
351 | 430 |
352 var filters = [ | 431 let filters = [ |
353 "@@||alternate.de^$document", | 432 "@@||alternate.de^$document", |
354 "@@||der.postillion.com^$document", | 433 "@@||der.postillion.com^$document", |
355 "@@||taz.de^$document", | 434 "@@||taz.de^$document", |
356 "@@||amazon.de^$document", | 435 "@@||amazon.de^$document", |
357 "||biglemon.am/bg_poster/banner.jpg", | 436 "||biglemon.am/bg_poster/banner.jpg", |
358 "winfuture.de###header_logo_link", | 437 "winfuture.de###header_logo_link", |
359 "###WerbungObenRechts10_GesamtDIV", | 438 "###WerbungObenRechts10_GesamtDIV", |
360 "###WerbungObenRechts8_GesamtDIV", | 439 "###WerbungObenRechts8_GesamtDIV", |
361 "###WerbungObenRechts9_GesamtDIV", | 440 "###WerbungObenRechts9_GesamtDIV", |
362 "###WerbungUntenLinks4_GesamtDIV", | 441 "###WerbungUntenLinks4_GesamtDIV", |
363 "###WerbungUntenLinks7_GesamtDIV", | 442 "###WerbungUntenLinks7_GesamtDIV", |
364 "###WerbungUntenLinks8_GesamtDIV", | 443 "###WerbungUntenLinks8_GesamtDIV", |
365 "###WerbungUntenLinks9_GesamtDIV", | 444 "###WerbungUntenLinks9_GesamtDIV", |
366 "###Werbung_Sky", | 445 "###Werbung_Sky", |
367 "###Werbung_Wide", | 446 "###Werbung_Wide", |
368 "###__ligatus_placeholder__", | 447 "###__ligatus_placeholder__", |
369 "###ad-bereich1-08", | 448 "###ad-bereich1-08", |
370 "###ad-bereich1-superbanner", | 449 "###ad-bereich1-superbanner", |
371 "###ad-bereich2-08", | 450 "###ad-bereich2-08", |
372 "###ad-bereich2-skyscrapper" | 451 "###ad-bereich2-skyscrapper" |
373 ]; | 452 ]; |
374 var knownFilters = filters.map(modules.filterClasses.Filter.fromText); | 453 let knownFilters = filters.map(modules.filterClasses.Filter.fromText); |
375 | 454 |
376 var subscriptions = [ | 455 let subscriptions = { |
377 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt", | 456 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt": { |
378 "https://easylist-downloads.adblockplus.org/exceptionrules.txt", | 457 title: "EasyList Germany+EasyList" |
379 "https://easylist-downloads.adblockplus.org/fanboy-social.txt", | 458 }, |
380 "~user~786254" | 459 "https://easylist-downloads.adblockplus.org/exceptionrules.txt": { |
381 ]; | 460 title: "Allow non-intrusive advertising" |
382 var knownSubscriptions = Object.create(null); | 461 }, |
383 for (var subscriptionUrl of subscriptions) | 462 "https://easylist-downloads.adblockplus.org/fanboy-social.txt": { |
384 knownSubscriptions[subscriptionUrl] = modules.subscriptionClasses.Subscripti
on.fromURL(subscriptionUrl); | 463 title: "Fanboy's Social Blocking List", |
385 var customSubscription = knownSubscriptions["~user~786254"]; | 464 type: "social" |
386 | 465 }, |
387 global.seenDataCorruption = params.seenDataCorruption; | 466 "https://easylist-downloads.adblockplus.org/antiadblockfilters.txt": { |
388 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"]; |
389 | 481 |
390 if (params.addSubscription) | 482 if (params.addSubscription) |
391 { | 483 { |
392 // 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 |
393 // so we'll post the message after one second | 485 // so we'll post the message after one second |
394 setTimeout(function() | 486 setTimeout(() => |
395 { | 487 { |
396 window.postMessage({ | 488 window.postMessage({ |
397 type: "message", | 489 type: "message", |
398 payload: { | 490 payload: { |
399 title: "Custom subscription", | 491 title: "Custom subscription", |
400 url: "http://example.com/custom.txt", | 492 url: "http://example.com/custom.txt", |
401 confirm: true, | 493 confirm: true, |
402 type: "subscriptions.add" | 494 type: "subscriptions.add" |
403 } | 495 } |
404 }, "*"); | 496 }, "*"); |
405 }, 1000); | 497 }, 1000); |
406 } | 498 } |
407 | 499 |
408 ext.devtools.onCreated.addListener(function(panel) | 500 ext.devtools.onCreated.addListener((panel) => |
409 { | 501 { |
410 // blocked request | 502 // blocked request |
411 panel.sendMessage({ | 503 panel.sendMessage({ |
412 type: "add-record", | 504 type: "add-record", |
413 request: { | 505 request: { |
414 url: "http://adserver.example.com/ad_banner.png", | 506 url: "http://adserver.example.com/ad_banner.png", |
415 type: "IMAGE", | 507 type: "IMAGE", |
416 docDomain: "example.com" | 508 docDomain: "example.com" |
417 }, | 509 }, |
418 filter: { | 510 filter: { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 docDomain: "example.com" | 566 docDomain: "example.com" |
475 }, | 567 }, |
476 filter: { | 568 filter: { |
477 text: "||example.com/some-annoying-popup$popup", | 569 text: "||example.com/some-annoying-popup$popup", |
478 whitelisted: false, | 570 whitelisted: false, |
479 userDefined: true, | 571 userDefined: true, |
480 subscription: null | 572 subscription: null |
481 } | 573 } |
482 }); | 574 }); |
483 }); | 575 }); |
484 | 576 }()); |
485 if (params.safariContentBlocker) | |
486 { | |
487 global.safari = { | |
488 extension: { | |
489 setContentBlocker: function() {} | |
490 } | |
491 }; | |
492 } | |
493 })(this); | |
LEFT | RIGHT |