| 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 10 matching lines...) Expand all Loading... | |
| 21 "img": "IMAGE", | 21 "img": "IMAGE", |
| 22 "input": "IMAGE", | 22 "input": "IMAGE", |
| 23 "audio": "MEDIA", | 23 "audio": "MEDIA", |
| 24 "video": "MEDIA", | 24 "video": "MEDIA", |
| 25 "frame": "SUBDOCUMENT", | 25 "frame": "SUBDOCUMENT", |
| 26 "iframe": "SUBDOCUMENT" | 26 "iframe": "SUBDOCUMENT" |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 function checkCollapse(element) | 29 function checkCollapse(element) |
| 30 { | 30 { |
| 31 // <input type="image"> elements try to load their image again | |
| 32 // when the "display" CSS property is changed by the | |
| 33 // collapsing code below. So we have to bail out, if collapsing | |
| 34 // is already in progress, to avoid an infinite recursion. | |
| 35 if (element._collapsing) | |
| 36 return; | |
|
Wladimir Palant
2014/09/24 14:57:00
Interesting, a load triggered for an element with
Thomas Greiner
2014/09/24 15:08:29
That's what I checked before and it does have the
Sebastian Noack
2014/09/24 16:42:40
The only thing the standard defines for that parti
Sebastian Noack
2014/09/24 17:04:58
Done, though it wasn't actually that simply. I als
| |
| 37 | |
| 38 var tag = element.localName; | 31 var tag = element.localName; |
| 39 if (tag in typeMap) | 32 if (tag in typeMap) |
| 40 { | 33 { |
| 41 // This element failed loading, did we block it? | 34 // This element failed loading, did we block it? |
| 42 var url = element.src; | 35 var url = element.src; |
| 43 if (!url) | 36 if (!url) |
| 44 return; | 37 return; |
| 45 | 38 |
| 46 ext.backgroundPage.sendMessage( | 39 ext.backgroundPage.sendMessage( |
| 47 { | 40 { |
| 48 type: "should-collapse", | 41 type: "should-collapse", |
| 49 url: url, | 42 url: url, |
| 50 mediatype: typeMap[tag] | 43 mediatype: typeMap[tag] |
| 51 }, | 44 }, |
| 52 | 45 |
| 53 function(response) | 46 function(response) |
| 54 { | 47 { |
| 55 if (response && element.parentNode) | 48 if (response && element.parentNode) |
| 56 { | 49 { |
| 57 element._collapsing = true; | 50 var property = "display"; |
|
Thomas Greiner
2014/09/24 12:35:32
This makes us quite easily distinguishable from ot
Sebastian Noack
2014/09/24 12:50:09
No, it doesn't. Content scripts run in a different
Thomas Greiner
2014/09/24 14:14:54
I can confirm that custom properties are not part
| |
| 51 var value = "none"; | |
| 58 | 52 |
| 59 // <frame> cannot be removed, doing that will mess up the frameset | 53 // <frame> cannot be removed, doing that will mess up the frameset |
| 60 if (tag == "frame") | 54 if (tag == "frame") |
| 61 element.style.setProperty("visibility", "hidden", "important"); | 55 { |
| 62 else | 56 property = "visibility"; |
| 63 element.style.setProperty("display", "none", "important"); | 57 value = "hidden"; |
| 58 } | |
| 59 | |
| 60 // <input type="image"> elements try to load their image again | |
| 61 // when the "display" CSS property is set. So we have to check | |
| 62 // that it isn't already collapsed to avoid an infinite recursion. | |
| 63 if (element.style.getPropertyValue(property) != value || | |
| 64 element.style.getPropertyPriority(property) != "important") | |
| 65 element.style.setProperty(property, value, "important"); | |
| 64 } | 66 } |
| 65 } | 67 } |
| 66 ); | 68 ); |
| 67 } | 69 } |
| 68 } | 70 } |
| 69 | 71 |
| 70 function checkSitekey() | 72 function checkSitekey() |
| 71 { | 73 { |
| 72 var attr = document.documentElement.getAttribute("data-adblockkey"); | 74 var attr = document.documentElement.getAttribute("data-adblockkey"); |
| 73 if (attr) | 75 if (attr) |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 }, true); | 210 }, true); |
| 209 | 211 |
| 210 ext.backgroundPage.sendMessage({type: "get-selectors"}, setElemhideCSSRules); | 212 ext.backgroundPage.sendMessage({type: "get-selectors"}, setElemhideCSSRules); |
| 211 } | 213 } |
| 212 | 214 |
| 213 if (document instanceof HTMLDocument) | 215 if (document instanceof HTMLDocument) |
| 214 { | 216 { |
| 215 checkSitekey(); | 217 checkSitekey(); |
| 216 init(document); | 218 init(document); |
| 217 } | 219 } |
| LEFT | RIGHT |