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 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 var canUseChromeNotifications = require("info").platform == "chromium" | 62 var canUseChromeNotifications = require("info").platform == "chromium" |
63 && "notifications" in chrome | 63 && "notifications" in chrome |
64 && (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); |
65 | 65 |
66 var seenDataCorruption = false; | 66 var seenDataCorruption = false; |
67 var filterlistsReinitialized = false; | 67 var filterlistsReinitialized = false; |
68 require("filterNotifier").FilterNotifier.addListener(function(action) | 68 require("filterNotifier").FilterNotifier.addListener(function(action) |
69 { | 69 { |
70 if (action == "load") | 70 if (action == "load") |
71 { | 71 { |
72 var addonVersion = require("info").addonVersion; | 72 ext.storage.get(["currentVersion"], function(items) |
73 var prevVersion = ext.storage.currentVersion; | 73 { |
| 74 var addonVersion = require("info").addonVersion; |
| 75 var prevVersion = items.currentVersion; |
74 | 76 |
75 // There are no filters stored so we need to reinitialize all filterlists | 77 // There are no filters stored so we need to reinitialize all filterlists |
76 if (!FilterStorage.firstRun && FilterStorage.subscriptions.length === 0) | 78 if (!FilterStorage.firstRun && FilterStorage.subscriptions.length === 0) |
77 { | 79 { |
78 filterlistsReinitialized = true; | 80 filterlistsReinitialized = true; |
79 prevVersion = null; | 81 prevVersion = null; |
80 } | 82 } |
81 | 83 |
82 if (prevVersion != addonVersion || FilterStorage.firstRun) | 84 if (prevVersion != addonVersion || FilterStorage.firstRun) |
83 { | 85 { |
84 seenDataCorruption = prevVersion && FilterStorage.firstRun; | 86 seenDataCorruption = prevVersion && FilterStorage.firstRun; |
85 ext.storage.currentVersion = addonVersion; | 87 ext.storage.set("currentVersion", addonVersion); |
86 addSubscription(prevVersion); | 88 addSubscription(prevVersion); |
87 } | 89 } |
| 90 |
| 91 // The "Hide placeholders" option has been removed from the UI in 1.8.8.12
85 |
| 92 // So we reset the option for users updating from older versions. |
| 93 if (prevVersion && Services.vc.compare(prevVersion, "1.8.8.1285") < 0) |
| 94 Prefs.hidePlaceholders = true; |
| 95 }); |
88 | 96 |
89 if (canUseChromeNotifications) | 97 if (canUseChromeNotifications) |
90 initChromeNotifications(); | 98 initChromeNotifications(); |
91 initAntiAdblockNotification(); | 99 initAntiAdblockNotification(); |
92 | |
93 // The "Hide placeholders" option has been removed from the UI in 1.8.8.1285 | |
94 // So we reset the option for users updating from older versions. | |
95 if (prevVersion && Services.vc.compare(prevVersion, "1.8.8.1285") < 0) | |
96 Prefs.hidePlaceholders = true; | |
97 } | 100 } |
98 | 101 |
99 // update browser actions when whitelisting might have changed, | 102 // update browser actions when whitelisting might have changed, |
100 // due to loading filters or saving filter changes | 103 // due to loading filters or saving filter changes |
101 if (action == "load" || action == "save") | 104 if (action == "load" || action == "save") |
102 refreshIconAndContextMenuForAllPages(); | 105 refreshIconAndContextMenuForAllPages(); |
103 }); | 106 }); |
104 | 107 |
105 // Special-case domains for which we cannot use style-based hiding rules. | 108 // Special-case domains for which we cannot use style-based hiding rules. |
106 // See http://crbug.com/68705. | 109 // See http://crbug.com/68705. |
107 var noStyleRulesHosts = ["mail.google.com", "mail.yahoo.com", "www.google.com"]; | 110 var noStyleRulesHosts = ["mail.google.com", "mail.yahoo.com", "www.google.com"]; |
108 | 111 |
109 var htmlPages = new ext.PageMap(); | 112 var htmlPages = new ext.PageMap(); |
110 | |
111 function removeDeprecatedOptions() | |
112 { | |
113 var deprecatedOptions = ["specialCaseYouTube", "experimental", "disableInlineT
extAds"]; | |
114 deprecatedOptions.forEach(function(option) | |
115 { | |
116 if (option in ext.storage) | |
117 delete ext.storage[option]; | |
118 }); | |
119 } | |
120 | |
121 // Remove deprecated options before we do anything else. | |
122 removeDeprecatedOptions(); | |
123 | |
124 var activeNotification = null; | 113 var activeNotification = null; |
125 | 114 |
126 var contextMenuItem = { | 115 var contextMenuItem = { |
127 title: ext.i18n.getMessage("block_element"), | 116 title: ext.i18n.getMessage("block_element"), |
128 contexts: ["image", "video", "audio"], | 117 contexts: ["image", "video", "audio"], |
129 onclick: function(page) | 118 onclick: function(page) |
130 { | 119 { |
131 page.sendMessage({type: "clickhide-new-filter"}); | 120 page.sendMessage({type: "clickhide-new-filter"}); |
132 } | 121 } |
133 }; | 122 }; |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 }); | 535 }); |
547 break; | 536 break; |
548 case "add-sitekey": | 537 case "add-sitekey": |
549 processKey(msg.token, sender.page, sender.frame); | 538 processKey(msg.token, sender.page, sender.frame); |
550 break; | 539 break; |
551 case "report-html-page": | 540 case "report-html-page": |
552 htmlPages.set(sender.page, null); | 541 htmlPages.set(sender.page, null); |
553 refreshIconAndContextMenu(sender.page); | 542 refreshIconAndContextMenu(sender.page); |
554 break; | 543 break; |
555 case "compose-filters": | 544 case "compose-filters": |
556 sendResponse(composeFilters({ | 545 sendResponse(composeFilters( |
557 tagName: msg.tagName, | 546 msg.tagName, msg.id, msg.src, msg.style, |
558 id: msg.id, | 547 msg.classes, msg.urls, new URL(msg.baseURL) |
559 src: msg.src, | 548 )); |
560 style: msg.style, | |
561 classes: msg.classes, | |
562 urls: msg.urls, | |
563 type: msg.mediatype, | |
564 baseURL: msg.baseURL, | |
565 page: sender.page, | |
566 frame: sender.frame | |
567 })); | |
568 break; | 549 break; |
569 case "forward": | 550 case "forward": |
570 if (sender.page) | 551 if (sender.page) |
571 { | 552 { |
572 if (msg.expectsResponse) | 553 if (msg.expectsResponse) |
573 { | 554 { |
574 sender.page.sendMessage(msg.payload, sendResponse); | 555 sender.page.sendMessage(msg.payload, sendResponse); |
575 return true; | 556 return true; |
576 } | 557 } |
577 | 558 |
578 sender.page.sendMessage(msg.payload); | 559 sender.page.sendMessage(msg.payload); |
579 } | 560 } |
580 break; | 561 break; |
581 } | 562 } |
582 }); | 563 }); |
583 | 564 |
584 // update icon when page changes location | 565 // update icon when page changes location |
585 ext.pages.onLoading.addListener(function(page) | 566 ext.pages.onLoading.addListener(function(page) |
586 { | 567 { |
587 page.sendMessage({type: "clickhide-deactivate"}); | 568 page.sendMessage({type: "clickhide-deactivate"}); |
588 refreshIconAndContextMenu(page); | 569 refreshIconAndContextMenu(page); |
589 }); | 570 }); |
590 | 571 |
591 setTimeout(function() | 572 setTimeout(function() |
592 { | 573 { |
593 var notificationToShow = NotificationStorage.getNextToShow(); | 574 var notificationToShow = NotificationStorage.getNextToShow(); |
594 if (notificationToShow) | 575 if (notificationToShow) |
595 showNotification(notificationToShow); | 576 showNotification(notificationToShow); |
596 }, 3 * 60 * 1000); | 577 }, 3 * 60 * 1000); |
OLD | NEW |