Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 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 |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
16 */ | 16 */ |
17 | 17 |
18 // Click-to-hide stuff | 18 // Click-to-hide stuff |
19 var clickHide_activated = false; | 19 var clickHide_activated = false; |
20 var clickHide_filters = null; | 20 var clickHide_filters = null; |
21 var currentElement = null; | 21 var currentElement = null; |
22 var currentElement_boxShadow = null; | |
23 var currentElement_backgroundColor; | |
24 var clickHideFilters = null; | 22 var clickHideFilters = null; |
25 var highlightedElementsSelector = null; | 23 var highlightedElementsSelector = null; |
26 var highlightedElementsBoxShadows = null; | |
27 var highlightedElementsBGColors = null; | |
28 var clickHideFiltersDialog = null; | 24 var clickHideFiltersDialog = null; |
29 var lastRightClickEvent = null; | 25 var lastRightClickEvent = null; |
26 | |
27 function supportsShadowRoot(element) | |
28 { | |
29 if (!("createShadowRoot" in element)) | |
30 return false; | |
31 | |
32 // There are some elements (e.g. <textarea>), which don't | |
33 // support author created shadow roots and throw an exception. | |
34 var clone = element.cloneNode(false); | |
35 try | |
36 { | |
37 clone.createShadowRoot(); | |
38 } | |
39 catch (e) | |
40 { | |
41 return false; | |
42 } | |
43 | |
44 // There are some elements (e.g. <input>), which support | |
45 // author created shadow roots, but ignore insertion points. | |
46 var child = document.createTextNode(""); | |
47 clone.appendChild(child); | |
48 | |
49 var shadow = document.createElement("shadow"); | |
50 clone.shadowRoot.appendChild(shadow); | |
51 | |
52 return shadow.getDistributedNodes()[0] == child; | |
53 } | |
54 | |
55 function highlightElement(element, shadowColor, backgroundColor) | |
56 { | |
57 unhighlightElement(element); | |
58 | |
59 var originalBoxShadowPriority = element.style.getPropertyPriority("box-shadow" ); | |
60 var originalBackgroundColorPriority = element.style.getPropertyPriority("backg round-color"); | |
61 | |
62 var boxShadow = "inset 0px 0px 5px " + shadowColor; | |
63 | |
64 var highlightWithShadowDOM = function() | |
65 { | |
66 var style = document.createElement("style"); | |
67 style.textContent = ":host {" + | |
68 "box-shadow:" + boxShadow + " !important;" + | |
69 "background-color:" + backgroundColor + " !important;" + | |
70 "}"; | |
71 | |
72 var root = element.createShadowRoot(); | |
73 root.appendChild(document.createElement("shadow")); | |
74 root.appendChild(style); | |
75 | |
76 element._unhighlight = function() | |
77 { | |
78 root.removeChild(style); | |
79 }; | |
80 }; | |
81 | |
82 var highlightWithStyleAttribute = function() | |
83 { | |
84 var originalBoxShadow = element.style.getPropertyValue("box-shadow"); | |
85 var originalBackgroundColor = element.style.getPropertyValue("background-col or"); | |
86 | |
87 element.style.setProperty("box-shadow", boxShadow, "important"); | |
88 element.style.setProperty("background-color", backgroundColor, "important"); | |
89 | |
90 element._unhighlight = function() | |
91 { | |
92 this.style.removeProperty("box-shadow"); | |
93 this.style.setProperty( | |
94 "box-shadow", | |
95 originalBoxShadow, | |
96 originalBoxShadowPriority | |
97 ); | |
98 | |
99 this.style.removeProperty("background-color"); | |
100 this.style.setProperty( | |
101 "background-color", | |
102 originalBackgroundColor, | |
103 originalBackgroundColorPriority | |
104 ); | |
105 }; | |
106 }; | |
107 | |
108 // Use shadow DOM if posibble to avoid side effects when the | |
109 // web page updates style while highlighted. However, if the | |
110 // element has important styles we can't override them with shadow DOM. | |
111 if (supportsShadowRoot(element) && originalBoxShadowPriority != "importa nt" && | |
112 originalBackgroundColorPriority != "importa nt") | |
113 highlightWithShadowDOM(); | |
114 else | |
115 highlightWithStyleAttribute(); | |
116 } | |
117 | |
118 | |
119 function unhighlightElement(element) | |
120 { | |
121 if ("_unhighlight" in element) | |
122 { | |
123 element._unhighlight(); | |
124 delete element._unhighlight; | |
125 } | |
126 } | |
30 | 127 |
31 // Highlight elements according to selector string. This would include | 128 // Highlight elements according to selector string. This would include |
32 // all elements that would be affected by proposed filters. | 129 // all elements that would be affected by proposed filters. |
33 function highlightElements(selectorString) { | 130 function highlightElements(selectorString) { |
34 if(highlightedElementsSelector) | 131 unhighlightElements(); |
35 unhighlightElements(); | |
36 | 132 |
37 var highlightedElements = document.querySelectorAll(selectorString); | 133 var highlightedElements = document.querySelectorAll(selectorString); |
38 highlightedElementsSelector = selectorString; | 134 highlightedElementsSelector = selectorString; |
39 highlightedElementsBoxShadows = new Array(); | 135 |
40 highlightedElementsBGColors = new Array(); | 136 for(var i = 0; i < highlightedElements.length; i++) |
41 | 137 highlightElement(highlightedElements[i], "#fd6738", "#f6e1e5"); |
42 for(var i = 0; i < highlightedElements.length; i++) { | |
43 highlightedElementsBoxShadows[i] = highlightedElements[i].style.getPropertyV alue("-webkit-box-shadow"); | |
44 highlightedElementsBGColors[i] = highlightedElements[i].style.backgroundColo r; | |
45 highlightedElements[i].style.setProperty("-webkit-box-shadow", "inset 0px 0p x 5px #fd6738"); | |
46 highlightedElements[i].style.backgroundColor = "#f6e1e5"; | |
47 } | |
48 } | 138 } |
49 | 139 |
50 // Unhighlight all elements, including those that would be affected by | 140 // Unhighlight all elements, including those that would be affected by |
51 // the proposed filters | 141 // the proposed filters |
52 function unhighlightElements() { | 142 function unhighlightElements() { |
53 if(highlightedElementsSelector == null) | 143 if (highlightedElementsSelector) |
54 return; | 144 { |
55 var highlightedElements = document.querySelectorAll(highlightedElementsSelecto r); | 145 Array.prototype.forEach.call( |
56 for(var i = 0; i < highlightedElements.length; i++) { | 146 document.querySelectorAll(highlightedElementsSelector), |
57 highlightedElements[i].style.setProperty("-webkit-box-shadow", highlightedEl ementsBoxShadows[i]); | 147 unhighlightElement |
58 highlightedElements[i].style.backgroundColor = highlightedElementsBGColors[i ]; | 148 ); |
59 } | 149 |
60 highlightedElementsSelector = null; | 150 highlightedElementsSelector = null; |
151 } | |
61 } | 152 } |
62 | 153 |
63 // Gets the absolute position of an element by walking up the DOM tree, | 154 // Gets the absolute position of an element by walking up the DOM tree, |
64 // adding up offsets. | 155 // adding up offsets. |
65 // I hope there's a better way because it just seems absolutely stupid | 156 // I hope there's a better way because it just seems absolutely stupid |
66 // that the DOM wouldn't have a direct way to get this, given that it | 157 // that the DOM wouldn't have a direct way to get this, given that it |
67 // has hundreds and hundreds of other methods that do random junk. | 158 // has hundreds and hundreds of other methods that do random junk. |
68 function getAbsolutePosition(elt) { | 159 function getAbsolutePosition(elt) { |
69 var l = 0; | 160 var l = 0; |
70 var t = 0; | 161 var t = 0; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
176 { | 267 { |
177 if (clickHideFiltersDialog) | 268 if (clickHideFiltersDialog) |
178 { | 269 { |
179 document.body.removeChild(clickHideFiltersDialog); | 270 document.body.removeChild(clickHideFiltersDialog); |
180 clickHideFiltersDialog = null; | 271 clickHideFiltersDialog = null; |
181 } | 272 } |
182 | 273 |
183 if(currentElement) { | 274 if(currentElement) { |
184 currentElement.removeEventListener("contextmenu", clickHide_elementClickHand ler, false); | 275 currentElement.removeEventListener("contextmenu", clickHide_elementClickHand ler, false); |
185 unhighlightElements(); | 276 unhighlightElements(); |
186 currentElement.style.setProperty("-webkit-box-shadow", currentElement_boxSha dow); | 277 unhighlightElement(currentElement); |
187 currentElement.style.backgroundColor = currentElement_backgroundColor; | |
188 currentElement = null; | 278 currentElement = null; |
189 clickHideFilters = null; | 279 clickHideFilters = null; |
190 } | 280 } |
191 unhighlightElements(); | 281 unhighlightElements(); |
192 | 282 |
193 clickHide_activated = false; | 283 clickHide_activated = false; |
194 clickHide_filters = null; | 284 clickHide_filters = null; |
195 if(!document) | 285 if(!document) |
196 return; // This can happen inside a nuked iframe...I think | 286 return; // This can happen inside a nuked iframe...I think |
197 document.removeEventListener("mouseover", clickHide_mouseOver, false); | 287 document.removeEventListener("mouseover", clickHide_mouseOver, false); |
(...skipping 14 matching lines...) Expand all Loading... | |
212 clickHide_mouseClick(ev); | 302 clickHide_mouseClick(ev); |
213 } | 303 } |
214 | 304 |
215 // Hovering over an element so highlight it | 305 // Hovering over an element so highlight it |
216 function clickHide_mouseOver(e) | 306 function clickHide_mouseOver(e) |
217 { | 307 { |
218 if (clickHide_activated == false) | 308 if (clickHide_activated == false) |
219 return; | 309 return; |
220 | 310 |
221 var target = e.target; | 311 var target = e.target; |
222 while (target.parentNode && !(target.id || target.className || target.src || / :.+:/.test(target.getAttribute("style")))) | 312 while (target.parentNode && !(target.id || target.className || target.src)) |
223 target = target.parentNode; | 313 target = target.parentNode; |
224 if (target == document.documentElement || target == document.body) | 314 if (target == document.documentElement || target == document.body) |
225 target = null; | 315 target = null; |
226 | 316 |
227 if (target && target instanceof HTMLElement) | 317 if (target && target instanceof HTMLElement) |
228 { | 318 { |
229 currentElement = target; | 319 currentElement = target; |
230 currentElement_boxShadow = target.style.getPropertyValue("-webkit-box-shadow "); | 320 |
231 currentElement_backgroundColor = target.style.backgroundColor; | 321 highlightElement(target, "#d6d84b", "#f8fa47"); |
232 target.style.setProperty("-webkit-box-shadow", "inset 0px 0px 5px #d6d84b"); | |
233 target.style.backgroundColor = "#f8fa47"; | |
234 | |
235 target.addEventListener("contextmenu", clickHide_elementClickHandler, false) ; | 322 target.addEventListener("contextmenu", clickHide_elementClickHandler, false) ; |
236 } | 323 } |
237 } | 324 } |
238 | 325 |
239 // No longer hovering over this element so unhighlight it | 326 // No longer hovering over this element so unhighlight it |
240 function clickHide_mouseOut(e) | 327 function clickHide_mouseOut(e) |
241 { | 328 { |
242 if (!clickHide_activated || !currentElement) | 329 if (!clickHide_activated || !currentElement) |
243 return; | 330 return; |
244 | 331 |
245 currentElement.style.setProperty("-webkit-box-shadow", currentElement_boxShado w); | 332 unhighlightElement(currentElement); |
246 currentElement.style.backgroundColor = currentElement_backgroundColor; | |
247 | |
248 currentElement.removeEventListener("contextmenu", clickHide_elementClickHandle r, false); | 333 currentElement.removeEventListener("contextmenu", clickHide_elementClickHandle r, false); |
249 } | 334 } |
250 | 335 |
251 // Selects the currently hovered-over filter or cancels selection | 336 // Selects the currently hovered-over filter or cancels selection |
252 function clickHide_keyDown(e) | 337 function clickHide_keyDown(e) |
253 { | 338 { |
254 if (!e.ctrlKey && !e.altKey && !e.shiftKey && e.keyCode == 13 /*DOM_VK_RETURN* /) | 339 if (!e.ctrlKey && !e.altKey && !e.shiftKey && e.keyCode == 13 /*DOM_VK_RETURN* /) |
255 clickHide_mouseClick(e); | 340 clickHide_mouseClick(e); |
256 else if (!e.ctrlKey && !e.altKey && !e.shiftKey && e.keyCode == 27 /*DOM_VK_ES CAPE*/) | 341 else if (!e.ctrlKey && !e.altKey && !e.shiftKey && e.keyCode == 27 /*DOM_VK_ES CAPE*/) |
257 { | 342 { |
(...skipping 24 matching lines...) Expand all Loading... | |
282 // Construct filters. The popup will retrieve these. | 367 // Construct filters. The popup will retrieve these. |
283 // Only one ID | 368 // Only one ID |
284 var elementId = elt.id ? elt.id.split(' ').join('') : null; | 369 var elementId = elt.id ? elt.id.split(' ').join('') : null; |
285 // Can have multiple classes, and there might be extraneous whitespace | 370 // Can have multiple classes, and there might be extraneous whitespace |
286 var elementClasses = null; | 371 var elementClasses = null; |
287 if (elt.className) | 372 if (elt.className) |
288 elementClasses = elt.className.replace(/\s+/g, ' ').replace(/^\s+|\s+$/g, '' ).split(' '); | 373 elementClasses = elt.className.replace(/\s+/g, ' ').replace(/^\s+|\s+$/g, '' ).split(' '); |
289 | 374 |
290 clickHideFilters = new Array(); | 375 clickHideFilters = new Array(); |
291 selectorList = new Array(); | 376 selectorList = new Array(); |
292 | 377 if (elementId) |
293 var addSelector = function(selector) | 378 { |
294 { | 379 clickHideFilters.push(document.domain + "###" + elementId); |
380 selectorList.push("#" + elementId); | |
381 } | |
382 if (elementClasses && elementClasses.length > 0) | |
383 { | |
384 var selector = elementClasses.map(function(elClass) | |
385 { | |
386 return "." + elClass.replace(/([^\w-])/, "\\$1"); | |
387 }).join(""); | |
388 | |
295 clickHideFilters.push(document.domain + "##" + selector); | 389 clickHideFilters.push(document.domain + "##" + selector); |
296 selectorList.push(selector); | 390 selectorList.push(selector); |
297 }; | 391 } |
298 | |
299 if (elementId) | |
300 addSelector("#" + elementId); | |
301 | |
302 if (elt.classList.length > 0) | |
303 { | |
304 var selector = ""; | |
305 | |
306 for (var i = 0; i < elt.classList.length; i++) | |
307 selector += "." + elt.classList[i].replace(/([^\w-])/g, "\\$1"); | |
308 | |
309 addSelector(selector); | |
310 } | |
311 | |
312 if (url) | 392 if (url) |
313 { | 393 { |
314 url = relativeToAbsoluteUrl(url); | 394 clickHideFilters.push(url.replace(/^[\w\-]+:\/+(?:www\.)?/, "||")); |
315 | 395 selectorList.push('[src="' + elt.getAttribute("src") + '"]'); |
316 clickHideFilters.push(normalizeURL(url)); | 396 } |
Wladimir Palant
2014/06/27 07:30:53
I wonder what will happen to src="about:blank" or
Sebastian Noack
2014/06/28 09:42:50
See http://codereview.adblockplus.org/594587757104
| |
317 selectorList.push(elt.localName + '[src="' + url + '"]'); | |
Wladimir Palant
2014/06/27 07:30:53
Just noticed - this one won't work correctly, it n
Sebastian Noack
2014/06/28 09:42:50
Done.
| |
318 } | |
319 | |
320 // restore the original style, before generating the fallback filter that | |
321 // will include the style, and to prevent highlightElements from saving those | |
322 currentElement.style.setProperty("-webkit-box-shadow", currentElement_boxShado w); | |
323 currentElement.style.backgroundColor = currentElement_backgroundColor; | |
324 | |
325 // as last resort, create a filter based on inline styles | |
326 if (clickHideFilters.length == 0 && elt.hasAttribute("style")) | |
327 addSelector(elt.localName + '[style="' + elt.getAttribute("style").replace(/ "/g, '\\"') + '"]'); | |
328 | 397 |
329 // Show popup | 398 // Show popup |
330 clickHide_showDialog(e.clientX, e.clientY, clickHideFilters); | 399 clickHide_showDialog(e.clientX, e.clientY, clickHideFilters); |
331 | 400 |
401 // Highlight the unlucky elements | |
402 // Restore currentElement's box-shadow and bgcolor so that highlightElements w on't save those | |
403 unhighlightElement(currentElement); | |
332 // Highlight the elements specified by selector in yellow | 404 // Highlight the elements specified by selector in yellow |
333 highlightElements(selectorList.join(",")); | 405 highlightElements(selectorList.join(",")); |
334 // Now, actually highlight the element the user clicked on in red | 406 // Now, actually highlight the element the user clicked on in red |
335 currentElement.style.setProperty("-webkit-box-shadow", "inset 0px 0px 5px #fd1 708"); | 407 highlightElement(currentElement, "#fd1708", "#f6a1b5"); |
336 currentElement.style.backgroundColor = "#f6a1b5"; | |
337 | 408 |
338 // Make sure the browser doesn't handle this click | 409 // Make sure the browser doesn't handle this click |
339 e.preventDefault(); | 410 e.preventDefault(); |
340 e.stopPropagation(); | 411 e.stopPropagation(); |
341 } | 412 } |
342 | 413 |
343 // Extracts source URL from an IMG, OBJECT, EMBED, or IFRAME | 414 // Extracts source URL from an IMG, OBJECT, EMBED, or IFRAME |
344 function getElementURL(elt) { | 415 function getElementURL(elt) { |
345 // Check children of object nodes for "param" nodes with name="movie" that spe cify a URL | 416 // Check children of object nodes for "param" nodes with name="movie" that spe cify a URL |
346 // in value attribute | 417 // in value attribute |
347 var url; | 418 var url; |
348 if(elt.localName.toUpperCase() == "OBJECT" && !(url = elt.getAttribute("data") )) { | 419 if(elt.localName.toUpperCase() == "OBJECT" && !(url = elt.getAttribute("data") )) { |
349 // No data attribute, look in PARAM child tags for a URL for the swf file | 420 // No data attribute, look in PARAM child tags for a URL for the swf file |
350 var params = elt.querySelectorAll("param[name=\"movie\"]"); | 421 var params = elt.querySelectorAll("param[name=\"movie\"]"); |
351 // This OBJECT could contain an EMBED we already nuked, in which case there' s no URL | 422 // This OBJECT could contain an EMBED we already nuked, in which case there' s no URL |
352 if(params[0]) | 423 if(params[0]) |
353 url = params[0].getAttribute("value"); | 424 url = params[0].getAttribute("value"); |
354 else { | 425 else { |
355 params = elt.querySelectorAll("param[name=\"src\"]"); | 426 params = elt.querySelectorAll("param[name=\"src\"]"); |
356 if(params[0]) | 427 if(params[0]) |
357 url = params[0].getAttribute("value"); | 428 url = params[0].getAttribute("value"); |
358 } | 429 } |
430 | |
431 if (url) | |
432 url = resolveURL(url); | |
359 } else if(!url) { | 433 } else if(!url) { |
360 url = elt.getAttribute("src") || elt.getAttribute("href"); | 434 url = elt.src || elt.href; |
361 } | 435 } |
362 return url; | 436 return url; |
363 } | 437 } |
364 | 438 |
365 // This function Copyright (c) 2008 Jeni Tennison, from jquery.uri.js | 439 // This function Copyright (c) 2008 Jeni Tennison, from jquery.uri.js |
366 // and licensed under the MIT license. See jquery-*.min.js for details. | 440 // and licensed under the MIT license. See jquery-*.min.js for details. |
367 function removeDotSegments(u) { | 441 function removeDotSegments(u) { |
368 var r = '', m = []; | 442 var r = '', m = []; |
369 if (/\./.test(u)) { | 443 if (/\./.test(u)) { |
370 while (u !== undefined && u !== '') { | 444 while (u !== undefined && u !== '') { |
(...skipping 13 matching lines...) Expand all Loading... | |
384 u = m[2]; | 458 u = m[2]; |
385 r = r + m[1]; | 459 r = r + m[1]; |
386 } | 460 } |
387 } | 461 } |
388 return r; | 462 return r; |
389 } else { | 463 } else { |
390 return u; | 464 return u; |
391 } | 465 } |
392 } | 466 } |
393 | 467 |
394 // Does some degree of URL normalization | 468 if (document instanceof HTMLDocument) |
395 function normalizeURL(url) | |
396 { | |
397 var components = url.match(/(.+:\/\/)(.+?)\/(.*)/); | |
Wladimir Palant
2014/06/27 07:30:53
We should really start using the URI class from ba
Sebastian Noack
2014/06/28 09:42:50
Any reasons why we "normalize" the URL in the firs
Sebastian Noack
2014/09/25 08:36:25
As discussed in http://codereview.adblockplus.org/
| |
398 if(!components) | |
399 return url; | |
400 var newPath = removeDotSegments(components[3]); | |
401 if(newPath != '' && newPath[0] != '/') | |
Wladimir Palant
2014/06/27 07:30:53
It should actually be: newPath == "" || newPath[0]
Sebastian Noack
2014/06/28 09:42:50
Then you can just check for newPath[0] != "/" with
| |
402 newPath = '/' + newPath; | |
403 return '||' + components[2] + newPath; | |
404 } | |
405 | |
406 // Content scripts are apparently invoked on non-HTML documents, so we have to | |
407 // check for that before doing stuff. |document instanceof HTMLDocument| check | |
408 // will fail on some sites like planet.mozilla.org because WebKit creates | |
409 // Document instances for XHTML documents, have to test the root element. | |
410 if (document.documentElement instanceof HTMLElement) | |
411 { | 469 { |
412 // Use a contextmenu handler to save the last element the user right-clicked o n. | 470 // Use a contextmenu handler to save the last element the user right-clicked o n. |
413 // To make things easier, we actually save the DOM event. | 471 // To make things easier, we actually save the DOM event. |
414 // We have to do this because the contextMenu API only provides a URL, not the actual | 472 // We have to do this because the contextMenu API only provides a URL, not the actual |
415 // DOM element. | 473 // DOM element. |
416 document.addEventListener('contextmenu', function(e) { | 474 document.addEventListener('contextmenu', function(e) { |
417 lastRightClickEvent = e; | 475 lastRightClickEvent = e; |
418 }, false); | 476 }, false); |
419 | 477 |
420 document.addEventListener("click", function(event) | 478 document.addEventListener("click", function(event) |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
524 if(msg.filter === url) | 582 if(msg.filter === url) |
525 { | 583 { |
526 // This request would have come from the chrome.contextMenu handler, s o we | 584 // This request would have come from the chrome.contextMenu handler, s o we |
527 // simulate the user having chosen the element to get rid of via the u sual means. | 585 // simulate the user having chosen the element to get rid of via the u sual means. |
528 clickHide_activated = true; | 586 clickHide_activated = true; |
529 // FIXME: clickHideFilters is erased in clickHide_mouseClick anyway, s o why set it? | 587 // FIXME: clickHideFilters is erased in clickHide_mouseClick anyway, s o why set it? |
530 clickHideFilters = [msg.filter]; | 588 clickHideFilters = [msg.filter]; |
531 // Coerce red highlighted overlay on top of element to remove. | 589 // Coerce red highlighted overlay on top of element to remove. |
532 // TODO: Wow, the design of the clickHide stuff is really dumb - gotta fix it sometime | 590 // TODO: Wow, the design of the clickHide stuff is really dumb - gotta fix it sometime |
533 currentElement = addElementOverlay(target); | 591 currentElement = addElementOverlay(target); |
534 currentElement_backgroundColor = target.style.backgroundColor; | |
535 // clickHide_mouseOver(lastRightClickEvent); | 592 // clickHide_mouseOver(lastRightClickEvent); |
536 clickHide_mouseClick(lastRightClickEvent); | 593 clickHide_mouseClick(lastRightClickEvent); |
537 } | 594 } |
538 else | 595 else |
539 console.log("clickhide-new-filter: URLs don't match. Couldn't find tha t element.", request.filter, url, lastRightClickEvent.target.src); | 596 console.log("clickhide-new-filter: URLs don't match. Couldn't find tha t element.", request.filter, url, lastRightClickEvent.target.src); |
540 break; | 597 break; |
541 case "clickhide-init": | 598 case "clickhide-init": |
542 if (clickHideFiltersDialog) | 599 if (clickHideFiltersDialog) |
543 { | 600 { |
544 sendResponse({filters: clickHide_filters}); | 601 sendResponse({filters: clickHide_filters}); |
(...skipping 18 matching lines...) Expand all Loading... | |
563 currentElement.parentNode.removeChild(currentElement); | 620 currentElement.parentNode.removeChild(currentElement); |
564 | 621 |
565 clickHide_deactivate(); | 622 clickHide_deactivate(); |
566 } | 623 } |
567 break; | 624 break; |
568 default: | 625 default: |
569 sendResponse({}); | 626 sendResponse({}); |
570 break; | 627 break; |
571 } | 628 } |
572 }); | 629 }); |
573 } | 630 |
631 if (window == window.top) | |
632 ext.backgroundPage.sendMessage({type: "report-html-page"}); | |
633 } | |
LEFT | RIGHT |