| OLD | NEW |
| 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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 | 119 |
| 120 for (var i = 0; i < urls.length; i++) | 120 for (var i = 0; i < urls.length; i++) |
| 121 { | 121 { |
| 122 if (/^(?!https?:)[\w-]+:/i.test(urls[i])) | 122 if (/^(?!https?:)[\w-]+:/i.test(urls[i])) |
| 123 urls.splice(i--, 1); | 123 urls.splice(i--, 1); |
| 124 } | 124 } |
| 125 | 125 |
| 126 return urls; | 126 return urls; |
| 127 } | 127 } |
| 128 | 128 |
| 129 function checkCollapse(element) | 129 function checkCollapse(element, contentDocument) |
| 130 { | 130 { |
| 131 window.collapsing = true; | 131 window.collapsing = true; |
| 132 | 132 |
| 133 var mediatype = typeMap[element.localName]; | 133 var mediatype = typeMap[element.localName]; |
| 134 if (!mediatype) | 134 if (!mediatype) |
| 135 return; | 135 return; |
| 136 | 136 |
| 137 var urls = getURLsFromElement(element); | 137 var urls = getURLsFromElement(element); |
| 138 if (urls.length == 0) | 138 if (urls.length == 0) |
| 139 return; | 139 return; |
| 140 | 140 |
| 141 ext.backgroundPage.sendMessage( | 141 var message = { |
| 142 { | 142 type: "filters.collapse", |
| 143 type: "filters.collapse", | 143 urls: urls, |
| 144 urls: urls, | 144 mediatype: mediatype, |
| 145 mediatype: mediatype, | 145 baseURL: document.location.href |
| 146 baseURL: document.location.href | 146 }; |
| 147 }, | |
| 148 | 147 |
| 148 if (contentDocument) |
| 149 message.dynamicFrameURL = contentDocument.location.href; |
| 150 |
| 151 ext.backgroundPage.sendMessage(message, |
| 149 function(collapse) | 152 function(collapse) |
| 150 { | 153 { |
| 151 function collapseElement() | 154 function collapseElement() |
| 152 { | 155 { |
| 153 if (element.localName == "frame") | 156 if (element.localName == "frame") |
| 154 element.style.setProperty("visibility", "hidden", "important"); | 157 element.style.setProperty("visibility", "hidden", "important"); |
| 155 else | 158 else |
| 156 element.style.setProperty("display", "none", "important"); | 159 element.style.setProperty("display", "none", "important"); |
| 157 } | 160 } |
| 158 | 161 |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 // dynamically created frames. Also on Chrome 37-40 | 549 // dynamically created frames. Also on Chrome 37-40 |
| 547 // document_start content scripts (like this one) don't | 550 // document_start content scripts (like this one) don't |
| 548 // run either in those frames due to https://crbug.com/416907. | 551 // run either in those frames due to https://crbug.com/416907. |
| 549 // So we have to apply element hiding from the parent frame. | 552 // So we have to apply element hiding from the parent frame. |
| 550 if (!("init" in contentWindow)) | 553 if (!("init" in contentWindow)) |
| 551 init(contentDocument); | 554 init(contentDocument); |
| 552 | 555 |
| 553 // Moreover, "load" and "error" events aren't dispatched for elements | 556 // Moreover, "load" and "error" events aren't dispatched for elements |
| 554 // in dynamically created frames due to https://crbug.com/442107. | 557 // in dynamically created frames due to https://crbug.com/442107. |
| 555 // So we also have to apply element collpasing from the parent frame. | 558 // So we also have to apply element collpasing from the parent frame. |
| 556 if (!contentWindow.collapsing) | 559 if (!contentWindow.collapsing) |
| 557 Array.prototype.forEach.call( | 560 Array.prototype.forEach.call( |
| 558 contentDocument.querySelectorAll(Object.keys(typeMap).join(",")), | 561 contentDocument.querySelectorAll(Object.keys(typeMap).join(",")), |
| 559 checkCollapse | 562 function(element) |
| 563 { |
| 564 checkCollapse(element, contentDocument); |
| 565 } |
| 560 ); | 566 ); |
| 561 } | 567 } |
| 562 } | 568 } |
| 563 } | 569 } |
| 564 }, true); | 570 }, true); |
| 565 | 571 |
| 566 return updateStylesheet; | 572 return updateStylesheet; |
| 567 } | 573 } |
| 568 | 574 |
| 569 if (document instanceof HTMLDocument) | 575 if (document instanceof HTMLDocument) |
| 570 { | 576 { |
| 571 checkSitekey(); | 577 checkSitekey(); |
| 572 window.updateStylesheet = init(document); | 578 window.updateStylesheet = init(document); |
| 573 } | 579 } |
| OLD | NEW |