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 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 // author created shadow roots, but ignore insertion points. | 69 // author created shadow roots, but ignore insertion points. |
70 var child = document.createTextNode(""); | 70 var child = document.createTextNode(""); |
71 clone.appendChild(child); | 71 clone.appendChild(child); |
72 | 72 |
73 var shadow = document.createElement("shadow"); | 73 var shadow = document.createElement("shadow"); |
74 clone.shadowRoot.appendChild(shadow); | 74 clone.shadowRoot.appendChild(shadow); |
75 | 75 |
76 return shadow.getDistributedNodes()[0] == child; | 76 return shadow.getDistributedNodes()[0] == child; |
77 } | 77 } |
78 | 78 |
79 function getOriginalStyle(element) | |
80 { | |
81 if ("_originalStyle" in element) | |
82 return element._originalStyle; | |
83 | |
84 return element.getAttribute("style"); | |
85 } | |
86 | |
79 function highlightElement(element, shadowColor, backgroundColor) | 87 function highlightElement(element, shadowColor, backgroundColor) |
80 { | 88 { |
81 unhighlightElement(element); | 89 unhighlightElement(element); |
82 | 90 |
83 var originalBoxShadowPriority = element.style.getPropertyPriority("box-shadow" ); | 91 var originalBoxShadowPriority = element.style.getPropertyPriority("box-shadow" ); |
84 var originalBackgroundColorPriority = element.style.getPropertyPriority("backg round-color"); | 92 var originalBackgroundColorPriority = element.style.getPropertyPriority("backg round-color"); |
85 | 93 |
86 var boxShadow = "inset 0px 0px 5px " + shadowColor; | 94 var boxShadow = "inset 0px 0px 5px " + shadowColor; |
87 | 95 |
88 var highlightWithShadowDOM = function() | 96 var highlightWithShadowDOM = function() |
(...skipping 11 matching lines...) Expand all Loading... | |
100 element._unhighlight = function() | 108 element._unhighlight = function() |
101 { | 109 { |
102 root.removeChild(style); | 110 root.removeChild(style); |
103 }; | 111 }; |
104 }; | 112 }; |
105 | 113 |
106 var highlightWithStyleAttribute = function() | 114 var highlightWithStyleAttribute = function() |
107 { | 115 { |
108 var originalBoxShadow = element.style.getPropertyValue("box-shadow"); | 116 var originalBoxShadow = element.style.getPropertyValue("box-shadow"); |
109 var originalBackgroundColor = element.style.getPropertyValue("background-col or"); | 117 var originalBackgroundColor = element.style.getPropertyValue("background-col or"); |
118 | |
119 element._originalStyle = getOriginalStyle(element); | |
110 | 120 |
111 element.style.setProperty("box-shadow", boxShadow, "important"); | 121 element.style.setProperty("box-shadow", boxShadow, "important"); |
112 element.style.setProperty("background-color", backgroundColor, "important"); | 122 element.style.setProperty("background-color", backgroundColor, "important"); |
113 | 123 |
114 element._unhighlight = function() | 124 element._unhighlight = function() |
115 { | 125 { |
116 this.style.removeProperty("box-shadow"); | 126 this.style.removeProperty("box-shadow"); |
117 this.style.setProperty( | 127 this.style.setProperty( |
118 "box-shadow", | 128 "box-shadow", |
119 originalBoxShadow, | 129 originalBoxShadow, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 { | 178 { |
169 Array.prototype.forEach.call( | 179 Array.prototype.forEach.call( |
170 document.querySelectorAll(highlightedElementsSelector), | 180 document.querySelectorAll(highlightedElementsSelector), |
171 unhighlightElement | 181 unhighlightElement |
172 ); | 182 ); |
173 | 183 |
174 highlightedElementsSelector = null; | 184 highlightedElementsSelector = null; |
175 } | 185 } |
176 } | 186 } |
177 | 187 |
178 function getElementURLs(element) { | 188 function getURLsFromObjectElement(element) |
189 { | |
190 var url = element.getAttribute("data"); | |
191 if (url) | |
192 return [resolveURL(url)]; | |
193 | |
194 for (var i = 0; i < element.children.length; i++) | |
195 { | |
196 var child = element.children[i]; | |
197 if (child.localName != "param") | |
198 continue; | |
199 | |
200 var name = child.getAttribute("name"); | |
201 if (name != "movie" && // Adobe Flash | |
202 name != "source" && // Silverlight | |
203 name != "src" && // Real Media + Quicktime | |
204 name != "FileName") // Windows Media | |
205 continue; | |
206 | |
207 var value = child.getAttribute("value"); | |
208 if (!value) | |
209 continue; | |
210 | |
211 return [resolveURL(value)]; | |
212 } | |
213 | |
214 return []; | |
215 } | |
216 | |
217 function getURLsFromAttributes(element) | |
218 { | |
179 var urls = []; | 219 var urls = []; |
180 | 220 |
181 if (element.src) | 221 if (element.src) |
182 urls.push(element.src); | 222 urls.push(element.src); |
183 | 223 |
224 if (element.srcset) | |
225 { | |
226 var candidates = element.srcset.split(","); | |
227 for (var i = 0; i < candidates.length; i++) | |
228 { | |
229 var url = candidates[i].trim().replace(/\s+\S+$/, ""); | |
230 if (url) | |
231 urls.push(resolveURL(url)); | |
232 } | |
233 } | |
234 | |
235 return urls; | |
236 } | |
237 | |
238 function getURLsFromMediaElement(element) | |
239 { | |
240 var urls = getURLsFromAttributes(element); | |
241 | |
242 for (var i = 0; i < element.children.length; i++) | |
243 { | |
244 var child = element.children[i]; | |
245 if (child.localName == "source" || child.localName == "track") | |
246 urls.push.apply(urls, getURLsFromAttributes(child)); | |
247 } | |
248 | |
249 if (element.poster) | |
250 urls.push(element.poster); | |
251 | |
252 return urls; | |
253 } | |
254 | |
255 function getURLsFromElement(element) { | |
184 switch (element.localName) | 256 switch (element.localName) |
185 { | 257 { |
186 case "object": | 258 case "object": |
187 var url = element.getAttribute("data"); | 259 return getURLsFromObjectElement(element); |
Wladimir Palant
2014/12/08 11:43:00
For reference: <object> also has archive and codeb
Sebastian Noack
2014/12/08 16:45:04
I agree, also note they are obsolete since HTML5,
Wladimir Palant
2014/12/08 20:31:09
Oh, you didn't have to deal with Java? :)
Sebastian Noack
2014/12/08 21:12:49
I see, that stuff is for Java. I prefer to ignore
| |
188 if (url) | |
189 return [resolveURL(url)]; | |
190 | |
191 for (var i = 0; i < element.children.length; i++) | |
192 { | |
193 var child = element.children[i]; | |
194 if (child.localName != "param") | |
195 continue; | |
196 | |
197 var name = child.getAttribute("name"); | |
198 if (name != "movie" && name != "src") | |
199 continue; | |
200 | |
201 var value = child.getAttribute("value"); | |
202 if (!value) | |
203 continue; | |
204 | |
205 return [resolveURL(value)]; | |
206 } | |
207 | |
208 return []; | |
209 | 260 |
210 case "video": | 261 case "video": |
211 case "audio": | 262 case "audio": |
212 case "picture": | 263 case "picture": |
213 for (var i = 0; i < element.children.length; i++) | 264 return getURLsFromMediaElement(element); |
214 { | 265 } |
215 var child = element.children[i]; | 266 |
216 | 267 return getURLsFromAttributes(element); |
217 if (child.localName != "source") | |
218 continue; | |
Wladimir Palant
2014/12/08 11:43:00
It seems that we need to handle <track> elements a
Sebastian Noack
2014/12/08 16:45:04
Done.
| |
219 | |
220 if (child.src) | |
221 urls.push(child.src); | |
222 | |
223 urls = urls.concat(parseSrcSet(child)); | |
Wladimir Palant
2014/12/08 11:43:00
Rather than generate a new array, I'd prefer:
url
Sebastian Noack
2014/12/08 16:45:04
Right, I forgot that push() can add multiple items
| |
224 } | |
225 | |
226 if (element.poster) | |
227 urls.push(element.poster); | |
228 | |
229 break; | |
230 | |
231 case "img": | |
232 urls = urls.concat(parseSrcSet(element)); | |
233 } | |
234 | |
235 return urls; | |
236 } | 268 } |
237 | 269 |
238 function isBlockable(element) | 270 function isBlockable(element) |
239 { | 271 { |
240 if (element.id) | 272 if (element.id) |
241 return true; | 273 return true; |
242 if (element.classList.length > 0) | 274 if (element.classList.length > 0) |
243 return true; | 275 return true; |
244 if (getElementURLs(element).length > 0) | 276 if (getURLsFromElement(element).length > 0) |
245 return true; | 277 return true; |
246 | 278 |
247 // We only generate filters based on the "style" attribute, | 279 // We only generate filters based on the "style" attribute, |
248 // if this is the only way we can generate a filter, and | 280 // if this is the only way we can generate a filter, and |
249 // only if there are at least two CSS properties defined. | 281 // only if there are at least two CSS properties defined. |
250 if (/:.+:/.test(element.getAttribute("style"))) | 282 if (/:.+:/.test(getOriginalStyle(element))) |
251 return true; | 283 return true; |
252 | 284 |
253 return false; | 285 return false; |
254 } | 286 } |
255 | 287 |
256 // Gets the absolute position of an element by walking up the DOM tree, | 288 // Gets the absolute position of an element by walking up the DOM tree, |
257 // adding up offsets. | 289 // adding up offsets. |
258 // I hope there's a better way because it just seems absolutely stupid | 290 // I hope there's a better way because it just seems absolutely stupid |
259 // that the DOM wouldn't have a direct way to get this, given that it | 291 // that the DOM wouldn't have a direct way to get this, given that it |
260 // has hundreds and hundreds of other methods that do random junk. | 292 // has hundreds and hundreds of other methods that do random junk. |
(...skipping 12 matching lines...) Expand all Loading... | |
273 // If this element is enclosed in an object tag, we prefer to block that inste ad | 305 // If this element is enclosed in an object tag, we prefer to block that inste ad |
274 if(!elt) | 306 if(!elt) |
275 return null; | 307 return null; |
276 | 308 |
277 // If element doesn't have at least one of class name, ID or URL, give up | 309 // If element doesn't have at least one of class name, ID or URL, give up |
278 // because we don't know how to construct a filter rule for it | 310 // because we don't know how to construct a filter rule for it |
279 if(!isBlockable(elt)) | 311 if(!isBlockable(elt)) |
280 return; | 312 return; |
281 | 313 |
282 // If the element isn't rendered (since its or one of its ancestor's | 314 // If the element isn't rendered (since its or one of its ancestor's |
283 // "diplay" property is "none"), the overlay wouldn't match the element. | 315 // "display" property is "none"), the overlay wouldn't match the element. |
284 if (!elt.offsetParent) | 316 if (!elt.offsetParent) |
285 return; | 317 return; |
286 | 318 |
287 var thisStyle = getComputedStyle(elt, null); | 319 var thisStyle = getComputedStyle(elt, null); |
288 var overlay = document.createElement('div'); | 320 var overlay = document.createElement('div'); |
289 overlay.prisoner = elt; | 321 overlay.prisoner = elt; |
290 overlay.className = "__adblockplus__overlay"; | 322 overlay.className = "__adblockplus__overlay"; |
291 overlay.setAttribute('style', 'opacity:0.4; background-color:#ffffff; display: inline-box; ' + 'width:' + thisStyle.width + '; height:' + thisStyle.height + '; position:absolute; overflow:hidden; -webkit-box-sizing:border-box;'); | 323 overlay.setAttribute('style', 'opacity:0.4; background-color:#ffffff; display: inline-box; ' + 'width:' + thisStyle.width + '; height:' + thisStyle.height + '; position:absolute; overflow:hidden; -webkit-box-sizing:border-box;'); |
292 var pos = getAbsolutePosition(elt); | 324 var pos = getAbsolutePosition(elt); |
293 overlay.style.left = pos[0] + "px"; | 325 overlay.style.left = pos[0] + "px"; |
294 overlay.style.top = pos[1] + "px"; | 326 overlay.style.top = pos[1] + "px"; |
295 | 327 |
296 if (thisStyle.position != "static") | 328 if (thisStyle.position != "static") |
297 overlay.style.zIndex = thisStyle.zIndex; | 329 overlay.style.zIndex = thisStyle.zIndex; |
298 else | 330 else |
299 overlay.style.zIndex = getComputedStyle(elt.offsetParent).zIndex; | 331 overlay.style.zIndex = getComputedStyle(elt.offsetParent).zIndex; |
300 | 332 |
301 // elt.parentNode.appendChild(overlay, elt); | 333 // elt.parentNode.appendChild(overlay, elt); |
302 document.body.appendChild(overlay); | 334 document.body.appendChild(overlay); |
303 return overlay; | 335 return overlay; |
304 } | 336 } |
305 | 337 |
306 // Show dialog asking user whether she wants to add the proposed filters derived | 338 // Show dialog asking user whether she wants to add the proposed filters derived |
307 // from selected page element | 339 // from selected page element |
308 function clickHide_showDialog(left, top, filters) | 340 function clickHide_showDialog(left, top, filters) |
309 { | 341 { |
310 // If we are already selecting, abort now | 342 // If we are already selecting, abort now |
311 if (clickHide_activated || clickHideFiltersDialog) | 343 if (clickHide_activated || clickHideFiltersDialog) |
312 { | 344 clickHide_deactivate(true); |
313 var savedElement = (currentElement.prisoner ? currentElement.prisoner : curr entElement); | |
314 clickHide_deactivate(); | |
315 currentElement = savedElement; | |
316 } | |
317 | 345 |
318 clickHide_filters = filters; | 346 clickHide_filters = filters; |
319 | 347 |
320 clickHideFiltersDialog = document.createElement("iframe"); | 348 clickHideFiltersDialog = document.createElement("iframe"); |
321 clickHideFiltersDialog.src = ext.getURL("block.html"); | 349 clickHideFiltersDialog.src = ext.getURL("block.html"); |
322 clickHideFiltersDialog.setAttribute("style", "position: fixed !important; visi bility: hidden; display: block !important; border: 0px !important;"); | 350 clickHideFiltersDialog.setAttribute("style", "position: fixed !important; visi bility: hidden; display: block !important; border: 0px !important;"); |
323 clickHideFiltersDialog.style.WebkitBoxShadow = "5px 5px 20px rgba(0,0,0,0.5)"; | 351 clickHideFiltersDialog.style.WebkitBoxShadow = "5px 5px 20px rgba(0,0,0,0.5)"; |
324 clickHideFiltersDialog.style.zIndex = 0x7FFFFFFF; | 352 clickHideFiltersDialog.style.zIndex = 0x7FFFFFFF; |
325 | 353 |
326 // Position in upper-left all the time | 354 // Position in upper-left all the time |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 // on whether the user actually wants these filters | 396 // on whether the user actually wants these filters |
369 function clickHide_rulesPending() { | 397 function clickHide_rulesPending() { |
370 clickHide_activated = false; | 398 clickHide_activated = false; |
371 document.removeEventListener("mouseover", clickHide_mouseOver, true); | 399 document.removeEventListener("mouseover", clickHide_mouseOver, true); |
372 document.removeEventListener("mouseout", clickHide_mouseOut, true); | 400 document.removeEventListener("mouseout", clickHide_mouseOut, true); |
373 document.removeEventListener("click", clickHide_mouseClick, true); | 401 document.removeEventListener("click", clickHide_mouseClick, true); |
374 document.removeEventListener("keydown", clickHide_keyDown, true); | 402 document.removeEventListener("keydown", clickHide_keyDown, true); |
375 } | 403 } |
376 | 404 |
377 // Turn off click-to-hide | 405 // Turn off click-to-hide |
378 function clickHide_deactivate() | 406 function clickHide_deactivate(keepOverlays) |
379 { | 407 { |
380 if (clickHideFiltersDialog) | 408 if (clickHideFiltersDialog) |
381 { | 409 { |
382 document.body.removeChild(clickHideFiltersDialog); | 410 document.body.removeChild(clickHideFiltersDialog); |
383 clickHideFiltersDialog = null; | 411 clickHideFiltersDialog = null; |
384 } | 412 } |
385 | |
386 if(currentElement) { | |
387 currentElement.removeEventListener("contextmenu", clickHide_elementClickHand ler, true); | |
388 unhighlightElements(); | |
389 unhighlightElement(currentElement); | |
390 currentElement = null; | |
391 clickHideFilters = null; | |
392 } | |
393 unhighlightElements(); | |
394 | 413 |
395 clickHide_activated = false; | 414 clickHide_activated = false; |
396 clickHide_filters = null; | 415 clickHide_filters = null; |
397 if(!document) | 416 if(!document) |
398 return; // This can happen inside a nuked iframe...I think | 417 return; // This can happen inside a nuked iframe...I think |
399 document.removeEventListener("mouseover", clickHide_mouseOver, true); | 418 document.removeEventListener("mouseover", clickHide_mouseOver, true); |
400 document.removeEventListener("mouseout", clickHide_mouseOut, true); | 419 document.removeEventListener("mouseout", clickHide_mouseOut, true); |
401 document.removeEventListener("click", clickHide_mouseClick, true); | 420 document.removeEventListener("click", clickHide_mouseClick, true); |
402 document.removeEventListener("keydown", clickHide_keyDown, true); | 421 document.removeEventListener("keydown", clickHide_keyDown, true); |
403 | 422 |
404 // Remove overlays | 423 if (!keepOverlays) |
405 // For some reason iterating over the array returend by getElementsByClassName () doesn't work | 424 { |
406 var elt; | 425 if (currentElement) { |
407 while(elt = document.querySelector('.__adblockplus__overlay')) | 426 currentElement.removeEventListener("contextmenu", clickHide_elementClickH andler, true); |
408 elt.parentNode.removeChild(elt); | 427 unhighlightElements(); |
428 unhighlightElement(currentElement); | |
429 currentElement = null; | |
430 clickHideFilters = null; | |
431 } | |
432 unhighlightElements(); | |
433 | |
434 var overlays = document.getElementsByClassName("__adblockplus__overlay"); | |
435 while (overlays.length > 0) | |
436 overlays[0].parentNode.removeChild(overlays[0]); | |
437 } | |
409 } | 438 } |
410 | 439 |
411 function clickHide_elementClickHandler(ev) { | 440 function clickHide_elementClickHandler(ev) { |
412 ev.preventDefault(); | 441 ev.preventDefault(); |
413 ev.stopPropagation(); | 442 ev.stopPropagation(); |
414 clickHide_mouseClick(ev); | 443 clickHide_mouseClick(ev); |
415 } | 444 } |
416 | 445 |
417 // Hovering over an element so highlight it | 446 // Hovering over an element so highlight it |
418 function clickHide_mouseOver(e) | 447 function clickHide_mouseOver(e) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
495 if (elt.classList.length > 0) | 524 if (elt.classList.length > 0) |
496 { | 525 { |
497 var selector = ""; | 526 var selector = ""; |
498 | 527 |
499 for (var i = 0; i < elt.classList.length; i++) | 528 for (var i = 0; i < elt.classList.length; i++) |
500 selector += "." + escapeCSS(elt.classList[i]); | 529 selector += "." + escapeCSS(elt.classList[i]); |
501 | 530 |
502 addSelector(selector); | 531 addSelector(selector); |
503 } | 532 } |
504 | 533 |
505 var urls = getElementURLs(elt); | 534 var urls = getURLsFromElement(elt); |
506 for (var i = 0; i < urls.length; i++) | 535 for (var i = 0; i < urls.length; i++) |
507 { | 536 { |
508 var url = urls[i]; | 537 var url = urls[i]; |
509 | 538 |
Sebastian Noack
2014/11/26 14:01:22
A fair amount of complexity here, only came from g
| |
510 if (/^https?:/i.test(url)) | 539 if (/^https?:/i.test(url)) |
511 { | 540 { |
512 var filter = url.replace(/^[\w\-]+:\/+(?:www\.)?/, "||"); | 541 var filter = url.replace(/^[\w\-]+:\/+(?:www\.)?/, "||"); |
513 | 542 |
514 if (clickHideFilters.indexOf(filter) == -1) | 543 if (clickHideFilters.indexOf(filter) == -1) |
515 clickHideFilters.push(filter); | 544 clickHideFilters.push(filter); |
516 | 545 |
517 continue; | 546 continue; |
518 } | 547 } |
519 | 548 |
520 if (url == elt.src) | 549 if (url == elt.src) |
521 addSelector(escapeCSS(elt.localName) + '[src=' + quote(elt.getAttribute("s rc")) + ']'); | 550 addSelector(escapeCSS(elt.localName) + '[src=' + quote(elt.getAttribute("s rc")) + ']'); |
522 } | 551 } |
523 | 552 |
524 // restore the original style, before generating the fallback filter that | |
525 // will include the style, and to prevent highlightElements from saving those | |
526 unhighlightElement(currentElement); | |
527 | |
528 // as last resort, create a filter based on inline styles | 553 // as last resort, create a filter based on inline styles |
529 if (clickHideFilters.length == 0) | 554 if (clickHideFilters.length == 0) |
530 { | 555 { |
531 var style = elt.getAttribute("style"); | 556 var style = getOriginalStyle(elt); |
532 if (style) | 557 if (style) |
533 addSelector(escapeCSS(elt.localName) + '[style=' + quote(style) + ']'); | 558 addSelector(escapeCSS(elt.localName) + '[style=' + quote(style) + ']'); |
534 } | 559 } |
535 | 560 |
536 // Show popup | 561 // Show popup |
537 clickHide_showDialog(e.clientX, e.clientY, clickHideFilters); | 562 clickHide_showDialog(e.clientX, e.clientY, clickHideFilters); |
538 | 563 |
539 // Highlight the elements specified by selector in yellow | 564 // Highlight the elements specified by selector in yellow |
540 highlightElements(selectorList.join(",")); | 565 if (selectorList.length > 0) |
566 highlightElements(selectorList.join(",")); | |
541 // Now, actually highlight the element the user clicked on in red | 567 // Now, actually highlight the element the user clicked on in red |
542 highlightElement(currentElement, "#fd1708", "#f6a1b5"); | 568 highlightElement(currentElement, "#fd1708", "#f6a1b5"); |
543 | 569 |
544 // Make sure the browser doesn't handle this click | 570 // Make sure the browser doesn't handle this click |
545 e.preventDefault(); | 571 e.preventDefault(); |
546 e.stopPropagation(); | 572 e.stopPropagation(); |
547 } | |
548 | |
549 function parseSrcSet(element) | |
550 { | |
551 if (!element.srcset) | |
552 return []; | |
553 | |
554 var urls = element.srcset.split(","); | |
555 for (var i = 0; i < urls.length; i++) | |
556 { | |
557 var url = urls[i].replace(/^\s+/, "").replace(/(\s+\S+)?\s*$/, ""); | |
Wladimir Palant
2014/12/08 11:43:00
Use urls[i].trim()? According to http://kangax.git
Sebastian Noack
2014/12/08 16:45:04
Done.
| |
558 if (url) | |
559 urls[i] = resolveURL(url); | |
Wladimir Palant
2014/12/08 11:43:00
What about descriptions? See http://html5hub.com/s
Sebastian Noack
2014/12/08 16:45:04
Those are stripped by the regex above.
| |
560 else | |
561 urls.splice(i--, 1); | |
562 } | |
563 | |
564 return urls; | |
565 } | 573 } |
566 | 574 |
567 // This function Copyright (c) 2008 Jeni Tennison, from jquery.uri.js | 575 // This function Copyright (c) 2008 Jeni Tennison, from jquery.uri.js |
568 // and licensed under the MIT license. See jquery-*.min.js for details. | 576 // and licensed under the MIT license. See jquery-*.min.js for details. |
569 function removeDotSegments(u) { | 577 function removeDotSegments(u) { |
570 var r = '', m = []; | 578 var r = '', m = []; |
571 if (/\./.test(u)) { | 579 if (/\./.test(u)) { |
572 while (u !== undefined && u !== '') { | 580 while (u !== undefined && u !== '') { |
573 if (u === '.' || u === '..') { | 581 if (u === '.' || u === '..') { |
574 u = ''; | 582 u = ''; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
738 } | 746 } |
739 break; | 747 break; |
740 case "clickhide-move": | 748 case "clickhide-move": |
741 if (clickHideFiltersDialog) | 749 if (clickHideFiltersDialog) |
742 { | 750 { |
743 clickHideFiltersDialog.style.left = (parseInt(clickHideFiltersDialog.s tyle.left, 10) + msg.x) + "px"; | 751 clickHideFiltersDialog.style.left = (parseInt(clickHideFiltersDialog.s tyle.left, 10) + msg.x) + "px"; |
744 clickHideFiltersDialog.style.top = (parseInt(clickHideFiltersDialog.st yle.top, 10) + msg.y) + "px"; | 752 clickHideFiltersDialog.style.top = (parseInt(clickHideFiltersDialog.st yle.top, 10) + msg.y) + "px"; |
745 } | 753 } |
746 break; | 754 break; |
747 case "clickhide-close": | 755 case "clickhide-close": |
748 if (clickHideFiltersDialog) | 756 if (clickHideFiltersDialog && msg.remove) |
749 { | 757 { |
750 // Explicitly get rid of currentElement | 758 // Explicitly get rid of currentElement |
751 if (msg.remove && currentElement && currentElement.parentNode) | 759 var element = currentElement.prisoner || currentElement; |
752 currentElement.parentNode.removeChild(currentElement); | 760 if (element && element.parentNode) |
761 element.parentNode.removeChild(element); | |
753 } | 762 } |
754 clickHide_deactivate(); | 763 clickHide_deactivate(); |
755 break; | 764 break; |
756 default: | 765 default: |
757 sendResponse({}); | 766 sendResponse({}); |
758 break; | 767 break; |
759 } | 768 } |
760 }); | 769 }); |
761 | 770 |
762 if (window == window.top) | 771 if (window == window.top) |
763 ext.backgroundPage.sendMessage({type: "report-html-page"}); | 772 ext.backgroundPage.sendMessage({type: "report-html-page"}); |
764 } | 773 } |
LEFT | RIGHT |