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

Delta Between Two Patch Sets: include.preload.js

Issue 29374674: Issue 4864 - Start using ESLint for adblockpluschrome (Closed)
Left Patch Set: Update adblockplusui dependency to include the notification fix Created March 19, 2017, 6:48 a.m.
Right Patch Set: Use .includes again Created March 31, 2017, 8:37 a.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/common.js ('k') | lib/compat.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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2017 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 function runInPageContext(fn, arg) 330 function runInPageContext(fn, arg)
331 { 331 {
332 let script = document.createElement("script"); 332 let script = document.createElement("script");
333 script.type = "application/javascript"; 333 script.type = "application/javascript";
334 script.async = false; 334 script.async = false;
335 script.textContent = "(" + fn + ")(" + JSON.stringify(arg) + ");"; 335 script.textContent = "(" + fn + ")(" + JSON.stringify(arg) + ");";
336 document.documentElement.appendChild(script); 336 document.documentElement.appendChild(script);
337 document.documentElement.removeChild(script); 337 document.documentElement.removeChild(script);
338 } 338 }
339 339
340 // Chrome doesn't allow us to intercept WebSockets[1], and therefore 340 // Before Chrome 58 the webRequest API didn't allow us to intercept
341 // some ad networks are misusing them as a way to serve adverts and circumvent 341 // WebSockets[1], and therefore some ad networks are misusing them as a way to
342 // us. As a workaround we wrap WebSocket, preventing blocked WebSocket 342 // serve adverts and circumvent us. As a workaround we wrap WebSocket,
343 // connections from being opened. 343 // preventing blocked WebSocket connections from being opened.
344 // [1] - https://bugs.chromium.org/p/chromium/issues/detail?id=129353 344 // [1] - https://bugs.chromium.org/p/chromium/issues/detail?id=129353
345 function wrapWebSocket() 345 function wrapWebSocket()
346 { 346 {
347 let randomEventName = "abpws-" + Math.random().toString(36).substr(2); 347 let randomEventName = "abpws-" + Math.random().toString(36).substr(2);
348 348
349 document.addEventListener(randomEventName, event => 349 document.addEventListener(randomEventName, event =>
350 { 350 {
351 ext.backgroundPage.sendMessage({ 351 ext.backgroundPage.sendMessage({
352 type: "request.websocket", 352 type: "request.websocket",
353 url: event.detail.url 353 url: event.detail.url
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 if (this.shadow) 512 if (this.shadow)
513 { 513 {
514 for (let selector of selectors) 514 for (let selector of selectors)
515 { 515 {
516 let subSelectors = splitSelector(selector); 516 let subSelectors = splitSelector(selector);
517 for (let subSelector of subSelectors) 517 for (let subSelector of subSelectors)
518 preparedSelectors.push("::content " + subSelector); 518 preparedSelectors.push("::content " + subSelector);
519 } 519 }
520 } 520 }
521 else 521 else
522 {
522 preparedSelectors = selectors; 523 preparedSelectors = selectors;
524 }
523 525
524 // Safari only allows 8192 primitive selectors to be injected at once[1], we 526 // Safari only allows 8192 primitive selectors to be injected at once[1], we
525 // therefore chunk the inserted selectors into groups of 200 to be safe. 527 // therefore chunk the inserted selectors into groups of 200 to be safe.
526 // (Chrome also has a limit, larger... but we're not certain exactly what it 528 // (Chrome also has a limit, larger... but we're not certain exactly what it
527 // is! Edge apparently has no such limit.) 529 // is! Edge apparently has no such limit.)
528 // [1] - https://github.com/WebKit/webkit/blob/1cb2227f6b2a1035f7bdc46e5ab69 debb75fc1de/Source/WebCore/css/RuleSet.h#L68 530 // [1] - https://github.com/WebKit/webkit/blob/1cb2227f6b2a1035f7bdc46e5ab69 debb75fc1de/Source/WebCore/css/RuleSet.h#L68
529 for (let i = 0; i < preparedSelectors.length; i += this.selectorGroupSize) 531 for (let i = 0; i < preparedSelectors.length; i += this.selectorGroupSize)
530 { 532 {
531 let selector = preparedSelectors.slice( 533 let selector = preparedSelectors.slice(
532 i, i + this.selectorGroupSize 534 i, i + this.selectorGroupSize
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 checkCollapse(event.target); 575 checkCollapse(event.target);
574 }, true); 576 }, true);
575 577
576 document.addEventListener("load", event => 578 document.addEventListener("load", event =>
577 { 579 {
578 let element = event.target; 580 let element = event.target;
579 if (/^i?frame$/.test(element.localName)) 581 if (/^i?frame$/.test(element.localName))
580 checkCollapse(element); 582 checkCollapse(element);
581 }, true); 583 }, true);
582 } 584 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld