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

Delta Between Two Patch Sets: include.preload.js

Issue 4734012065054720: Issue 2634 - Consider alternative URLs for element collapsing (Closed)
Left Patch Set: Exclude non-HTTP(s) URLs in content script Created June 7, 2015, 3:10 p.m.
Right 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « include.postload.js ('k') | lib/filterComposer.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 urls = getURLsFromMediaElement(element); 111 urls = getURLsFromMediaElement(element);
112 break; 112 break;
113 113
114 default: 114 default:
115 urls = getURLsFromAttributes(element); 115 urls = getURLsFromAttributes(element);
116 break; 116 break;
117 } 117 }
118 118
119 for (var i = 0; i < urls.length; i++) 119 for (var i = 0; i < urls.length; i++)
120 { 120 {
121 if (/^(?!https?:)[\w-]+:/i.test(urls[i])) 121 if (/^(?!https?:)[\w-]+:/i.test(urls[i]))
Sebastian Noack 2015/06/07 15:30:06 Note that we already use the very same regexp in s
122 urls.splice(i--, 1); 122 urls.splice(i--, 1);
123 } 123 }
124 124
125 return urls; 125 return urls;
126 } 126 }
127 127
128 function checkCollapse(element) 128 function checkCollapse(element)
129 { 129 {
130 var tag = element.localName; 130 var tag = element.localName;
131 if (tag in typeMap) 131 if (tag in typeMap)
132 { 132 {
133 // This element failed loading, did we block it? 133 // This element failed loading, did we block it?
134 var url = element.src; 134 var urls = getURLsFromElement(element);
135 if (!url || !/^https?:/i.test(url)) 135 if (urls.length == 0)
136 return; 136 return;
137 137
138 ext.backgroundPage.sendMessage( 138 ext.backgroundPage.sendMessage(
139 { 139 {
140 type: "should-collapse", 140 type: "should-collapse",
141 url: url, 141 urls: urls,
142 mediatype: typeMap[tag] 142 mediatype: typeMap[tag],
143 baseURL: document.location.href
143 }, 144 },
144 145
145 function(response) 146 function(response)
146 { 147 {
147 if (response && element.parentNode) 148 if (response && element.parentNode)
148 { 149 {
149 var property = "display"; 150 var property = "display";
150 var value = "none"; 151 var value = "none";
151 152
152 // <frame> cannot be removed, doing that will mess up the frameset 153 // <frame> cannot be removed, doing that will mess up the frameset
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 }, true); 395 }, true);
395 396
396 return updateStylesheet; 397 return updateStylesheet;
397 } 398 }
398 399
399 if (document instanceof HTMLDocument) 400 if (document instanceof HTMLDocument)
400 { 401 {
401 checkSitekey(); 402 checkSitekey();
402 window.updateStylesheet = init(document); 403 window.updateStylesheet = init(document);
403 } 404 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld