Left: | ||
Right: |
OLD | NEW |
---|---|
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-2016 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 | |
19 { | 20 { |
20 function EventEmitter() | 21 function EventEmitter() |
21 { | 22 { |
22 this._listeners = Object.create(null); | 23 this._listeners = Object.create(null); |
23 } | 24 } |
24 EventEmitter.prototype = { | 25 EventEmitter.prototype = { |
25 on: function(name, listener) | 26 on(name, listener) |
26 { | 27 { |
27 if (name in this._listeners) | 28 if (name in this._listeners) |
28 this._listeners[name].push(listener); | 29 this._listeners[name].push(listener); |
29 else | 30 else |
30 this._listeners[name] = [listener]; | 31 this._listeners[name] = [listener]; |
31 }, | 32 }, |
32 off: function(name, listener) | 33 off(name, listener) |
33 { | 34 { |
34 var listeners = this._listeners[name]; | 35 let listeners = this._listeners[name]; |
35 if (listeners) | 36 if (listeners) |
36 { | 37 { |
37 var idx = listeners.indexOf(listener); | 38 let idx = listeners.indexOf(listener); |
38 if (idx != -1) | 39 if (idx != -1) |
39 listeners.splice(idx, 1); | 40 listeners.splice(idx, 1); |
40 } | 41 } |
41 }, | 42 }, |
42 emit: function(name) | 43 emit(name, ...args) |
43 { | 44 { |
44 var listeners = this._listeners[name]; | 45 let listeners = this._listeners[name]; |
45 if (listeners) | 46 if (listeners) |
46 { | 47 { |
47 for (var i = 0; i < listeners.length; i++) | 48 for (let listener of listeners) |
48 listeners[i].apply(null, Array.prototype.slice.call(arguments, 1)); | 49 listener(...args); |
49 } | 50 } |
50 } | 51 } |
51 }; | 52 }; |
52 | 53 |
53 function updateFromURL(data) | 54 function updateFromURL(data) |
54 { | 55 { |
55 if (window.location.search) | 56 if (window.location.search) |
56 { | 57 { |
57 var params = window.location.search.substr(1).split("&"); | 58 for (let param of window.location.search.substr(1).split("&")) |
Thomas Greiner
2017/03/01 17:39:32
Detail: Putting that long statement within the for
kzar
2017/03/07 12:48:31
Done.
| |
58 for (var i = 0; i < params.length; i++) | |
59 { | 59 { |
60 var parts = params[i].split("=", 2); | 60 let parts = param.split("=", 2); |
61 if (parts.length == 2 && parts[0] in data) | 61 if (parts.length == 2 && parts[0] in data) |
62 data[parts[0]] = decodeURIComponent(parts[1]); | 62 data[parts[0]] = decodeURIComponent(parts[1]); |
63 } | 63 } |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 var params = { | 67 let params = { |
68 blockedURLs: "", | 68 blockedURLs: "", |
69 filterlistsReinitialized: false, | 69 filterlistsReinitialized: false, |
70 addSubscription: false, | 70 addSubscription: false, |
71 filterError: false, | 71 filterError: false, |
72 downloadStatus: "synchronize_ok", | 72 downloadStatus: "synchronize_ok", |
73 showNotificationUI: false | 73 showNotificationUI: false |
74 }; | 74 }; |
75 updateFromURL(params); | 75 updateFromURL(params); |
76 | 76 |
77 var modules = {}; | 77 let modules = {}; |
78 global.require = function(module) | 78 window.require = function(module) |
79 { | 79 { |
80 return modules[module]; | 80 return modules[module]; |
81 }; | 81 }; |
82 | 82 |
83 modules.utils = { | 83 modules.utils = { |
84 Utils: { | 84 Utils: { |
85 getDocLink: function(link) | 85 getDocLink(link) |
86 { | 86 { |
87 return "https://adblockplus.org/redirect?link=" + encodeURIComponent(lin k); | 87 return "https://adblockplus.org/redirect?link=" + encodeURIComponent(lin k); |
88 }, | 88 }, |
89 get appLocale() | 89 get appLocale() |
90 { | 90 { |
91 return parent.ext.i18n.getMessage("@@ui_locale").replace(/_/g, "-"); | 91 return parent.ext.i18n.getMessage("@@ui_locale").replace(/_/g, "-"); |
92 } | 92 } |
93 } | 93 } |
94 }; | 94 }; |
95 | 95 |
96 modules.prefs = {Prefs: new EventEmitter()}; | 96 modules.prefs = {Prefs: new EventEmitter()}; |
97 var prefs = { | 97 let prefs = { |
98 notifications_ignoredcategories: (params.showNotificationUI) ? ["*"] : [], | 98 notifications_ignoredcategories: (params.showNotificationUI) ? ["*"] : [], |
99 notifications_showui: params.showNotificationUI, | 99 notifications_showui: params.showNotificationUI, |
100 shouldShowBlockElementMenu: true, | 100 shouldShowBlockElementMenu: true, |
101 show_devtools_panel: true, | 101 show_devtools_panel: true, |
102 subscriptions_exceptionsurl: "https://easylist-downloads.adblockplus.org/exc eptionrules.txt" | 102 subscriptions_exceptionsurl: "https://easylist-downloads.adblockplus.org/exc eptionrules.txt" |
103 }; | 103 }; |
104 Object.keys(prefs).forEach(function(key) | 104 for (let key of Object.keys(prefs)) |
105 { | 105 { |
106 Object.defineProperty(modules.prefs.Prefs, key, { | 106 Object.defineProperty(modules.prefs.Prefs, key, { |
107 get: function() | 107 get() |
108 { | 108 { |
109 return prefs[key]; | 109 return prefs[key]; |
110 }, | 110 }, |
111 set: function(value) | 111 set(value) |
112 { | 112 { |
113 prefs[key] = value; | 113 prefs[key] = value; |
114 modules.prefs.Prefs.emit(key); | 114 modules.prefs.Prefs.emit(key); |
115 } | 115 } |
116 }); | 116 }); |
117 }); | 117 } |
118 | 118 |
119 modules.notification = { | 119 modules.notification = { |
120 Notification: { | 120 Notification: { |
121 toggleIgnoreCategory: function(category) | 121 toggleIgnoreCategory(category) |
122 { | 122 { |
123 var categories = prefs.notifications_ignoredcategories; | 123 let categories = prefs.notifications_ignoredcategories; |
124 var index = categories.indexOf(category); | 124 let index = categories.indexOf(category); |
125 if (index == -1) | 125 if (index == -1) |
126 categories.push(category); | 126 categories.push(category); |
127 else | 127 else |
128 categories.splice(index, 1); | 128 categories.splice(index, 1); |
129 modules.prefs.Prefs.notifications_ignoredcategories = categories; | 129 modules.prefs.Prefs.notifications_ignoredcategories = categories; |
130 } | 130 } |
131 } | 131 } |
132 }; | 132 }; |
133 | 133 |
134 modules.subscriptionClasses = { | 134 function Subscription(url) |
135 Subscription: function(url) | |
136 { | |
137 this.url = url; | |
138 this._disabled = false; | |
139 this._lastDownload = 1234; | |
140 this.homepage = "https://easylist.adblockplus.org/"; | |
141 this.downloadStatus = params.downloadStatus; | |
142 }, | |
143 | |
144 SpecialSubscription: function(url) | |
145 { | |
146 this.url = url; | |
147 this.disabled = false; | |
148 this.filters = knownFilters.slice(); | |
149 } | |
150 }; | |
151 modules.subscriptionClasses.Subscription.fromURL = function(url) | |
152 { | 135 { |
153 if (url in knownSubscriptions) | 136 this.url = url; |
154 return knownSubscriptions[url]; | 137 this._disabled = false; |
155 | 138 this._lastDownload = 1234; |
156 if (/^https?:\/\//.test(url)) | 139 this.homepage = "https://easylist.adblockplus.org/"; |
157 return new modules.subscriptionClasses.Subscription(url); | 140 this.downloadStatus = params.downloadStatus; |
158 else | 141 } |
159 return new modules.subscriptionClasses.SpecialSubscription(url); | 142 Subscription.prototype = |
160 }; | |
161 modules.subscriptionClasses.DownloadableSubscription = modules.subscriptionCla sses.Subscription; | |
162 | |
163 modules.subscriptionClasses.Subscription.prototype = | |
164 { | 143 { |
165 get disabled() | 144 get disabled() |
166 { | 145 { |
167 return this._disabled; | 146 return this._disabled; |
168 }, | 147 }, |
169 set disabled(value) | 148 set disabled(value) |
170 { | 149 { |
171 this._disabled = value; | 150 this._disabled = value; |
172 modules.filterNotifier.FilterNotifier.emit("subscription.disabled", this); | 151 modules.filterNotifier.FilterNotifier.emit("subscription.disabled", this); |
173 }, | 152 }, |
174 get lastDownload() | 153 get lastDownload() |
175 { | 154 { |
176 return this._lastDownload; | 155 return this._lastDownload; |
177 }, | 156 }, |
178 set lastDownload(value) | 157 set lastDownload(value) |
179 { | 158 { |
180 this._lastDownload = value; | 159 this._lastDownload = value; |
181 modules.filterNotifier.FilterNotifier.emit("subscription.lastDownload", th is); | 160 modules.filterNotifier.FilterNotifier.emit("subscription.lastDownload", |
161 this); | |
182 } | 162 } |
183 }; | 163 }; |
164 Subscription.fromURL = function(url) | |
165 { | |
166 if (url in knownSubscriptions) | |
167 return knownSubscriptions[url]; | |
184 | 168 |
169 if (/^https?:\/\//.test(url)) | |
170 return new modules.subscriptionClasses.Subscription(url); | |
171 return new modules.subscriptionClasses.SpecialSubscription(url); | |
172 }; | |
173 | |
174 function SpecialSubscription(url) | |
175 { | |
176 this.url = url; | |
177 this.disabled = false; | |
178 this.filters = knownFilters.slice(); | |
179 } | |
180 | |
181 modules.subscriptionClasses = { | |
182 Subscription, | |
183 SpecialSubscription, | |
184 DownloadableSubscription: Subscription | |
185 }; | |
185 | 186 |
186 modules.filterStorage = { | 187 modules.filterStorage = { |
187 FilterStorage: { | 188 FilterStorage: { |
188 get subscriptions() | 189 get subscriptions() |
189 { | 190 { |
190 var subscriptions = []; | 191 let subscriptions = []; |
191 for (var url in modules.filterStorage.FilterStorage.knownSubscriptions) | 192 for (let url in modules.filterStorage.FilterStorage.knownSubscriptions) |
192 subscriptions.push(modules.filterStorage.FilterStorage.knownSubscripti ons[url]); | 193 { |
194 subscriptions.push( | |
195 modules.filterStorage.FilterStorage.knownSubscriptions[url] | |
196 ); | |
197 } | |
193 return subscriptions; | 198 return subscriptions; |
194 }, | 199 }, |
195 | 200 |
196 get knownSubscriptions() | 201 get knownSubscriptions() |
197 { | 202 { |
198 return knownSubscriptions; | 203 return knownSubscriptions; |
199 }, | 204 }, |
200 | 205 |
201 addSubscription: function(subscription) | 206 addSubscription(subscription) |
202 { | 207 { |
203 if (!(subscription.url in modules.filterStorage.FilterStorage.knownSubsc riptions)) | 208 let {fromURL} = modules.subscriptionClasses.Subscription; |
Thomas Greiner
2017/03/01 17:39:34
Detail: You can now refer to `Subscription` direct
kzar
2017/03/07 12:48:31
Done.
| |
209 let {FilterStorage} = modules.filterStorage; | |
210 | |
211 if (!(subscription.url in FilterStorage.knownSubscriptions)) | |
204 { | 212 { |
205 knownSubscriptions[subscription.url] = modules.subscriptionClasses.Sub scription.fromURL(subscription.url); | 213 knownSubscriptions[subscription.url] = fromURL(subscription.url); |
206 modules.filterNotifier.FilterNotifier.emit("subscription.added", subsc ription); | 214 modules.filterNotifier.FilterNotifier.emit("subscription.added", |
215 subscription); | |
207 } | 216 } |
208 }, | 217 }, |
209 | 218 |
210 removeSubscription: function(subscription) | 219 removeSubscription(subscription) |
211 { | 220 { |
212 if (subscription.url in modules.filterStorage.FilterStorage.knownSubscri ptions) | 221 let {FilterStorage} = modules.filterStorage; |
222 | |
223 if (subscription.url in FilterStorage.knownSubscriptions) | |
213 { | 224 { |
214 delete knownSubscriptions[subscription.url]; | 225 delete knownSubscriptions[subscription.url]; |
215 modules.filterNotifier.FilterNotifier.emit("subscription.removed", sub scription); | 226 modules.filterNotifier.FilterNotifier.emit("subscription.removed", |
227 subscription); | |
216 } | 228 } |
217 }, | 229 }, |
218 | 230 |
219 addFilter: function(filter) | 231 addFilter(filter) |
220 { | 232 { |
221 for (var i = 0; i < customSubscription.filters.length; i++) | 233 for (let customFilter of customSubscription.filters) |
222 { | 234 { |
223 if (customSubscription.filters[i].text == filter.text) | 235 if (customFilter.text == filter.text) |
224 return; | 236 return; |
225 } | 237 } |
226 customSubscription.filters.push(filter); | 238 customSubscription.filters.push(filter); |
227 modules.filterNotifier.FilterNotifier.emit("filter.added", filter); | 239 modules.filterNotifier.FilterNotifier.emit("filter.added", filter); |
228 }, | 240 }, |
229 | 241 |
230 removeFilter: function(filter) | 242 removeFilter(filter) |
231 { | 243 { |
232 for (var i = 0; i < customSubscription.filters.length; i++) | 244 for (let i = 0; i < customSubscription.filters.length; i++) |
233 { | 245 { |
234 if (customSubscription.filters[i].text == filter.text) | 246 if (customSubscription.filters[i].text == filter.text) |
235 { | 247 { |
236 customSubscription.filters.splice(i, 1); | 248 customSubscription.filters.splice(i, 1); |
237 modules.filterNotifier.FilterNotifier.emit("filter.removed", filter) ; | 249 modules.filterNotifier.FilterNotifier.emit("filter.removed", |
250 filter); | |
238 return; | 251 return; |
239 } | 252 } |
240 } | 253 } |
241 } | 254 } |
242 } | 255 } |
243 }; | 256 }; |
244 | 257 |
245 modules.filterClasses = { | 258 function Filter(text) |
246 BlockingFilter: function() {}, | 259 { |
247 Filter: function(text) | 260 this.text = text; |
248 { | 261 this.disabled = false; |
249 this.text = text; | 262 } |
250 this.disabled = false; | 263 Filter.fromText = text => |
Thomas Greiner
2017/03/01 17:39:34
Detail: Mind writing this as follows?
Filter.from
kzar
2017/03/07 12:48:30
Done.
| |
251 }, | |
252 RegExpFilter: function() {} | |
253 }; | |
254 modules.filterClasses.Filter.fromText = function(text) | |
255 { | 264 { |
256 return new modules.filterClasses.Filter(text); | 265 return new modules.filterClasses.Filter(text); |
257 }; | 266 }; |
258 modules.filterClasses.RegExpFilter.typeMap = Object.create(null); | |
259 | 267 |
260 modules.filterValidation = | 268 function BlockingFilter() |
261 { | 269 { |
262 parseFilter: function(text) | 270 } |
271 | |
272 function RegExpFilter() | |
273 { | |
274 } | |
275 RegExpFilter.typeMap = Object.create(null); | |
276 | |
277 modules.filterClasses = { | |
278 BlockingFilter, | |
279 Filter, | |
280 RegExpFilter | |
281 }; | |
282 | |
283 modules.filterValidation = | |
284 { | |
285 parseFilter(text) | |
263 { | 286 { |
264 if (params.filterError) | 287 if (params.filterError) |
265 return {error: "Invalid filter"}; | 288 return {error: "Invalid filter"}; |
266 return {filter: modules.filterClasses.Filter.fromText(text)}; | 289 return {filter: modules.filterClasses.Filter.fromText(text)}; |
267 }, | 290 }, |
268 parseFilters: function(text) | 291 parseFilters(text) |
269 { | 292 { |
270 if (params.filterError) | 293 if (params.filterError) |
271 return {errors: ["Invalid filter"]}; | 294 return {errors: ["Invalid filter"]}; |
272 return { | 295 return { |
273 filters: text.split("\n") | 296 filters: text.split("\n") |
274 .filter(function(filter) {return !!filter;}) | 297 .filter(filter => !!filter) |
275 .map(modules.filterClasses.Filter.fromText), | 298 .map(modules.filterClasses.Filter.fromText), |
276 errors: [] | 299 errors: [] |
277 }; | 300 }; |
278 } | 301 } |
279 }; | 302 }; |
280 | 303 |
281 modules.synchronizer = { | 304 modules.synchronizer = { |
282 Synchronizer: { | 305 Synchronizer: { |
283 _downloading: false, | 306 _downloading: false, |
284 execute: function(subscription, manual) | 307 execute(subscription, manual) |
285 { | 308 { |
286 modules.synchronizer.Synchronizer._downloading = true; | 309 modules.synchronizer.Synchronizer._downloading = true; |
287 modules.filterNotifier.FilterNotifier.emit( | 310 modules.filterNotifier.FilterNotifier.emit( |
288 "subscription.downloading", subscription | 311 "subscription.downloading", subscription |
289 ); | 312 ); |
290 setTimeout(function() | 313 setTimeout(() => |
291 { | 314 { |
292 modules.synchronizer.Synchronizer._downloading = false; | 315 modules.synchronizer.Synchronizer._downloading = false; |
293 subscription.lastDownload = Date.now() / 1000; | 316 subscription.lastDownload = Date.now() / 1000; |
294 }, 500); | 317 }, 500); |
295 }, | 318 }, |
296 isExecuting: function(url) | 319 isExecuting(url) |
297 { | 320 { |
298 return modules.synchronizer.Synchronizer._downloading; | 321 return modules.synchronizer.Synchronizer._downloading; |
299 } | 322 } |
300 } | 323 } |
301 }; | 324 }; |
302 | 325 |
303 modules.matcher = { | 326 modules.matcher = { |
304 defaultMatcher: { | 327 defaultMatcher: { |
305 matchesAny: function(url, requestType, docDomain, thirdParty) | 328 matchesAny(url, requestType, docDomain, thirdParty) |
306 { | 329 { |
307 var blocked = params.blockedURLs.split(","); | 330 let blocked = params.blockedURLs.split(","); |
308 if (blocked.indexOf(url) >= 0) | 331 if (blocked.indexOf(url) >= 0) |
309 return new modules.filterClasses.BlockingFilter(); | 332 return new modules.filterClasses.BlockingFilter(); |
310 else | 333 return null; |
311 return null; | |
312 } | 334 } |
313 } | 335 } |
314 }; | 336 }; |
315 | 337 |
316 modules.elemHideEmulation = { | 338 modules.elemHideEmulation = { |
317 ElemHideEmulation: {} | 339 ElemHideEmulation: {} |
318 }; | 340 }; |
319 | 341 |
320 modules.filterNotifier = { | 342 modules.filterNotifier = { |
321 FilterNotifier: new EventEmitter() | 343 FilterNotifier: new EventEmitter() |
(...skipping 15 matching lines...) Expand all Loading... | |
337 | 359 |
338 modules.messaging = { | 360 modules.messaging = { |
339 port: new EventEmitter() | 361 port: new EventEmitter() |
340 }; | 362 }; |
341 | 363 |
342 window.addEventListener("message", event => | 364 window.addEventListener("message", event => |
343 { | 365 { |
344 if (event.data.type != "message") | 366 if (event.data.type != "message") |
345 return; | 367 return; |
346 let message = event.data.payload; | 368 let message = event.data.payload; |
347 let messageId = event.data.messageId; | 369 let {messageId} = event.data; |
348 let sender = { | 370 let sender = { |
349 page: new ext.Page(event.source) | 371 page: new ext.Page(event.source) |
350 }; | 372 }; |
351 | 373 |
352 let listeners = modules.messaging.port._listeners[message.type]; | 374 let listeners = modules.messaging.port._listeners[message.type]; |
353 if (!listeners) | 375 if (!listeners) |
354 return; | 376 return; |
355 | 377 |
356 function reply(message) | 378 function reply(responseMessage) |
357 { | 379 { |
358 event.source.postMessage({ | 380 event.source.postMessage({ |
359 type: "response", | 381 type: "response", |
360 messageId: messageId, | 382 messageId, |
361 payload: message | 383 payload: responseMessage |
362 }, "*"); | 384 }, "*"); |
363 } | 385 } |
364 | 386 |
365 for (let listener of listeners) | 387 for (let listener of listeners) |
366 { | 388 { |
367 let response = listener(message, sender); | 389 let response = listener(message, sender); |
368 if (response && typeof response.then == "function") | 390 if (response && typeof response.then == "function") |
369 { | 391 { |
370 response.then( | 392 response.then( |
371 reply, | 393 reply, |
372 reason => { | 394 reason => |
395 { | |
373 console.error(reason); | 396 console.error(reason); |
374 reply(undefined); | 397 reply(undefined); |
375 } | 398 } |
376 ); | 399 ); |
377 } | 400 } |
378 else if (typeof response != "undefined") | 401 else if (typeof response != "undefined") |
379 { | |
380 reply(response); | 402 reply(response); |
381 } | |
382 } | 403 } |
383 }); | 404 }); |
384 | 405 |
385 global.Services = { | 406 window.Services = { |
386 vc: { | 407 vc: { |
387 compare: function(v1, v2) | 408 compare(v1, v2) |
388 { | 409 { |
389 return parseFloat(v1) - parseFloat(v2); | 410 return parseFloat(v1) - parseFloat(v2); |
390 } | 411 } |
391 } | 412 } |
392 }; | 413 }; |
393 | 414 |
394 var filters = [ | 415 let filters = [ |
395 "@@||alternate.de^$document", | 416 "@@||alternate.de^$document", |
396 "@@||der.postillion.com^$document", | 417 "@@||der.postillion.com^$document", |
397 "@@||taz.de^$document", | 418 "@@||taz.de^$document", |
398 "@@||amazon.de^$document", | 419 "@@||amazon.de^$document", |
399 "||biglemon.am/bg_poster/banner.jpg", | 420 "||biglemon.am/bg_poster/banner.jpg", |
400 "winfuture.de###header_logo_link", | 421 "winfuture.de###header_logo_link", |
401 "###WerbungObenRechts10_GesamtDIV", | 422 "###WerbungObenRechts10_GesamtDIV", |
402 "###WerbungObenRechts8_GesamtDIV", | 423 "###WerbungObenRechts8_GesamtDIV", |
403 "###WerbungObenRechts9_GesamtDIV", | 424 "###WerbungObenRechts9_GesamtDIV", |
404 "###WerbungUntenLinks4_GesamtDIV", | 425 "###WerbungUntenLinks4_GesamtDIV", |
405 "###WerbungUntenLinks7_GesamtDIV", | 426 "###WerbungUntenLinks7_GesamtDIV", |
406 "###WerbungUntenLinks8_GesamtDIV", | 427 "###WerbungUntenLinks8_GesamtDIV", |
407 "###WerbungUntenLinks9_GesamtDIV", | 428 "###WerbungUntenLinks9_GesamtDIV", |
408 "###Werbung_Sky", | 429 "###Werbung_Sky", |
409 "###Werbung_Wide", | 430 "###Werbung_Wide", |
410 "###__ligatus_placeholder__", | 431 "###__ligatus_placeholder__", |
411 "###ad-bereich1-08", | 432 "###ad-bereich1-08", |
412 "###ad-bereich1-superbanner", | 433 "###ad-bereich1-superbanner", |
413 "###ad-bereich2-08", | 434 "###ad-bereich2-08", |
414 "###ad-bereich2-skyscrapper" | 435 "###ad-bereich2-skyscrapper" |
415 ]; | 436 ]; |
416 var knownFilters = filters.map(modules.filterClasses.Filter.fromText); | 437 let knownFilters = filters.map(modules.filterClasses.Filter.fromText); |
417 | 438 |
418 var subscriptions = [ | 439 let subscriptions = [ |
419 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt", | 440 "https://easylist-downloads.adblockplus.org/easylistgermany+easylist.txt", |
420 "https://easylist-downloads.adblockplus.org/exceptionrules.txt", | 441 "https://easylist-downloads.adblockplus.org/exceptionrules.txt", |
421 "https://easylist-downloads.adblockplus.org/fanboy-social.txt", | 442 "https://easylist-downloads.adblockplus.org/fanboy-social.txt", |
422 "~user~786254" | 443 "~user~786254" |
423 ]; | 444 ]; |
424 var knownSubscriptions = Object.create(null); | 445 let knownSubscriptions = Object.create(null); |
425 for (var subscriptionUrl of subscriptions) | 446 for (let subscriptionUrl of subscriptions) |
426 knownSubscriptions[subscriptionUrl] = modules.subscriptionClasses.Subscripti on.fromURL(subscriptionUrl); | 447 { |
427 var customSubscription = knownSubscriptions["~user~786254"]; | 448 knownSubscriptions[subscriptionUrl] = |
449 modules.subscriptionClasses.Subscription.fromURL(subscriptionUrl); | |
450 } | |
451 let customSubscription = knownSubscriptions["~user~786254"]; | |
428 | 452 |
429 if (params.addSubscription) | 453 if (params.addSubscription) |
430 { | 454 { |
431 // We don't know how long it will take for the page to fully load | 455 // We don't know how long it will take for the page to fully load |
432 // so we'll post the message after one second | 456 // so we'll post the message after one second |
433 setTimeout(function() | 457 setTimeout(() => |
434 { | 458 { |
435 window.postMessage({ | 459 window.postMessage({ |
436 type: "message", | 460 type: "message", |
437 payload: { | 461 payload: { |
438 title: "Custom subscription", | 462 title: "Custom subscription", |
439 url: "http://example.com/custom.txt", | 463 url: "http://example.com/custom.txt", |
440 confirm: true, | 464 confirm: true, |
441 type: "subscriptions.add" | 465 type: "subscriptions.add" |
442 } | 466 } |
443 }, "*"); | 467 }, "*"); |
444 }, 1000); | 468 }, 1000); |
445 } | 469 } |
446 | 470 |
447 ext.devtools.onCreated.addListener(function(panel) | 471 ext.devtools.onCreated.addListener(panel => |
448 { | 472 { |
449 // blocked request | 473 // blocked request |
450 panel.sendMessage({ | 474 panel.sendMessage({ |
451 type: "add-record", | 475 type: "add-record", |
452 request: { | 476 request: { |
453 url: "http://adserver.example.com/ad_banner.png", | 477 url: "http://adserver.example.com/ad_banner.png", |
454 type: "IMAGE", | 478 type: "IMAGE", |
455 docDomain: "example.com" | 479 docDomain: "example.com" |
456 }, | 480 }, |
457 filter: { | 481 filter: { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
513 docDomain: "example.com" | 537 docDomain: "example.com" |
514 }, | 538 }, |
515 filter: { | 539 filter: { |
516 text: "||example.com/some-annoying-popup$popup", | 540 text: "||example.com/some-annoying-popup$popup", |
517 whitelisted: false, | 541 whitelisted: false, |
518 userDefined: true, | 542 userDefined: true, |
519 subscription: null | 543 subscription: null |
520 } | 544 } |
521 }); | 545 }); |
522 }); | 546 }); |
523 })(this); | 547 } |
OLD | NEW |