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-2017 eyeo GmbH | 3 * Copyright (C) 2006-2017 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 document.body.classList.add("nohtml"); | 42 document.body.classList.add("nohtml"); |
43 require("messaging").getPort(window).on( | 43 require("messaging").getPort(window).on( |
44 "composer.ready", (message, sender) => | 44 "composer.ready", (message, sender) => |
45 { | 45 { |
46 if (sender.page.id == page.id) | 46 if (sender.page.id == page.id) |
47 document.body.classList.remove("nohtml"); | 47 document.body.classList.remove("nohtml"); |
48 } | 48 } |
49 ); | 49 ); |
50 } | 50 } |
51 | 51 |
52 // Ask content script whether clickhide is active. If so, show cancel button
. | 52 // Ask content script whether clickhide is active. If so, show |
53 // If that isn't the case, ask background.html whether it has cached filters
. If so, | 53 // cancel button. If that isn't the case, ask background.html |
54 // ask the user whether she wants those filters. | 54 // whether it has cached filters. If so, ask the user whether she |
55 // Otherwise, we are in default state. | 55 // wants those filters. Otherwise, we are in default state. |
56 if (page) | 56 if (page) |
57 { | 57 { |
58 if (checkWhitelisted(page)) | 58 if (checkWhitelisted(page)) |
59 document.body.classList.add("disabled"); | 59 document.body.classList.add("disabled"); |
60 | 60 |
61 page.sendMessage({type: "composer.content.getState"}, response => | 61 page.sendMessage({type: "composer.content.getState"}, response => |
62 { | 62 { |
63 if (response && response.active) | 63 if (response && response.active) |
64 document.body.classList.add("clickhide-active"); | 64 document.body.classList.add("clickhide-active"); |
65 }); | 65 }); |
66 } | 66 } |
67 }); | 67 }); |
68 | 68 |
69 document.getElementById("enabled").addEventListener("click", toggleEnabled, fa
lse); | 69 document.getElementById("enabled").addEventListener( |
70 document.getElementById("clickhide").addEventListener("click", activateClickHi
de, false); | 70 "click", toggleEnabled, false |
71 document.getElementById("clickhide-cancel").addEventListener("click", cancelCl
ickHide, false); | 71 ); |
| 72 document.getElementById("clickhide").addEventListener( |
| 73 "click", activateClickHide, false |
| 74 ); |
| 75 document.getElementById("clickhide-cancel").addEventListener( |
| 76 "click", cancelClickHide, false |
| 77 ); |
72 document.getElementById("options").addEventListener("click", () => | 78 document.getElementById("options").addEventListener("click", () => |
73 { | 79 { |
74 ext.showOptions(); | 80 ext.showOptions(); |
75 }, false); | 81 }, false); |
76 | 82 |
77 // Set up collapsing of menu items | 83 // Set up collapsing of menu items |
78 for (let collapser of document.getElementsByClassName("collapse")) | 84 for (let collapser of document.getElementsByClassName("collapse")) |
79 { | 85 { |
80 collapser.addEventListener("click", toggleCollapse, false); | 86 collapser.addEventListener("click", toggleCollapse, false); |
81 if (!Prefs[collapser.dataset.option]) | 87 if (!Prefs[collapser.dataset.option]) |
82 document.getElementById(collapser.dataset.collapsable).classList.add("coll
apsed"); | 88 { |
| 89 document.getElementById( |
| 90 collapser.dataset.collapsable |
| 91 ).classList.add("collapsed"); |
| 92 } |
83 } | 93 } |
84 } | 94 } |
85 | 95 |
86 function toggleEnabled() | 96 function toggleEnabled() |
87 { | 97 { |
88 let disabled = document.body.classList.toggle("disabled"); | 98 let disabled = document.body.classList.toggle("disabled"); |
89 if (disabled) | 99 if (disabled) |
90 { | 100 { |
91 let host = getDecodedHostname(page.url).replace(/^www\./, ""); | 101 let host = getDecodedHostname(page.url).replace(/^www\./, ""); |
92 let filter = Filter.fromText("@@||" + host + "^$document"); | 102 let filter = Filter.fromText("@@||" + host + "^$document"); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 } | 143 } |
134 | 144 |
135 function toggleCollapse(event) | 145 function toggleCollapse(event) |
136 { | 146 { |
137 let collapser = event.currentTarget; | 147 let collapser = event.currentTarget; |
138 Prefs[collapser.dataset.option] = !Prefs[collapser.dataset.option]; | 148 Prefs[collapser.dataset.option] = !Prefs[collapser.dataset.option]; |
139 collapser.parentNode.classList.toggle("collapsed"); | 149 collapser.parentNode.classList.toggle("collapsed"); |
140 } | 150 } |
141 | 151 |
142 document.addEventListener("DOMContentLoaded", onLoad, false); | 152 document.addEventListener("DOMContentLoaded", onLoad, false); |
OLD | NEW |