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

Delta Between Two Patch Sets: include.preload.js

Issue 29570614: Issue 5028 - Use browser namespace (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Left Patch Set: Rebase Created Oct. 10, 2017, 6:28 p.m.
Right Patch Set: Update adblockplusui dependency Created Oct. 17, 2017, 1:02 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 | « ext/devtools.js ('k') | inject.preload.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-present eyeo GmbH 3 * Copyright (C) 2006-present 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 function checkCollapse(element) 158 function checkCollapse(element)
159 { 159 {
160 let mediatype = typeMap.get(element.localName); 160 let mediatype = typeMap.get(element.localName);
161 if (!mediatype) 161 if (!mediatype)
162 return; 162 return;
163 163
164 let urls = getURLsFromElement(element); 164 let urls = getURLsFromElement(element);
165 if (urls.length == 0) 165 if (urls.length == 0)
166 return; 166 return;
167 167
168 ext.backgroundPage.sendMessage( 168 browser.runtime.sendMessage(
169 { 169 {
170 type: "filters.collapse", 170 type: "filters.collapse",
171 urls, 171 urls,
172 mediatype, 172 mediatype,
173 baseURL: document.location.href 173 baseURL: document.location.href
174 }, 174 },
175 175
176 collapse => 176 collapse =>
177 { 177 {
178 if (collapse) 178 if (collapse)
179 { 179 {
180 hideElement(element); 180 hideElement(element);
181 } 181 }
182 } 182 }
183 ); 183 );
184 } 184 }
185 185
186 function checkSitekey() 186 function checkSitekey()
187 { 187 {
188 let attr = document.documentElement.getAttribute("data-adblockkey"); 188 let attr = document.documentElement.getAttribute("data-adblockkey");
189 if (attr) 189 if (attr)
190 ext.backgroundPage.sendMessage({type: "filters.addKey", token: attr}); 190 browser.runtime.sendMessage({type: "filters.addKey", token: attr});
191 } 191 }
192 192
193 function ElementHidingTracer() 193 function ElementHidingTracer()
194 { 194 {
195 this.selectors = []; 195 this.selectors = [];
196 this.changedNodes = []; 196 this.changedNodes = [];
197 this.timeout = null; 197 this.timeout = null;
198 this.observer = new MutationObserver(this.observe.bind(this)); 198 this.observer = new MutationObserver(this.observe.bind(this));
199 this.trace = this.trace.bind(this); 199 this.trace = this.trace.bind(this);
200 200
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 selectors.push(selector); 241 selectors.push(selector);
242 242
243 break nodes; 243 break nodes;
244 } 244 }
245 } 245 }
246 } 246 }
247 } 247 }
248 248
249 if (selectors.length > 0 || filters.length > 0) 249 if (selectors.length > 0 || filters.length > 0)
250 { 250 {
251 ext.backgroundPage.sendMessage({ 251 browser.runtime.sendMessage({
252 type: "devtools.traceElemHide", 252 type: "devtools.traceElemHide",
253 selectors, filters 253 selectors, filters
254 }); 254 });
255 } 255 }
256 }, 256 },
257 257
258 onTimeout() 258 onTimeout()
259 { 259 {
260 this.checkNodes(this.changedNodes, this.selectors); 260 this.checkNodes(this.changedNodes, this.selectors);
261 this.changedNodes = []; 261 this.changedNodes = [];
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 // (Firefox 53 onwards for now and possibly Chrome in the near future). 445 // (Firefox 53 onwards for now and possibly Chrome in the near future).
446 // Once all supported platforms have implemented this API, we can remove 446 // Once all supported platforms have implemented this API, we can remove
447 // the code below. See issue #5090. 447 // the code below. See issue #5090.
448 // Related Chrome and Firefox issues: 448 // Related Chrome and Firefox issues:
449 // https://bugs.chromium.org/p/chromium/issues/detail?id=632009 449 // https://bugs.chromium.org/p/chromium/issues/detail?id=632009
450 // https://bugzilla.mozilla.org/show_bug.cgi?id=1310026 450 // https://bugzilla.mozilla.org/show_bug.cgi?id=1310026
451 this.injectSelectors(selectors, filters); 451 this.injectSelectors(selectors, filters);
452 } 452 }
453 else 453 else
454 { 454 {
455 ext.backgroundPage.sendMessage({ 455 browser.runtime.sendMessage({
456 type: "elemhide.injectSelectors", 456 type: "elemhide.injectSelectors",
457 selectors 457 selectors
458 }); 458 });
459 } 459 }
460 460
461 if (this.tracer) 461 if (this.tracer)
462 this.tracer.addSelectors(selectors, filters); 462 this.tracer.addSelectors(selectors, filters);
463 }, 463 },
464 464
465 hideElements(elements, filters) 465 hideElements(elements, filters)
466 { 466 {
467 for (let element of elements) 467 for (let element of elements)
468 hideElement(element); 468 hideElement(element);
469 469
470 if (this.tracer) 470 if (this.tracer)
471 { 471 {
472 ext.backgroundPage.sendMessage({ 472 browser.runtime.sendMessage({
473 type: "devtools.traceElemHide", 473 type: "devtools.traceElemHide",
474 selectors: [], 474 selectors: [],
475 filters 475 filters
476 }); 476 });
477 } 477 }
478 }, 478 },
479 479
480 apply() 480 apply()
481 { 481 {
482 ext.backgroundPage.sendMessage({type: "elemhide.getSelectors"}, response => 482 browser.runtime.sendMessage({type: "elemhide.getSelectors"}, response =>
483 { 483 {
484 if (this.tracer) 484 if (this.tracer)
485 this.tracer.disconnect(); 485 this.tracer.disconnect();
486 this.tracer = null; 486 this.tracer = null;
487 487
488 if (this.style && this.style.parentElement) 488 if (this.style && this.style.parentElement)
489 this.style.parentElement.removeChild(this.style); 489 this.style.parentElement.removeChild(this.style);
490 this.style = null; 490 this.style = null;
491 491
492 if (response.trace) 492 if (response.trace)
(...skipping 23 matching lines...) Expand all
516 checkCollapse(event.target); 516 checkCollapse(event.target);
517 }, true); 517 }, true);
518 518
519 document.addEventListener("load", event => 519 document.addEventListener("load", event =>
520 { 520 {
521 let element = event.target; 521 let element = event.target;
522 if (/^i?frame$/.test(element.localName)) 522 if (/^i?frame$/.test(element.localName))
523 checkCollapse(element); 523 checkCollapse(element);
524 }, true); 524 }, true);
525 } 525 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld