LEFT | RIGHT |
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 { | 122 { |
123 if (/^(?!https?:)[\w-]+:/i.test(urls[i])) | 123 if (/^(?!https?:)[\w-]+:/i.test(urls[i])) |
124 urls.splice(i--, 1); | 124 urls.splice(i--, 1); |
125 } | 125 } |
126 | 126 |
127 return urls; | 127 return urls; |
128 } | 128 } |
129 | 129 |
130 function hideElement(element) | 130 function hideElement(element) |
131 { | 131 { |
132 function doHide(el) | 132 function doHide() |
133 { | 133 { |
134 let propertyName = "display"; | 134 let propertyName = "display"; |
135 let propertyValue = "none"; | 135 let propertyValue = "none"; |
136 if (el.localName == "frame") | 136 if (element.localName == "frame") |
137 { | 137 { |
138 propertyName = "visibility"; | 138 propertyName = "visibility"; |
139 propertyValue = "hidden"; | 139 propertyValue = "hidden"; |
140 } | 140 } |
141 | 141 |
142 if (el.style.getPropertyValue(propertyName) != propertyValue || | 142 if (element.style.getPropertyValue(propertyName) != propertyValue || |
143 el.style.getPropertyPriority(propertyName) != "important") | 143 element.style.getPropertyPriority(propertyName) != "important") |
144 el.style.setProperty(propertyName, propertyValue, "important"); | 144 element.style.setProperty(propertyName, propertyValue, "important"); |
145 } | 145 } |
146 | 146 |
147 function processMutations(mutations) | 147 doHide(); |
148 { | 148 |
149 for (let mutation of mutations) | 149 new MutationObserver(doHide).observe( |
150 doHide(mutation.target); | |
151 } | |
152 | |
153 doHide(element); | |
154 | |
155 new MutationObserver(processMutations).observe( | |
156 element, { | 150 element, { |
157 attributes: true, | 151 attributes: true, |
158 attributeFilter: ["style"] | 152 attributeFilter: ["style"] |
159 } | 153 } |
160 ); | 154 ); |
161 } | 155 } |
162 | 156 |
163 function checkCollapse(element) | 157 function checkCollapse(element) |
164 { | 158 { |
165 let mediatype = typeMap.get(element.localName); | 159 let mediatype = typeMap.get(element.localName); |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 checkCollapse(event.target); | 491 checkCollapse(event.target); |
498 }, true); | 492 }, true); |
499 | 493 |
500 document.addEventListener("load", event => | 494 document.addEventListener("load", event => |
501 { | 495 { |
502 let element = event.target; | 496 let element = event.target; |
503 if (/^i?frame$/.test(element.localName)) | 497 if (/^i?frame$/.test(element.localName)) |
504 checkCollapse(element); | 498 checkCollapse(element); |
505 }, true); | 499 }, true); |
506 } | 500 } |
LEFT | RIGHT |