| 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-2016 Eyeo GmbH | 3  * Copyright (C) 2006-2016 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 30 matching lines...) Expand all  Loading... | 
| 41 | 41 | 
| 42     // Ask content script whether clickhide is active. If so, show cancel button
     . | 42     // Ask content script whether clickhide is active. If so, show cancel button
     . | 
| 43     // If that isn't the case, ask background.html whether it has cached filters
     . If so, | 43     // If that isn't the case, ask background.html whether it has cached filters
     . If so, | 
| 44     // ask the user whether she wants those filters. | 44     // ask the user whether she wants those filters. | 
| 45     // Otherwise, we are in default state. | 45     // Otherwise, we are in default state. | 
| 46     if (page) | 46     if (page) | 
| 47     { | 47     { | 
| 48       if (checkWhitelisted(page)) | 48       if (checkWhitelisted(page)) | 
| 49         document.body.classList.add("disabled"); | 49         document.body.classList.add("disabled"); | 
| 50 | 50 | 
| 51       page.sendMessage({type: "get-clickhide-state"}, function(response) | 51       page.sendMessage({type: "blockelement-get-state"}, function(response) | 
| 52       { | 52       { | 
| 53         if (response && response.active) | 53         if (response && response.active) | 
| 54           document.body.classList.add("clickhide-active"); | 54           document.body.classList.add("clickhide-active"); | 
| 55       }); | 55       }); | 
| 56     } | 56     } | 
| 57   }); | 57   }); | 
| 58 | 58 | 
| 59   // Attach event listeners | 59   // Attach event listeners | 
| 60   ext.onMessage.addListener(onMessage); | 60   ext.onMessage.addListener(onMessage); | 
| 61   document.getElementById("enabled").addEventListener("click", toggleEnabled, fa
     lse); | 61   document.getElementById("enabled").addEventListener("click", toggleEnabled, fa
     lse); | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
| 77   } | 77   } | 
| 78 } | 78 } | 
| 79 | 79 | 
| 80 function onUnload() | 80 function onUnload() | 
| 81 { | 81 { | 
| 82   ext.onMessage.removeListener(onMessage); | 82   ext.onMessage.removeListener(onMessage); | 
| 83 } | 83 } | 
| 84 | 84 | 
| 85 function onMessage(message, sender, callback) | 85 function onMessage(message, sender, callback) | 
| 86 { | 86 { | 
| 87   if (message.type == "report-html-page" && sender.page._id == page._id) | 87   if (message.type == "report-html-page" && sender.page.id == page.id) | 
| 88     document.body.classList.remove("nohtml"); | 88     document.body.classList.remove("nohtml"); | 
| 89 } | 89 } | 
| 90 | 90 | 
| 91 function toggleEnabled() | 91 function toggleEnabled() | 
| 92 { | 92 { | 
| 93   var disabled = document.body.classList.toggle("disabled"); | 93   var disabled = document.body.classList.toggle("disabled"); | 
| 94   if (disabled) | 94   if (disabled) | 
| 95   { | 95   { | 
| 96     var host = getDecodedHostname(page.url).replace(/^www\./, ""); | 96     var host = getDecodedHostname(page.url).replace(/^www\./, ""); | 
| 97     var filter = Filter.fromText("@@||" + host + "^$document"); | 97     var filter = Filter.fromText("@@||" + host + "^$document"); | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
| 113       if (filter.subscriptions.length) | 113       if (filter.subscriptions.length) | 
| 114         filter.disabled = true; | 114         filter.disabled = true; | 
| 115       filter = checkWhitelisted(page); | 115       filter = checkWhitelisted(page); | 
| 116     } | 116     } | 
| 117   } | 117   } | 
| 118 } | 118 } | 
| 119 | 119 | 
| 120 function activateClickHide() | 120 function activateClickHide() | 
| 121 { | 121 { | 
| 122   document.body.classList.add("clickhide-active"); | 122   document.body.classList.add("clickhide-active"); | 
| 123   page.sendMessage({type: "clickhide-activate"}); | 123   page.sendMessage({type: "blockelement-start-picking-element"}); | 
| 124 | 124 | 
| 125   // Close the popup after a few seconds, so user doesn't have to | 125   // Close the popup after a few seconds, so user doesn't have to | 
| 126   activateClickHide.timeout = window.setTimeout(ext.closePopup, 5000); | 126   activateClickHide.timeout = window.setTimeout(ext.closePopup, 5000); | 
| 127 } | 127 } | 
| 128 | 128 | 
| 129 function cancelClickHide() | 129 function cancelClickHide() | 
| 130 { | 130 { | 
| 131   if (activateClickHide.timeout) | 131   if (activateClickHide.timeout) | 
| 132   { | 132   { | 
| 133     window.clearTimeout(activateClickHide.timeout); | 133     window.clearTimeout(activateClickHide.timeout); | 
| 134     activateClickHide.timeout = null; | 134     activateClickHide.timeout = null; | 
| 135   } | 135   } | 
| 136   document.body.classList.remove("clickhide-active"); | 136   document.body.classList.remove("clickhide-active"); | 
| 137   page.sendMessage({type: "clickhide-deactivate"}); | 137   page.sendMessage({type: "blockelement-finished"}); | 
| 138 } | 138 } | 
| 139 | 139 | 
| 140 function toggleCollapse(event) | 140 function toggleCollapse(event) | 
| 141 { | 141 { | 
| 142   var collapser = event.currentTarget; | 142   var collapser = event.currentTarget; | 
| 143   Prefs[collapser.dataset.option] = !Prefs[collapser.dataset.option]; | 143   Prefs[collapser.dataset.option] = !Prefs[collapser.dataset.option]; | 
| 144   collapser.parentNode.classList.toggle("collapsed"); | 144   collapser.parentNode.classList.toggle("collapsed"); | 
| 145 } | 145 } | 
| 146 | 146 | 
| 147 document.addEventListener("DOMContentLoaded", onLoad, false); | 147 document.addEventListener("DOMContentLoaded", onLoad, false); | 
| 148 window.addEventListener("unload", onUnload, false); | 148 window.addEventListener("unload", onUnload, false); | 
| OLD | NEW | 
|---|