OLD | NEW |
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 defaultOptionValue("disableInlineTextAds", "false"); | |
76 | 85 |
77 // If user had older version installed, get rid of old option | 86 removeDeprecatedOptions(); |
78 if ("specialCaseYouTube" in localStorage) | |
79 delete localStorage.specialCaseYouTube; | |
80 if ("experimental" in localStorage) | |
81 delete localStorage.experimental; | |
82 } | 87 } |
83 | 88 |
84 // Upgrade options before we do anything else. | 89 // Upgrade options before we do anything else. |
85 setDefaultOptions(); | 90 setDefaultOptions(); |
86 | 91 |
87 /** | 92 /** |
88 * Checks whether a page is whitelisted. | 93 * Checks whether a page is whitelisted. |
89 * @param {String} url | 94 * @param {String} url |
90 * @param {String} [type] content type to be checked, default is "DOCUMENT" | 95 * @param {String} [type] content type to be checked, default is "DOCUMENT" |
91 * @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... |
555 sendResponse(collapse); | 560 sendResponse(collapse); |
556 } | 561 } |
557 else | 562 else |
558 sendResponse(false); | 563 sendResponse(false); |
559 break; | 564 break; |
560 case "get-domain-enabled-state": | 565 case "get-domain-enabled-state": |
561 // Returns whether this domain is in the exclusion list. | 566 // Returns whether this domain is in the exclusion list. |
562 // The page action popup asks us this. | 567 // The page action popup asks us this. |
563 if(sender.tab) | 568 if(sender.tab) |
564 { | 569 { |
565 sendResponse({enabled: !isWhitelisted(sender.tab.url), specialCaseYouTub
e: localStorage["specialCaseYouTube"] == "true", disableInlineTextAds: localStor
age["disableInlineTextAds"] == "true"}); | 570 sendResponse({enabled: !isWhitelisted(sender.tab.url)}); |
566 return; | 571 return; |
567 } | 572 } |
568 break; | 573 break; |
569 case "add-filters": | 574 case "add-filters": |
570 if (request.filters && request.filters.length) | 575 if (request.filters && request.filters.length) |
571 { | 576 { |
572 for (var i = 0; i < request.filters.length; i++) | 577 for (var i = 0; i < request.filters.length; i++) |
573 FilterStorage.addFilter(Filter.fromText(request.filters[i])); | 578 FilterStorage.addFilter(Filter.fromText(request.filters[i])); |
574 } | 579 } |
575 break; | 580 break; |
(...skipping 20 matching lines...) Expand all Loading... |
596 refreshIconAndContextMenu(windows[i].tabs[j]); | 601 refreshIconAndContextMenu(windows[i].tabs[j]); |
597 }); | 602 }); |
598 | 603 |
599 // Update icon if a tab changes location | 604 // Update icon if a tab changes location |
600 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) | 605 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) |
601 { | 606 { |
602 chrome.tabs.sendRequest(tabId, {reqtype: "clickhide-deactivate"}) | 607 chrome.tabs.sendRequest(tabId, {reqtype: "clickhide-deactivate"}) |
603 if(changeInfo.status == "loading") | 608 if(changeInfo.status == "loading") |
604 refreshIconAndContextMenu(tab); | 609 refreshIconAndContextMenu(tab); |
605 }); | 610 }); |
OLD | NEW |