| 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-present 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 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 EventEmitter.prototype = { | 26 EventEmitter.prototype = { |
| 27 on(name, listener) | 27 on(name, listener) |
| 28 { | 28 { |
| 29 if (name in this._listeners) | 29 if (name in this._listeners) |
| 30 this._listeners[name].push(listener); | 30 this._listeners[name].push(listener); |
| 31 else | 31 else |
| 32 this._listeners[name] = [listener]; | 32 this._listeners[name] = [listener]; |
| 33 }, | 33 }, |
| 34 off(name, listener) | 34 off(name, listener) |
| 35 { | 35 { |
| 36 let listeners = this._listeners[name]; | 36 const listeners = this._listeners[name]; |
| 37 if (listeners) | 37 if (listeners) |
| 38 { | 38 { |
| 39 let idx = listeners.indexOf(listener); | 39 const idx = listeners.indexOf(listener); |
| 40 if (idx != -1) | 40 if (idx != -1) |
| 41 listeners.splice(idx, 1); | 41 listeners.splice(idx, 1); |
| 42 } | 42 } |
| 43 }, | 43 }, |
| 44 emit(name, ...args) | 44 emit(name, ...args) |
| 45 { | 45 { |
| 46 let listeners = this._listeners[name]; | 46 const listeners = this._listeners[name]; |
| 47 if (listeners) | 47 if (listeners) |
| 48 { | 48 { |
| 49 for (let listener of listeners) | 49 for (const listener of listeners) |
| 50 listener(...args); | 50 listener(...args); |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 function updateFromURL(data) | 55 function updateFromURL(data) |
| 56 { | 56 { |
| 57 if (window.location.search) | 57 if (window.location.search) |
| 58 { | 58 { |
| 59 let params = window.location.search.substr(1).split("&"); | 59 const params = window.location.search.substr(1).split("&"); |
| 60 | 60 |
| 61 for (let param of params) | 61 for (const param of params) |
| 62 { | 62 { |
| 63 let parts = param.split("=", 2); | 63 const parts = param.split("=", 2); |
| 64 if (parts.length == 2 && parts[0] in data) | 64 if (parts.length == 2 && parts[0] in data) |
| 65 data[parts[0]] = decodeURIComponent(parts[1]); | 65 data[parts[0]] = decodeURIComponent(parts[1]); |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 } | 68 } |
| 69 | 69 |
| 70 let params = { | 70 const params = { |
| 71 additionalSubscriptions: "", | 71 additionalSubscriptions: "", |
| 72 blockedURLs: "", | 72 blockedURLs: "", |
| 73 dataCorrupted: false, | 73 dataCorrupted: false, |
| 74 filterlistsReinitialized: false, | 74 filterlistsReinitialized: false, |
| 75 addSubscription: false, | 75 addSubscription: false, |
| 76 filterError: false, | 76 filterError: false, |
| 77 downloadStatus: "synchronize_ok", | 77 downloadStatus: "synchronize_ok", |
| 78 showNotificationUI: false, | 78 showNotificationUI: false, |
| 79 showPageOptions: false | 79 showPageOptions: false |
| 80 }; | 80 }; |
| 81 updateFromURL(params); | 81 updateFromURL(params); |
| 82 | 82 |
| 83 const subscriptionServer = "https://easylist-downloads.adblockplus.org"; | 83 const subscriptionServer = "https://easylist-downloads.adblockplus.org"; |
| 84 const easyListGermany = `${subscriptionServer}/easylistgermany+easylist.txt`; | 84 const easyListGermany = `${subscriptionServer}/easylistgermany+easylist.txt`; |
| 85 const acceptableAds = `${subscriptionServer}/exceptionrules.txt`; | 85 const acceptableAds = `${subscriptionServer}/exceptionrules.txt`; |
| 86 const acceptableAdsPrivacyFriendly = | 86 const acceptableAdsPrivacyFriendly = |
| 87 `${subscriptionServer}/exceptionrules-privacy-friendly.txt`; | 87 `${subscriptionServer}/exceptionrules-privacy-friendly.txt`; |
| 88 const redirectLink = "https://adblockplus.org/redirect?link="; | 88 const redirectLink = "https://adblockplus.org/redirect?link="; |
| 89 | 89 |
| 90 let modules = {}; | 90 const modules = {}; |
| 91 window.require = function(module) | 91 window.require = function(module) |
| 92 { | 92 { |
| 93 return modules[module.substr(module.lastIndexOf("/") + 1)]; | 93 return modules[module.split("/").pop()]; |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 modules.utils = { | 96 modules.utils = { |
| 97 Utils: { | 97 Utils: { |
| 98 getDocLink(link) | 98 getDocLink(link) |
| 99 { | 99 { |
| 100 return `${redirectLink}${encodeURIComponent(link)}`; | 100 return `${redirectLink}${encodeURIComponent(link)}`; |
| 101 }, | 101 }, |
| 102 get appLocale() | 102 get appLocale() |
| 103 { | 103 { |
| 104 return browser.i18n.getUILanguage(); | 104 return browser.i18n.getUILanguage(); |
| 105 }, | 105 }, |
| 106 get readingDirection() | 106 get readingDirection() |
| 107 { | 107 { |
| 108 return /^(?:ar|fa|he|ug|ur)\b/.test(this.appLocale) ? "rtl" : "ltr"; | 108 return /^(?:ar|fa|he|ug|ur)\b/.test(this.appLocale) ? "rtl" : "ltr"; |
| 109 } | 109 } |
| 110 } | 110 } |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 modules.prefs = {Prefs: new EventEmitter()}; | 113 modules.prefs = {Prefs: new EventEmitter()}; |
| 114 let prefs = { | 114 const prefs = { |
| 115 notifications_ignoredcategories: params.showNotificationUI ? ["*"] : [], | 115 notifications_ignoredcategories: params.showNotificationUI ? ["*"] : [], |
| 116 notifications_showui: params.showNotificationUI, | 116 notifications_showui: params.showNotificationUI, |
| 117 shouldShowBlockElementMenu: true, | 117 shouldShowBlockElementMenu: true, |
| 118 show_devtools_panel: true, | 118 show_devtools_panel: true, |
| 119 ui_warn_tracking: true, | 119 ui_warn_tracking: true, |
| 120 additional_subscriptions: params.additionalSubscriptions.split(","), | 120 additional_subscriptions: params.additionalSubscriptions.split(","), |
| 121 subscriptions_exceptionsurl: acceptableAds, | 121 subscriptions_exceptionsurl: acceptableAds, |
| 122 subscriptions_exceptionsurl_privacy: acceptableAdsPrivacyFriendly | 122 subscriptions_exceptionsurl_privacy: acceptableAdsPrivacyFriendly |
| 123 }; | 123 }; |
| 124 for (let key of Object.keys(prefs)) | 124 for (const key of Object.keys(prefs)) |
| 125 { | 125 { |
| 126 Object.defineProperty(modules.prefs.Prefs, key, { | 126 Object.defineProperty(modules.prefs.Prefs, key, { |
| 127 get() | 127 get() |
| 128 { | 128 { |
| 129 return prefs[key]; | 129 return prefs[key]; |
| 130 }, | 130 }, |
| 131 set(value) | 131 set(value) |
| 132 { | 132 { |
| 133 prefs[key] = value; | 133 prefs[key] = value; |
| 134 modules.prefs.Prefs.emit(key); | 134 modules.prefs.Prefs.emit(key); |
| 135 } | 135 } |
| 136 }); | 136 }); |
| 137 } | 137 } |
| 138 | 138 |
| 139 modules.notification = { | 139 modules.notification = { |
| 140 Notification: { | 140 Notification: { |
| 141 toggleIgnoreCategory(category) | 141 toggleIgnoreCategory(category) |
| 142 { | 142 { |
| 143 let categories = prefs.notifications_ignoredcategories; | 143 const categories = prefs.notifications_ignoredcategories; |
| 144 let index = categories.indexOf(category); | 144 const index = categories.indexOf(category); |
| 145 if (index == -1) | 145 if (index == -1) |
| 146 categories.push(category); | 146 categories.push(category); |
| 147 else | 147 else |
| 148 categories.splice(index, 1); | 148 categories.splice(index, 1); |
| 149 modules.prefs.Prefs.notifications_ignoredcategories = categories; | 149 modules.prefs.Prefs.notifications_ignoredcategories = categories; |
| 150 } | 150 } |
| 151 } | 151 } |
| 152 }; | 152 }; |
| 153 | 153 |
| 154 modules.notificationHelper = { | 154 modules.notificationHelper = { |
| 155 getActiveNotification() | 155 getActiveNotification() |
| 156 { | 156 { |
| 157 }, | 157 }, |
| 158 shouldDisplay() | 158 shouldDisplay() |
| 159 { | 159 { |
| 160 return true; | 160 return true; |
| 161 } | 161 } |
| 162 }; | 162 }; |
| 163 | 163 |
| 164 let subscriptionDetails = { | 164 const subscriptionDetails = { |
| 165 [easyListGermany]: { | 165 [easyListGermany]: { |
| 166 title: "EasyList Germany+EasyList", | 166 title: "EasyList Germany+EasyList", |
| 167 filters: ["-ad-banner.", "-ad-big.", "-ad-bottom-", "-ad-button-"], | 167 filters: ["-ad-banner.", "-ad-big.", "-ad-bottom-", "-ad-button-"], |
| 168 installed: true | 168 installed: true |
| 169 }, | 169 }, |
| 170 [acceptableAds]: { | 170 [acceptableAds]: { |
| 171 title: "Allow non-intrusive advertising", | 171 title: "Allow non-intrusive advertising", |
| 172 installed: true | 172 installed: true |
| 173 }, | 173 }, |
| 174 [acceptableAdsPrivacyFriendly]: { | 174 [acceptableAdsPrivacyFriendly]: { |
| 175 title: "Allow only nonintrusive ads that are privacy-friendly" | 175 title: "Allow only nonintrusive ads that are privacy-friendly" |
| 176 }, | 176 }, |
| 177 [`${subscriptionServer}/fanboy-social.txt`]: { | 177 [`${subscriptionServer}/fanboy-social.txt`]: { |
| 178 title: "Fanboy's Social Blocking List", | 178 title: "Fanboy's Social Blocking List", |
| 179 installed: true | 179 installed: true |
| 180 }, |
| 181 [`${subscriptionServer}/abp-filters-anti-cv.txt`]: { |
| 182 title: "ABP Anti-Circumvention list", |
| 183 installed: true, |
| 184 disabled: false, |
| 185 recommended: "circumvention" |
| 180 }, | 186 }, |
| 181 [`${subscriptionServer}/antiadblockfilters.txt`]: { | 187 [`${subscriptionServer}/antiadblockfilters.txt`]: { |
| 182 title: "Adblock Warning Removal List", | 188 title: "Adblock Warning Removal List", |
| 183 installed: true, | 189 installed: true, |
| 184 disabled: true | 190 disabled: true |
| 185 }, | 191 }, |
| 186 "~user~786254": { | 192 "~user~786254": { |
| 187 installed: true | 193 installed: true |
| 188 } | 194 } |
| 189 }; | 195 }; |
| 190 | 196 |
| 191 function Subscription(url) | 197 function Subscription(url) |
| 192 { | 198 { |
| 193 this.url = url; | 199 this.url = url; |
| 194 this._disabled = false; | 200 this._disabled = false; |
| 195 this._lastDownload = 1234; | 201 this._lastDownload = 1234; |
| 196 this.filters = []; | 202 this.filters = []; |
| 197 this.homepage = "https://easylist.adblockplus.org/"; | 203 this.homepage = "https://easylist.adblockplus.org/"; |
| 198 this.downloadStatus = params.downloadStatus; | 204 this.downloadStatus = params.downloadStatus; |
| 199 | 205 |
| 200 let details = subscriptionDetails[this.url]; | 206 const details = subscriptionDetails[this.url]; |
| 201 if (details) | 207 if (details) |
| 202 { | 208 { |
| 203 this.disabled = !!details.disabled; | 209 this.disabled = !!details.disabled; |
| 204 this.title = details.title || ""; | 210 this.title = details.title || ""; |
| 205 this.filters = this.filters.concat(details.filters); | 211 this.filters = this.filters.concat(details.filters); |
| 206 } | 212 } |
| 207 } | 213 } |
| 208 Subscription.prototype = | 214 Subscription.prototype = |
| 209 { | 215 { |
| 210 get disabled() | 216 get disabled() |
| (...skipping 11 matching lines...) Expand all Loading... |
| 222 }, | 228 }, |
| 223 set lastDownload(value) | 229 set lastDownload(value) |
| 224 { | 230 { |
| 225 this._lastDownload = value; | 231 this._lastDownload = value; |
| 226 modules.filterNotifier.FilterNotifier.emit("subscription.lastDownload", | 232 modules.filterNotifier.FilterNotifier.emit("subscription.lastDownload", |
| 227 this); | 233 this); |
| 228 } | 234 } |
| 229 }; | 235 }; |
| 230 Subscription.fromURL = function(url) | 236 Subscription.fromURL = function(url) |
| 231 { | 237 { |
| 232 if (url in knownSubscriptions) | 238 if (knownSubscriptions.has(url)) |
| 233 return knownSubscriptions[url]; | 239 return knownSubscriptions.get(url); |
| 234 | 240 |
| 235 if (/^https?:\/\//.test(url)) | 241 if (/^https?:\/\//.test(url)) |
| 236 return new modules.subscriptionClasses.Subscription(url); | 242 return new modules.subscriptionClasses.Subscription(url); |
| 237 return new modules.subscriptionClasses.SpecialSubscription(url); | 243 return new modules.subscriptionClasses.SpecialSubscription(url); |
| 238 }; | 244 }; |
| 239 | 245 |
| 240 function SpecialSubscription(url) | 246 function SpecialSubscription(url) |
| 241 { | 247 { |
| 242 this.url = url; | 248 this.url = url; |
| 243 this.disabled = false; | 249 this.disabled = false; |
| 244 this.filters = knownFilters.slice(); | 250 this.filters = knownFilters.slice(); |
| 245 } | 251 } |
| 246 | 252 |
| 247 modules.subscriptionClasses = { | 253 modules.subscriptionClasses = { |
| 248 Subscription, | 254 Subscription, |
| 249 SpecialSubscription, | 255 SpecialSubscription, |
| 250 DownloadableSubscription: Subscription | 256 DownloadableSubscription: Subscription |
| 251 }; | 257 }; |
| 252 | 258 |
| 253 modules.filterStorage = { | 259 modules.filterStorage = { |
| 254 FilterStorage: { | 260 FilterStorage: { |
| 255 get subscriptions() | 261 get subscriptions() |
| 256 { | 262 { |
| 257 let subscriptions = []; | 263 return Array.from(knownSubscriptions.values()); |
| 258 for (let url in modules.filterStorage.FilterStorage.knownSubscriptions) | 264 }, |
| 265 |
| 266 get knownSubscriptions() |
| 267 { |
| 268 return knownSubscriptions; |
| 269 }, |
| 270 |
| 271 addSubscription(subscription) |
| 272 { |
| 273 const {fromURL} = Subscription; |
| 274 |
| 275 if (!knownSubscriptions.has(subscription.url)) |
| 259 { | 276 { |
| 260 subscriptions.push( | 277 knownSubscriptions.set(subscription.url, fromURL(subscription.url)); |
| 261 modules.filterStorage.FilterStorage.knownSubscriptions[url] | |
| 262 ); | |
| 263 } | |
| 264 return subscriptions; | |
| 265 }, | |
| 266 | |
| 267 get knownSubscriptions() | |
| 268 { | |
| 269 return knownSubscriptions; | |
| 270 }, | |
| 271 | |
| 272 addSubscription(subscription) | |
| 273 { | |
| 274 let {fromURL} = Subscription; | |
| 275 let {FilterStorage} = modules.filterStorage; | |
| 276 | |
| 277 if (!(subscription.url in FilterStorage.knownSubscriptions)) | |
| 278 { | |
| 279 knownSubscriptions[subscription.url] = fromURL(subscription.url); | |
| 280 modules.filterNotifier.FilterNotifier.emit("subscription.added", | 278 modules.filterNotifier.FilterNotifier.emit("subscription.added", |
| 281 subscription); | 279 subscription); |
| 282 } | 280 } |
| 283 }, | 281 }, |
| 284 | 282 |
| 285 removeSubscription(subscription) | 283 removeSubscription(subscription) |
| 286 { | 284 { |
| 287 let {FilterStorage} = modules.filterStorage; | 285 if (knownSubscriptions.has(subscription.url)) |
| 288 | |
| 289 if (subscription.url in FilterStorage.knownSubscriptions) | |
| 290 { | 286 { |
| 291 delete knownSubscriptions[subscription.url]; | 287 knownSubscriptions.delete(subscription.url); |
| 292 modules.filterNotifier.FilterNotifier.emit("subscription.removed", | 288 modules.filterNotifier.FilterNotifier.emit("subscription.removed", |
| 293 subscription); | 289 subscription); |
| 294 } | 290 } |
| 295 }, | 291 }, |
| 296 | 292 |
| 297 addFilter(filter) | 293 addFilter(filter) |
| 298 { | 294 { |
| 299 for (let customFilter of customSubscription.filters) | 295 for (const customFilter of customSubscription.filters) |
| 300 { | 296 { |
| 301 if (customFilter.text == filter.text) | 297 if (customFilter.text == filter.text) |
| 302 return; | 298 return; |
| 303 } | 299 } |
| 304 customSubscription.filters.push(filter); | 300 customSubscription.filters.push(filter); |
| 305 modules.filterNotifier.FilterNotifier.emit("filter.added", filter); | 301 modules.filterNotifier.FilterNotifier.emit("filter.added", filter); |
| 306 }, | 302 }, |
| 307 | 303 |
| 308 removeFilter(filter) | 304 removeFilter(filter) |
| 309 { | 305 { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 { | 384 { |
| 389 return modules.synchronizer.Synchronizer._downloading; | 385 return modules.synchronizer.Synchronizer._downloading; |
| 390 } | 386 } |
| 391 } | 387 } |
| 392 }; | 388 }; |
| 393 | 389 |
| 394 modules.matcher = { | 390 modules.matcher = { |
| 395 defaultMatcher: { | 391 defaultMatcher: { |
| 396 matchesAny(url, requestType, docDomain, thirdParty) | 392 matchesAny(url, requestType, docDomain, thirdParty) |
| 397 { | 393 { |
| 398 let blocked = params.blockedURLs.split(","); | 394 const blocked = params.blockedURLs.split(","); |
| 399 if (blocked.indexOf(url) >= 0) | 395 if (blocked.indexOf(url) >= 0) |
| 400 return new modules.filterClasses.BlockingFilter(); | 396 return new modules.filterClasses.BlockingFilter(); |
| 401 return null; | 397 return null; |
| 402 } | 398 } |
| 403 } | 399 } |
| 404 }; | 400 }; |
| 405 | 401 |
| 406 modules.filterNotifier = { | 402 modules.filterNotifier = { |
| 407 FilterNotifier: new EventEmitter() | 403 FilterNotifier: new EventEmitter() |
| 408 }; | 404 }; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 434 | 430 |
| 435 if (callback) | 431 if (callback) |
| 436 callback(); | 432 callback(); |
| 437 } | 433 } |
| 438 }; | 434 }; |
| 439 | 435 |
| 440 window.addEventListener("message", (event) => | 436 window.addEventListener("message", (event) => |
| 441 { | 437 { |
| 442 if (event.data.type != "message") | 438 if (event.data.type != "message") |
| 443 return; | 439 return; |
| 444 let message = event.data.payload; | 440 const message = event.data.payload; |
| 445 let {messageId} = event.data; | 441 const {messageId} = event.data; |
| 446 let sender = { | 442 const sender = { |
| 447 page: new ext.Page(event.source) | 443 page: new ext.Page(event.source) |
| 448 }; | 444 }; |
| 449 | 445 |
| 450 let listeners = modules.messaging.port._listeners[message.type]; | 446 const listeners = modules.messaging.port._listeners[message.type]; |
| 451 if (!listeners) | 447 if (!listeners) |
| 452 return; | 448 return; |
| 453 | 449 |
| 454 function reply(responseMessage) | 450 function reply(responseMessage) |
| 455 { | 451 { |
| 456 event.source.postMessage({ | 452 event.source.postMessage({ |
| 457 type: "response", | 453 type: "response", |
| 458 messageId, | 454 messageId, |
| 459 payload: responseMessage | 455 payload: responseMessage |
| 460 }, "*"); | 456 }, "*"); |
| 461 } | 457 } |
| 462 | 458 |
| 463 for (let listener of listeners) | 459 for (const listener of listeners) |
| 464 { | 460 { |
| 465 let response = listener(message, sender); | 461 const response = listener(message, sender); |
| 466 if (response && typeof response.then == "function") | 462 if (response && typeof response.then == "function") |
| 467 { | 463 { |
| 468 response.then( | 464 response.then( |
| 469 reply, | 465 reply, |
| 470 (reason) => | 466 (reason) => |
| 471 { | 467 { |
| 472 console.error(reason); | 468 console.error(reason); |
| 473 reply(undefined); | 469 reply(undefined); |
| 474 } | 470 } |
| 475 ); | 471 ); |
| 476 } | 472 } |
| 477 else if (typeof response != "undefined") | 473 else if (typeof response != "undefined") |
| 478 { | 474 { |
| 479 reply(response); | 475 reply(response); |
| 480 } | 476 } |
| 481 } | 477 } |
| 482 }); | 478 }); |
| 483 | 479 |
| 484 let filters = [ | 480 const filters = [ |
| 485 "@@||alternate.de^$document", | 481 "@@||alternate.de^$document", |
| 486 "@@||der.postillion.com^$document", | 482 "@@||der.postillion.com^$document", |
| 487 "@@||taz.de^$document", | 483 "@@||taz.de^$document", |
| 488 "@@||amazon.de^$document", | 484 "@@||amazon.de^$document", |
| 489 "||biglemon.am/bg_poster/banner.jpg", | 485 "||biglemon.am/bg_poster/banner.jpg", |
| 490 "winfuture.de###header_logo_link", | 486 "winfuture.de###header_logo_link", |
| 491 "###WerbungObenRechts10_GesamtDIV", | 487 "###WerbungObenRechts10_GesamtDIV", |
| 492 "###WerbungObenRechts8_GesamtDIV", | 488 "###WerbungObenRechts8_GesamtDIV", |
| 493 "###WerbungObenRechts9_GesamtDIV", | 489 "###WerbungObenRechts9_GesamtDIV", |
| 494 "###WerbungUntenLinks4_GesamtDIV", | 490 "###WerbungUntenLinks4_GesamtDIV", |
| 495 "###WerbungUntenLinks7_GesamtDIV", | 491 "###WerbungUntenLinks7_GesamtDIV", |
| 496 "###WerbungUntenLinks8_GesamtDIV", | 492 "###WerbungUntenLinks8_GesamtDIV", |
| 497 "###WerbungUntenLinks9_GesamtDIV", | 493 "###WerbungUntenLinks9_GesamtDIV", |
| 498 "###Werbung_Sky", | 494 "###Werbung_Sky", |
| 499 "###Werbung_Wide", | 495 "###Werbung_Wide", |
| 500 "###__ligatus_placeholder__", | 496 "###__ligatus_placeholder__", |
| 501 "###ad-bereich1-08", | 497 "###ad-bereich1-08", |
| 502 "###ad-bereich1-superbanner", | 498 "###ad-bereich1-superbanner", |
| 503 "###ad-bereich2-08", | 499 "###ad-bereich2-08", |
| 504 "###ad-bereich2-skyscrapper" | 500 "###ad-bereich2-skyscrapper" |
| 505 ]; | 501 ]; |
| 506 let knownFilters = filters.map(modules.filterClasses.Filter.fromText); | 502 const knownFilters = filters.map(modules.filterClasses.Filter.fromText); |
| 507 | 503 |
| 508 let knownSubscriptions = Object.create(null); | 504 const knownSubscriptions = new Map(); |
| 509 for (let url in subscriptionDetails) | 505 for (const url in subscriptionDetails) |
| 510 { | 506 { |
| 511 if (!subscriptionDetails[url].installed) | 507 if (!subscriptionDetails[url].installed) |
| 512 continue; | 508 continue; |
| 513 | 509 |
| 514 knownSubscriptions[url] = | 510 knownSubscriptions.set( |
| 515 modules.subscriptionClasses.Subscription.fromURL(url); | 511 url, |
| 516 } | 512 modules.subscriptionClasses.Subscription.fromURL(url) |
| 517 let customSubscription = knownSubscriptions["~user~786254"]; | 513 ); |
| 514 } |
| 515 const customSubscription = knownSubscriptions.get("~user~786254"); |
| 518 | 516 |
| 519 if (params.addSubscription) | 517 if (params.addSubscription) |
| 520 { | 518 { |
| 521 // We don't know how long it will take for the page to fully load | 519 // We don't know how long it will take for the page to fully load |
| 522 // so we'll post the message after one second | 520 // so we'll post the message after one second |
| 523 setTimeout(() => | 521 setTimeout(() => |
| 524 { | 522 { |
| 525 window.postMessage({ | 523 window.postMessage({ |
| 526 type: "message", | 524 type: "message", |
| 527 payload: { | 525 payload: { |
| 528 title: "Custom subscription", | 526 title: "Custom subscription", |
| 529 url: "http://example.com/custom.txt", | 527 url: "http://example.com/custom.txt", |
| 530 confirm: true, | 528 confirm: true, |
| 531 type: "subscriptions.add" | 529 type: "subscriptions.add" |
| 532 } | 530 } |
| 533 }, "*"); | 531 }, "*"); |
| 534 }, 1000); | 532 }, 1000); |
| 535 } | 533 } |
| 536 | 534 |
| 537 if (params.showPageOptions) | 535 if (params.showPageOptions) |
| 538 { | 536 { |
| 539 // We don't know how long it will take for the page to fully load | 537 // We don't know how long it will take for the page to fully load |
| 540 // so we'll post the message after one second | 538 // so we'll post the message after one second |
| 541 setTimeout(() => | 539 setTimeout(() => |
| 542 { | 540 { |
| 543 let host = "example.com"; | 541 const host = "example.com"; |
| 544 let isWhitelisted = customSubscription.filters | 542 const isWhitelisted = customSubscription.filters |
| 545 .some((filter) => filter.text == `@@||${host}^$document`); | 543 .some((filter) => filter.text == `@@||${host}^$document`); |
| 546 window.postMessage({ | 544 window.postMessage({ |
| 547 type: "message", | 545 type: "message", |
| 548 payload: { | 546 payload: { |
| 549 type: "app.open", | 547 type: "app.open", |
| 550 what: "options", | 548 what: "options", |
| 551 action: "showPageOptions", | 549 action: "showPageOptions", |
| 552 args: [ | 550 args: [ |
| 553 { | 551 { |
| 554 host, | 552 host, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 type: "POPUP", | 626 type: "POPUP", |
| 629 docDomain: "example.com" | 627 docDomain: "example.com" |
| 630 }, | 628 }, |
| 631 filter: { | 629 filter: { |
| 632 text: "||example.com/some-annoying-popup$popup", | 630 text: "||example.com/some-annoying-popup$popup", |
| 633 whitelisted: false, | 631 whitelisted: false, |
| 634 userDefined: true, | 632 userDefined: true, |
| 635 subscription: null | 633 subscription: null |
| 636 } | 634 } |
| 637 }); | 635 }); |
| 636 |
| 637 // rewrite |
| 638 panel.sendMessage({ |
| 639 type: "add-record", |
| 640 request: { |
| 641 url: "http://example.com/some-annoying-popup", |
| 642 type: "OTHER", |
| 643 docDomain: "example.com", |
| 644 rewrittenUrl: "http://example.com/some-annoying-popup?nopopup" |
| 645 }, |
| 646 filter: { |
| 647 text: "/(example\\.com\\/some-annoying-popup\\)$/$rewrite=$1?nopopup", |
| 648 whitelisted: false, |
| 649 userDefined: true, |
| 650 subscription: null |
| 651 } |
| 652 }); |
| 638 }); | 653 }); |
| 639 }()); | 654 }()); |
| LEFT | RIGHT |