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-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 with(require("filterClasses")) | 18 with(require("filterClasses")) |
19 { | 19 { |
20 this.Filter = Filter; | 20 this.Filter = Filter; |
21 this.RegExpFilter = RegExpFilter; | |
22 this.BlockingFilter = BlockingFilter; | 21 this.BlockingFilter = BlockingFilter; |
23 this.WhitelistFilter = WhitelistFilter; | 22 this.WhitelistFilter = WhitelistFilter; |
24 } | 23 } |
25 with(require("subscriptionClasses")) | 24 with(require("subscriptionClasses")) |
26 { | 25 { |
27 this.Subscription = Subscription; | 26 this.Subscription = Subscription; |
28 this.DownloadableSubscription = DownloadableSubscription; | 27 this.DownloadableSubscription = DownloadableSubscription; |
29 this.SpecialSubscription = SpecialSubscription; | 28 this.SpecialSubscription = SpecialSubscription; |
30 } | 29 } |
31 with(require("whitelisting")) | 30 with(require("whitelisting")) |
32 { | 31 { |
33 this.isPageWhitelisted = isPageWhitelisted; | 32 this.isPageWhitelisted = isPageWhitelisted; |
34 this.isFrameWhitelisted = isFrameWhitelisted; | 33 this.isFrameWhitelisted = isFrameWhitelisted; |
35 this.processKey = processKey; | 34 this.processKey = processKey; |
36 this.getKey = getKey; | 35 this.getKey = getKey; |
37 } | 36 } |
38 with(require("url")) | 37 with(require("url")) |
39 { | 38 { |
40 this.stringifyURL = stringifyURL; | 39 this.stringifyURL = stringifyURL; |
41 this.isThirdParty = isThirdParty; | 40 this.isThirdParty = isThirdParty; |
42 this.extractHostFromFrame = extractHostFromFrame; | 41 this.extractHostFromFrame = extractHostFromFrame; |
| 42 } |
| 43 with(require("icon")) |
| 44 { |
| 45 this.updateIcon = updateIcon; |
| 46 this.startIconAnimation = startIconAnimation; |
| 47 this.stopIconAnimation = stopIconAnimation; |
43 } | 48 } |
44 var FilterStorage = require("filterStorage").FilterStorage; | 49 var FilterStorage = require("filterStorage").FilterStorage; |
45 var ElemHide = require("elemHide").ElemHide; | 50 var ElemHide = require("elemHide").ElemHide; |
46 var defaultMatcher = require("matcher").defaultMatcher; | 51 var defaultMatcher = require("matcher").defaultMatcher; |
47 var Prefs = require("prefs").Prefs; | 52 var Prefs = require("prefs").Prefs; |
48 var Synchronizer = require("synchronizer").Synchronizer; | 53 var Synchronizer = require("synchronizer").Synchronizer; |
49 var Utils = require("utils").Utils; | 54 var Utils = require("utils").Utils; |
50 var NotificationStorage = require("notification").Notification; | 55 var NotificationStorage = require("notification").Notification; |
51 var initAntiAdblockNotification = require("antiadblockInit").initAntiAdblockNoti
fication; | 56 var initAntiAdblockNotification = require("antiadblockInit").initAntiAdblockNoti
fication; |
52 var parseFilters = require("filterValidation").parseFilters; | 57 var parseFilters = require("filterValidation").parseFilters; |
53 var composeFilters = require("filterComposer").composeFilters; | 58 var composeFilters = require("filterComposer").composeFilters; |
54 | 59 |
55 // Some types cannot be distinguished | |
56 RegExpFilter.typeMap.OBJECT_SUBREQUEST = RegExpFilter.typeMap.OBJECT; | |
57 RegExpFilter.typeMap.MEDIA = RegExpFilter.typeMap.FONT = RegExpFilter.typeMap.OT
HER; | |
58 | |
59 // Chrome on Linux does not fully support chrome.notifications until version 35 | 60 // Chrome on Linux does not fully support chrome.notifications until version 35 |
60 // https://code.google.com/p/chromium/issues/detail?id=291485 | 61 // https://code.google.com/p/chromium/issues/detail?id=291485 |
61 var canUseChromeNotifications = require("info").platform == "chromium" | 62 var canUseChromeNotifications = require("info").platform == "chromium" |
62 && "notifications" in chrome | 63 && "notifications" in chrome |
63 && (navigator.platform.indexOf("Linux") == -1 || parseInt(require("info").appl
icationVersion, 10) > 34); | 64 && (navigator.platform.indexOf("Linux") == -1 || parseInt(require("info").appl
icationVersion, 10) > 34); |
64 | 65 |
65 var seenDataCorruption = false; | 66 var seenDataCorruption = false; |
66 var filterlistsReinitialized = false; | 67 var filterlistsReinitialized = false; |
67 require("filterNotifier").FilterNotifier.addListener(function(action) | 68 require("filterNotifier").FilterNotifier.addListener(function(action) |
68 { | 69 { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 onclick: function(page) | 129 onclick: function(page) |
129 { | 130 { |
130 page.sendMessage({type: "clickhide-new-filter"}); | 131 page.sendMessage({type: "clickhide-new-filter"}); |
131 } | 132 } |
132 }; | 133 }; |
133 | 134 |
134 // Adds or removes browser action icon according to options. | 135 // Adds or removes browser action icon according to options. |
135 function refreshIconAndContextMenu(page) | 136 function refreshIconAndContextMenu(page) |
136 { | 137 { |
137 var whitelisted = isPageWhitelisted(page); | 138 var whitelisted = isPageWhitelisted(page); |
138 | 139 updateIcon(page, whitelisted); |
139 var iconFilename; | |
140 if (whitelisted && require("info").platform != "safari") | |
141 // There is no grayscale version of the icon for whitelisted pages | |
142 // when using Safari, because icons are grayscale already and icons | |
143 // aren't per page in Safari. | |
144 iconFilename = "icons/abp-$size-whitelisted.png"; | |
145 else | |
146 iconFilename = "icons/abp-$size.png"; | |
147 | |
148 page.browserAction.setIcon(iconFilename); | |
149 iconAnimation.registerPage(page, iconFilename); | |
150 | 140 |
151 // show or hide the context menu entry dependent on whether | 141 // show or hide the context menu entry dependent on whether |
152 // adblocking is active on that page | 142 // adblocking is active on that page |
153 page.contextMenus.removeAll(); | 143 page.contextMenus.removeAll(); |
154 | |
155 if (Prefs.shouldShowBlockElementMenu && !whitelisted && htmlPages.has(page)) | 144 if (Prefs.shouldShowBlockElementMenu && !whitelisted && htmlPages.has(page)) |
156 page.contextMenus.create(contextMenuItem); | 145 page.contextMenus.create(contextMenuItem); |
157 } | 146 } |
158 | 147 |
159 function refreshIconAndContextMenuForAllPages() | 148 function refreshIconAndContextMenuForAllPages() |
160 { | 149 { |
161 ext.pages.query({}, function(pages) | 150 ext.pages.query({}, function(pages) |
162 { | 151 { |
163 pages.forEach(refreshIconAndContextMenu); | 152 pages.forEach(refreshIconAndContextMenu); |
164 }); | 153 }); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 if (name == "shouldShowBlockElementMenu") | 259 if (name == "shouldShowBlockElementMenu") |
271 refreshIconAndContextMenuForAllPages(); | 260 refreshIconAndContextMenuForAllPages(); |
272 }); | 261 }); |
273 | 262 |
274 function prepareNotificationIconAndPopup() | 263 function prepareNotificationIconAndPopup() |
275 { | 264 { |
276 var animateIcon = (activeNotification.type !== "question"); | 265 var animateIcon = (activeNotification.type !== "question"); |
277 activeNotification.onClicked = function() | 266 activeNotification.onClicked = function() |
278 { | 267 { |
279 if (animateIcon) | 268 if (animateIcon) |
280 iconAnimation.stop(); | 269 stopIconAnimation(); |
281 notificationClosed(); | 270 notificationClosed(); |
282 }; | 271 }; |
283 if (animateIcon) | 272 if (animateIcon) |
284 iconAnimation.update(activeNotification.type); | 273 startIconAnimation(activeNotification.type); |
285 } | 274 } |
286 | 275 |
287 function openNotificationLinks() | 276 function openNotificationLinks() |
288 { | 277 { |
289 if (activeNotification.links) | 278 if (activeNotification.links) |
290 { | 279 { |
291 activeNotification.links.forEach(function(link) | 280 activeNotification.links.forEach(function(link) |
292 { | 281 { |
293 ext.windows.getLastFocused(function(win) | 282 ext.windows.getLastFocused(function(win) |
294 { | 283 { |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 page.sendMessage({type: "clickhide-deactivate"}); | 579 page.sendMessage({type: "clickhide-deactivate"}); |
591 refreshIconAndContextMenu(page); | 580 refreshIconAndContextMenu(page); |
592 }); | 581 }); |
593 | 582 |
594 setTimeout(function() | 583 setTimeout(function() |
595 { | 584 { |
596 var notificationToShow = NotificationStorage.getNextToShow(); | 585 var notificationToShow = NotificationStorage.getNextToShow(); |
597 if (notificationToShow) | 586 if (notificationToShow) |
598 showNotification(notificationToShow); | 587 showNotification(notificationToShow); |
599 }, 3 * 60 * 1000); | 588 }, 3 * 60 * 1000); |
LEFT | RIGHT |