| 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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 /** | 18 /** |
| 19 * @fileOverview Handles notifications. | 19 * @fileOverview Handles notifications. |
| 20 */ | 20 */ |
| 21 | 21 |
| 22 Cu.import("resource://gre/modules/Services.jsm"); | 22 Cu.import("resource://gre/modules/Services.jsm"); |
| 23 | 23 |
| 24 let {Prefs} = require("prefs"); | 24 let {Prefs} = require("prefs"); |
| 25 let {Downloader, Downloadable, MILLIS_IN_MINUTE, MILLIS_IN_HOUR, MILLIS_IN_DAY}
= require("downloader"); | 25 let {Downloader, Downloadable, MILLIS_IN_MINUTE, MILLIS_IN_HOUR, MILLIS_IN_DAY}
= require("downloader"); |
| 26 let {Utils} = require("utils"); | 26 let {Utils} = require("utils"); |
| 27 let {Matcher} = require("matcher"); | 27 let {Matcher, defaultMatcher} = require("matcher"); |
| 28 let {Filter, RegExpFilter} = require("filterClasses"); | 28 let {Filter, RegExpFilter, WhitelistFilter} = require("filterClasses"); |
| 29 | 29 |
| 30 let INITIAL_DELAY = 1 * MILLIS_IN_MINUTE; | 30 let INITIAL_DELAY = 1 * MILLIS_IN_MINUTE; |
| 31 let CHECK_INTERVAL = 1 * MILLIS_IN_HOUR; | 31 let CHECK_INTERVAL = 1 * MILLIS_IN_HOUR; |
| 32 let EXPIRATION_INTERVAL = 1 * MILLIS_IN_DAY; | 32 let EXPIRATION_INTERVAL = 1 * MILLIS_IN_DAY; |
| 33 let TYPE = { | 33 let TYPE = { |
| 34 information: 0, | 34 information: 0, |
| 35 question: 1, | 35 question: 1, |
| 36 critical: 2 | 36 critical: 2 |
| 37 }; | 37 }; |
| 38 | 38 |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 { | 210 { |
| 211 let shown = Prefs.notificationdata.shown; | 211 let shown = Prefs.notificationdata.shown; |
| 212 if (shown instanceof Array && shown.indexOf(notification.id) != -1) | 212 if (shown instanceof Array && shown.indexOf(notification.id) != -1) |
| 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 (typeof url === "string" && notification.urlFilters instanceof Array) | 220 if (Prefs.enabled && typeof url === "string" && notification.urlFilters
instanceof Array) |
| 221 { | 221 { |
| 222 let host = (typeof URL == "function" ? new URL(url).hostname : Utils.m
akeURI(url).host); |
| 223 let exception = defaultMatcher.matchesAny(url, RegExpFilter.typeMap.DO
CUMENT, host, false, null); |
| 224 if (exception instanceof WhitelistFilter) |
| 225 continue; |
| 226 |
| 222 let matcher = new Matcher(); | 227 let matcher = new Matcher(); |
| 223 for (let urlFilter of notification.urlFilters) | 228 for (let urlFilter of notification.urlFilters) |
| 224 matcher.add(Filter.fromText(urlFilter)); | 229 matcher.add(Filter.fromText(urlFilter)); |
| 225 if (!matcher.matchesAny(url, RegExpFilter.typeMap.DOCUMENT, url)) | 230 if (!matcher.matchesAny(url, RegExpFilter.typeMap.DOCUMENT, host, fals
e, null)) |
| 226 continue; | 231 continue; |
| 227 } | 232 } |
| 228 else | 233 else |
| 229 continue; | 234 continue; |
| 230 } | 235 } |
| 231 | 236 |
| 232 if (notification.targets instanceof Array) | 237 if (notification.targets instanceof Array) |
| 233 { | 238 { |
| 234 let match = false; | 239 let match = false; |
| 235 for (let target of notification.targets) | 240 for (let target of notification.targets) |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 Prefs.notifications_showui = true; | 389 Prefs.notifications_showui = true; |
| 385 } | 390 } |
| 386 else if (index != -1 && forceValue !== true) | 391 else if (index != -1 && forceValue !== true) |
| 387 categories.splice(index, 1); | 392 categories.splice(index, 1); |
| 388 | 393 |
| 389 // HACK: JSON values aren't saved unless they are assigned a different objec
t. | 394 // HACK: JSON values aren't saved unless they are assigned a different objec
t. |
| 390 Prefs.notifications_ignoredcategories = JSON.parse(JSON.stringify(categories
)); | 395 Prefs.notifications_ignoredcategories = JSON.parse(JSON.stringify(categories
)); |
| 391 } | 396 } |
| 392 }; | 397 }; |
| 393 Notification.init(); | 398 Notification.init(); |
| OLD | NEW |