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-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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 }; | 85 }; |
86 | 86 |
87 modules.utils = { | 87 modules.utils = { |
88 Utils: { | 88 Utils: { |
89 getDocLink(link) | 89 getDocLink(link) |
90 { | 90 { |
91 return "https://adblockplus.org/redirect?link=" + encodeURIComponent(lin
k); | 91 return "https://adblockplus.org/redirect?link=" + encodeURIComponent(lin
k); |
92 }, | 92 }, |
93 get appLocale() | 93 get appLocale() |
94 { | 94 { |
95 return chrome.i18n.getUILanguage(); | 95 return browser.i18n.getUILanguage(); |
96 }, | 96 }, |
97 get readingDirection() | 97 get readingDirection() |
98 { | 98 { |
99 return /^(?:ar|fa|he|ug|ur)\b/.test(this.appLocale) ? "rtl" : "ltr"; | 99 return /^(?:ar|fa|he|ug|ur)\b/.test(this.appLocale) ? "rtl" : "ltr"; |
100 } | 100 } |
101 } | 101 } |
102 }; | 102 }; |
103 | 103 |
104 modules.prefs = {Prefs: new EventEmitter()}; | 104 modules.prefs = {Prefs: new EventEmitter()}; |
105 let prefs = { | 105 let prefs = { |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 | 409 |
410 modules.options = { | 410 modules.options = { |
411 showOptions(callback) | 411 showOptions(callback) |
412 { | 412 { |
413 if (!/\/(?:mobile|desktop)-options\.html\b/.test(top.location.href)) | 413 if (!/\/(?:mobile|desktop)-options\.html\b/.test(top.location.href)) |
414 window.open("desktop-options.html", "_blank"); | 414 window.open("desktop-options.html", "_blank"); |
415 | 415 |
416 if (callback) | 416 if (callback) |
417 callback(); | 417 callback(); |
418 } | 418 } |
| 419 }; |
| 420 |
| 421 modules.requestBlocker = { |
| 422 filterTypes: [] |
419 }; | 423 }; |
420 | 424 |
421 window.addEventListener("message", (event) => | 425 window.addEventListener("message", (event) => |
422 { | 426 { |
423 if (event.data.type != "message") | 427 if (event.data.type != "message") |
424 return; | 428 return; |
425 let message = event.data.payload; | 429 let message = event.data.payload; |
426 let {messageId} = event.data; | 430 let {messageId} = event.data; |
427 let sender = { | 431 let sender = { |
428 page: new ext.Page(event.source) | 432 page: new ext.Page(event.source) |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 { | 538 { |
535 host, | 539 host, |
536 whitelisted: isWhitelisted | 540 whitelisted: isWhitelisted |
537 } | 541 } |
538 ] | 542 ] |
539 } | 543 } |
540 }, "*"); | 544 }, "*"); |
541 }, 1000); | 545 }, 1000); |
542 } | 546 } |
543 | 547 |
544 let {port} = require("messaging"); | 548 browser.runtime.onConnect.addListener(port => |
545 | 549 { |
546 port.on("devtools.ready", (message, sender) => | |
547 { | |
548 let panel = sender.page; | |
549 | |
550 // blocked request | 550 // blocked request |
551 panel.sendMessage({ | 551 port.postMessage({ |
552 type: "add-record", | 552 type: "add-record", |
553 request: { | 553 request: { |
554 url: "http://adserver.example.com/ad_banner.png", | 554 url: "http://adserver.example.com/ad_banner.png", |
555 type: "IMAGE", | 555 type: "IMAGE", |
556 docDomain: "example.com" | 556 docDomain: "example.com" |
557 }, | 557 }, |
558 filter: { | 558 filter: { |
559 text: "/ad_banner*$domain=example.com", | 559 text: "/ad_banner*$domain=example.com", |
560 whitelisted: false, | 560 whitelisted: false, |
561 userDefined: false, | 561 userDefined: false, |
562 subscription: "EasyList" | 562 subscription: "EasyList" |
563 } | 563 } |
564 }); | 564 }); |
565 | 565 |
566 // whitelisted request | 566 // whitelisted request |
567 panel.sendMessage({ | 567 port.postMessage({ |
568 type: "add-record", | 568 type: "add-record", |
569 request: { | 569 request: { |
570 url: "http://example.com/looks_like_an_ad_but_isnt_one.html", | 570 url: "http://example.com/looks_like_an_ad_but_isnt_one.html", |
571 type: "SUBDOCUMENT", | 571 type: "SUBDOCUMENT", |
572 docDomain: "example.com" | 572 docDomain: "example.com" |
573 }, | 573 }, |
574 filter: { | 574 filter: { |
575 text: "@@||example.com/looks_like_an_ad_but_isnt_one.html", | 575 text: "@@||example.com/looks_like_an_ad_but_isnt_one.html", |
576 whitelisted: true, | 576 whitelisted: true, |
577 userDefined: false, | 577 userDefined: false, |
578 subscription: "EasyList" | 578 subscription: "EasyList" |
579 } | 579 } |
580 }); | 580 }); |
581 | 581 |
582 // request with long URL and no filter matches | 582 // request with long URL and no filter matches |
583 panel.sendMessage({ | 583 port.postMessage({ |
584 type: "add-record", | 584 type: "add-record", |
585 request: { | 585 request: { |
586 url: "https://this.url.has.a.long.domain/and_a_long_path_maybe_not_long_
enough_so_i_keep_typing?there=are&a=couple&of=parameters&as=well&and=even&some=m
ore", | 586 url: "https://this.url.has.a.long.domain/and_a_long_path_maybe_not_long_
enough_so_i_keep_typing?there=are&a=couple&of=parameters&as=well&and=even&some=m
ore", |
587 type: "XMLHTTPREQUEST", | 587 type: "XMLHTTPREQUEST", |
588 docDomain: "example.com" | 588 docDomain: "example.com" |
589 }, | 589 }, |
590 filter: null | 590 filter: null |
591 }); | 591 }); |
592 | 592 |
593 // matching element hiding filter | 593 // matching element hiding filter |
594 panel.sendMessage({ | 594 port.postMessage({ |
595 type: "add-record", | 595 type: "add-record", |
596 request: { | 596 request: { |
597 type: "ELEMHIDE", | 597 type: "ELEMHIDE", |
598 docDomain: "example.com" | 598 docDomain: "example.com" |
599 }, | 599 }, |
600 filter: { | 600 filter: { |
601 text: "example.com##.ad_banner", | 601 text: "example.com##.ad_banner", |
602 whitelisted: false, | 602 whitelisted: false, |
603 userDefined: false, | 603 userDefined: false, |
604 subscription: "EasyList" | 604 subscription: "EasyList" |
605 } | 605 } |
606 }); | 606 }); |
607 | 607 |
608 // user-defined filter | 608 // user-defined filter |
609 panel.sendMessage({ | 609 port.postMessage({ |
610 type: "add-record", | 610 type: "add-record", |
611 request: { | 611 request: { |
612 url: "http://example.com/some-annoying-popup", | 612 url: "http://example.com/some-annoying-popup", |
613 type: "POPUP", | 613 type: "POPUP", |
614 docDomain: "example.com" | 614 docDomain: "example.com" |
615 }, | 615 }, |
616 filter: { | 616 filter: { |
617 text: "||example.com/some-annoying-popup$popup", | 617 text: "||example.com/some-annoying-popup$popup", |
618 whitelisted: false, | 618 whitelisted: false, |
619 userDefined: true, | 619 userDefined: true, |
620 subscription: null | 620 subscription: null |
621 } | 621 } |
622 }); | 622 }); |
623 }); | 623 }); |
624 }()); | 624 }()); |
LEFT | RIGHT |