| Index: include.preload.js |
| =================================================================== |
| --- a/include.preload.js |
| +++ b/include.preload.js |
| @@ -57,35 +57,43 @@ function setElemhideCSSRules(selectors) |
| setRules(); |
| } |
| var typeMap = { |
| "img": "IMAGE", |
| "input": "IMAGE", |
| "audio": "MEDIA", |
| "video": "MEDIA", |
| + "frame": "SUBDOCUMENT", |
| "iframe": "SUBDOCUMENT" |
| }; |
| function checkCollapse(event) |
| { |
| var target = event.target; |
| var tag = target.localName; |
| - if (tag in typeMap && event.type == (tag == "iframe" ? "load" : "error")) |
| + var expectedEvent = (tag == "iframe" || tag == "frame" ? "load" : "error"); |
| + if (tag in typeMap && event.type == expectedEvent) |
| { |
| // This element failed loading, did we block it? |
| var url = target.src; |
| if (!url) |
| return; |
| var type = typeMap[tag]; |
| chrome.extension.sendRequest({reqtype: "should-collapse", url: url, documentUrl: document.URL, type: type}, function(response) |
| { |
| if (response && target.parentNode) |
| - target.parentNode.removeChild(target); |
| + { |
| + // <frame> cannot be removed, doing that will mess up the frameset |
| + if (tag == "frame") |
| + target.style.setProperty("visibility", "hidden", "!important"); |
| + else |
| + target.parentNode.removeChild(target); |
| + } |
| }); |
| } |
| } |
| function init() |
| { |
| // Make sure this is really an HTML page, as Chrome runs these scripts on just about everything |
| if (!(document.documentElement instanceof HTMLElement)) |