LEFT | RIGHT |
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-2017 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 |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 checkCollapse(event.target); | 575 checkCollapse(event.target); |
576 }, true); | 576 }, true); |
577 | 577 |
578 document.addEventListener("load", event => | 578 document.addEventListener("load", event => |
579 { | 579 { |
580 let element = event.target; | 580 let element = event.target; |
581 if (/^i?frame$/.test(element.localName)) | 581 if (/^i?frame$/.test(element.localName)) |
582 checkCollapse(element); | 582 checkCollapse(element); |
583 }, true); | 583 }, true); |
584 } | 584 } |
LEFT | RIGHT |