| 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 |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 continue; | 213 continue; |
| 214 if (Prefs.notifications_ignoredcategories.indexOf("*") != -1) | 214 if (Prefs.notifications_ignoredcategories.indexOf("*") != -1) |
| 215 continue; | 215 continue; |
| 216 } | 216 } |
| 217 | 217 |
| 218 if (typeof url === "string" || notification.urlFilters instanceof Array) | 218 if (typeof url === "string" || notification.urlFilters instanceof Array) |
| 219 { | 219 { |
| 220 if (Prefs.enabled && typeof url === "string" && notification.urlFilters
instanceof Array) | 220 if (Prefs.enabled && typeof url === "string" && notification.urlFilters
instanceof Array) |
| 221 { | 221 { |
| 222 let host; | 222 let host; |
| 223 if (typeof URL == "function") | 223 try |
| 224 host = new URL(url).hostname; | |
| 225 else | |
| 226 { | 224 { |
| 227 try | 225 host = new URL(url).host; |
| 228 { | |
| 229 host = Services.io.newURI(url, null, null).host; | |
| 230 } | |
| 231 catch (e) | |
| 232 { | |
| 233 // Ignore, an exception is expected for about: and similar schemes | |
| 234 host = ""; | |
| 235 } | |
| 236 } | 226 } |
| 227 catch (e) |
| 228 { |
| 229 host = ""; |
| 230 } |
| 231 |
| 237 let exception = defaultMatcher.matchesAny(url, RegExpFilter.typeMap.DO
CUMENT, host, false, null); | 232 let exception = defaultMatcher.matchesAny(url, RegExpFilter.typeMap.DO
CUMENT, host, false, null); |
| 238 if (exception instanceof WhitelistFilter) | 233 if (exception instanceof WhitelistFilter) |
| 239 continue; | 234 continue; |
| 240 | 235 |
| 241 let matcher = new Matcher(); | 236 let matcher = new Matcher(); |
| 242 for (let urlFilter of notification.urlFilters) | 237 for (let urlFilter of notification.urlFilters) |
| 243 matcher.add(Filter.fromText(urlFilter)); | 238 matcher.add(Filter.fromText(urlFilter)); |
| 244 if (!matcher.matchesAny(url, RegExpFilter.typeMap.DOCUMENT, host, fals
e, null)) | 239 if (!matcher.matchesAny(url, RegExpFilter.typeMap.DOCUMENT, host, fals
e, null)) |
| 245 continue; | 240 continue; |
| 246 } | 241 } |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 Prefs.notifications_showui = true; | 398 Prefs.notifications_showui = true; |
| 404 } | 399 } |
| 405 else if (index != -1 && forceValue !== true) | 400 else if (index != -1 && forceValue !== true) |
| 406 categories.splice(index, 1); | 401 categories.splice(index, 1); |
| 407 | 402 |
| 408 // HACK: JSON values aren't saved unless they are assigned a different objec
t. | 403 // HACK: JSON values aren't saved unless they are assigned a different objec
t. |
| 409 Prefs.notifications_ignoredcategories = JSON.parse(JSON.stringify(categories
)); | 404 Prefs.notifications_ignoredcategories = JSON.parse(JSON.stringify(categories
)); |
| 410 } | 405 } |
| 411 }; | 406 }; |
| 412 Notification.init(); | 407 Notification.init(); |
| OLD | NEW |