Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This file is part of the Adblock Plus extension, | 2 * This file is part of the Adblock Plus extension, |
3 * Copyright (C) 2006-2012 Eyeo GmbH | 3 * Copyright (C) 2006-2012 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 localStorage["currentVersion"] = addonVersion; | 54 localStorage["currentVersion"] = addonVersion; |
55 addSubscription(prevVersion); | 55 addSubscription(prevVersion); |
56 } | 56 } |
57 } | 57 } |
58 }); | 58 }); |
59 | 59 |
60 // Special-case domains for which we cannot use style-based hiding rules. | 60 // Special-case domains for which we cannot use style-based hiding rules. |
61 // See http://crbug.com/68705. | 61 // See http://crbug.com/68705. |
62 var noStyleRulesHosts = ["mail.google.com", "mail.yahoo.com", "www.google.com"]; | 62 var noStyleRulesHosts = ["mail.google.com", "mail.yahoo.com", "www.google.com"]; |
63 | 63 |
64 function removeDeprecatedOptions() | |
65 { | |
66 var deprecatedOptions = ["specialCaseYouTube", "experimental", "disableInlineT extAds"]; | |
67 deprecatedOptions.forEach(function(option) | |
68 { | |
69 if (option in localStorage) | |
70 delete localStorage[option]; | |
71 }); | |
72 } | |
73 | |
64 // Sets options to defaults, upgrading old options from previous versions as nec essary | 74 // Sets options to defaults, upgrading old options from previous versions as nec essary |
65 function setDefaultOptions() | 75 function setDefaultOptions() |
66 { | 76 { |
67 function defaultOptionValue(opt, val) | 77 function defaultOptionValue(opt, val) |
68 { | 78 { |
69 if(!(opt in localStorage)) | 79 if(!(opt in localStorage)) |
70 localStorage[opt] = val; | 80 localStorage[opt] = val; |
71 } | 81 } |
72 | 82 |
73 defaultOptionValue("shouldShowIcon", "true"); | 83 defaultOptionValue("shouldShowIcon", "true"); |
74 defaultOptionValue("shouldShowBlockElementMenu", "true"); | 84 defaultOptionValue("shouldShowBlockElementMenu", "true"); |
75 | 85 |
76 // If user had older version installed, get rid of old option | 86 removeDeprecatedOptions(); |
77 if ("specialCaseYouTube" in localStorage) | |
78 delete localStorage.specialCaseYouTube; | |
79 if ("experimental" in localStorage) | |
80 delete localStorage.experimental; | |
Wladimir Palant
2012/11/06 08:06:11
Please add disableInlineTextAds here to remove the
Felix Dahlke
2012/11/06 08:16:38
Done. I've refactored this a bit.
| |
81 } | 87 } |
82 | 88 |
83 // Upgrade options before we do anything else. | 89 // Upgrade options before we do anything else. |
84 setDefaultOptions(); | 90 setDefaultOptions(); |
85 | 91 |
86 /** | 92 /** |
87 * Checks whether a page is whitelisted. | 93 * Checks whether a page is whitelisted. |
88 * @param {String} url | 94 * @param {String} url |
89 * @param {String} [type] content type to be checked, default is "DOCUMENT" | 95 * @param {String} [type] content type to be checked, default is "DOCUMENT" |
90 * @return {Filter} filter that matched the URL or null if not whitelisted | 96 * @return {Filter} filter that matched the URL or null if not whitelisted |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
554 sendResponse(collapse); | 560 sendResponse(collapse); |
555 } | 561 } |
556 else | 562 else |
557 sendResponse(false); | 563 sendResponse(false); |
558 break; | 564 break; |
559 case "get-domain-enabled-state": | 565 case "get-domain-enabled-state": |
560 // Returns whether this domain is in the exclusion list. | 566 // Returns whether this domain is in the exclusion list. |
561 // The page action popup asks us this. | 567 // The page action popup asks us this. |
562 if(sender.tab) | 568 if(sender.tab) |
563 { | 569 { |
564 sendResponse({enabled: !isWhitelisted(sender.tab.url), specialCaseYouTub e: localStorage["specialCaseYouTube"] == "true"}); | 570 sendResponse({enabled: !isWhitelisted(sender.tab.url)}); |
Wladimir Palant
2012/11/06 08:06:11
Please get rid of specialCaseYouTube as well here
Felix Dahlke
2012/11/06 08:16:38
Done.
| |
565 return; | 571 return; |
566 } | 572 } |
567 break; | 573 break; |
568 case "add-filters": | 574 case "add-filters": |
569 if (request.filters && request.filters.length) | 575 if (request.filters && request.filters.length) |
570 { | 576 { |
571 for (var i = 0; i < request.filters.length; i++) | 577 for (var i = 0; i < request.filters.length; i++) |
572 FilterStorage.addFilter(Filter.fromText(request.filters[i])); | 578 FilterStorage.addFilter(Filter.fromText(request.filters[i])); |
573 } | 579 } |
574 break; | 580 break; |
(...skipping 20 matching lines...) Expand all Loading... | |
595 refreshIconAndContextMenu(windows[i].tabs[j]); | 601 refreshIconAndContextMenu(windows[i].tabs[j]); |
596 }); | 602 }); |
597 | 603 |
598 // Update icon if a tab changes location | 604 // Update icon if a tab changes location |
599 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) | 605 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) |
600 { | 606 { |
601 chrome.tabs.sendRequest(tabId, {reqtype: "clickhide-deactivate"}) | 607 chrome.tabs.sendRequest(tabId, {reqtype: "clickhide-deactivate"}) |
602 if(changeInfo.status == "loading") | 608 if(changeInfo.status == "loading") |
603 refreshIconAndContextMenu(tab); | 609 refreshIconAndContextMenu(tab); |
604 }); | 610 }); |
LEFT | RIGHT |