Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: include.postload.js

Issue 4734012065054720: Issue 2634 - Consider alternative URLs for element collapsing (Closed)
Patch Set: Consider all URLs for element collapsing Created June 7, 2015, 3:14 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « background.js ('k') | include.preload.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 { 131 {
132 Array.prototype.forEach.call( 132 Array.prototype.forEach.call(
133 document.querySelectorAll(highlightedElementsSelector), 133 document.querySelectorAll(highlightedElementsSelector),
134 unhighlightElement 134 unhighlightElement
135 ); 135 );
136 136
137 highlightedElementsSelector = null; 137 highlightedElementsSelector = null;
138 } 138 }
139 } 139 }
140 140
141 function getURLsFromObjectElement(element)
142 {
143 var url = element.getAttribute("data");
144 if (url)
145 return [url];
146
147 for (var i = 0; i < element.children.length; i++)
148 {
149 var child = element.children[i];
150 if (child.localName != "param")
151 continue;
152
153 var name = child.getAttribute("name");
154 if (name != "movie" && // Adobe Flash
155 name != "source" && // Silverlight
156 name != "src" && // Real Media + Quicktime
157 name != "FileName") // Windows Media
158 continue;
159
160 var value = child.getAttribute("value");
161 if (!value)
162 continue;
163
164 return [value];
165 }
166
167 return [];
168 }
169
170 function getURLsFromAttributes(element)
171 {
172 var urls = [];
173
174 if (element.src)
175 urls.push(element.src);
176
177 if (element.srcset)
178 {
179 var candidates = element.srcset.split(",");
180 for (var i = 0; i < candidates.length; i++)
181 {
182 var url = candidates[i].trim().replace(/\s+\S+$/, "");
183 if (url)
184 urls.push(url);
185 }
186 }
187
188 return urls;
189 }
190
191 function getURLsFromMediaElement(element)
192 {
193 var urls = getURLsFromAttributes(element);
194
195 for (var i = 0; i < element.children.length; i++)
196 {
197 var child = element.children[i];
198 if (child.localName == "source" || child.localName == "track")
199 urls.push.apply(urls, getURLsFromAttributes(child));
200 }
201
202 if (element.poster)
203 urls.push(element.poster);
204
205 return urls;
206 }
207
208 function getURLsFromElement(element) {
209 switch (element.localName)
210 {
211 case "object":
212 return getURLsFromObjectElement(element);
213
214 case "video":
215 case "audio":
216 case "picture":
217 return getURLsFromMediaElement(element);
218 }
219
220 return getURLsFromAttributes(element);
221 }
222
223 // Adds an overlay to an element, which is probably a Flash object 141 // Adds an overlay to an element, which is probably a Flash object
224 function addElementOverlay(elt) { 142 function addElementOverlay(elt) {
225 var position = "absolute"; 143 var position = "absolute";
226 var offsetX = window.scrollX; 144 var offsetX = window.scrollX;
227 var offsetY = window.scrollY; 145 var offsetY = window.scrollY;
228 146
229 for (var e = elt; e; e = e.parentElement) 147 for (var e = elt; e; e = e.parentElement)
230 { 148 {
231 var style = getComputedStyle(e); 149 var style = getComputedStyle(e);
232 150
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 lastRightClickEventValid = false; 665 lastRightClickEventValid = false;
748 else 666 else
749 lastRightClickEvent = null; 667 lastRightClickEvent = null;
750 break; 668 break;
751 } 669 }
752 }); 670 });
753 671
754 if (window == window.top) 672 if (window == window.top)
755 ext.backgroundPage.sendMessage({type: "report-html-page"}); 673 ext.backgroundPage.sendMessage({type: "report-html-page"});
756 } 674 }
OLDNEW
« no previous file with comments | « background.js ('k') | include.preload.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld