OLD | NEW |
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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 }; | 419 }; |
420 | 420 |
| 421 modules.requestBlocker = { |
| 422 filterTypes: [] |
| 423 }; |
| 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) |
429 }; | 433 }; |
430 | 434 |
(...skipping 103 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 ext.devtools.onCreated.addListener((panel) => | 548 browser.runtime.onConnect.addListener(port => |
545 { | 549 { |
546 // blocked request | 550 // blocked request |
547 panel.sendMessage({ | 551 port.postMessage({ |
548 type: "add-record", | 552 type: "add-record", |
549 request: { | 553 request: { |
550 url: "http://adserver.example.com/ad_banner.png", | 554 url: "http://adserver.example.com/ad_banner.png", |
551 type: "IMAGE", | 555 type: "IMAGE", |
552 docDomain: "example.com" | 556 docDomain: "example.com" |
553 }, | 557 }, |
554 filter: { | 558 filter: { |
555 text: "/ad_banner*$domain=example.com", | 559 text: "/ad_banner*$domain=example.com", |
556 whitelisted: false, | 560 whitelisted: false, |
557 userDefined: false, | 561 userDefined: false, |
558 subscription: "EasyList" | 562 subscription: "EasyList" |
559 } | 563 } |
560 }); | 564 }); |
561 | 565 |
562 // whitelisted request | 566 // whitelisted request |
563 panel.sendMessage({ | 567 port.postMessage({ |
564 type: "add-record", | 568 type: "add-record", |
565 request: { | 569 request: { |
566 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", |
567 type: "SUBDOCUMENT", | 571 type: "SUBDOCUMENT", |
568 docDomain: "example.com" | 572 docDomain: "example.com" |
569 }, | 573 }, |
570 filter: { | 574 filter: { |
571 text: "@@||example.com/looks_like_an_ad_but_isnt_one.html", | 575 text: "@@||example.com/looks_like_an_ad_but_isnt_one.html", |
572 whitelisted: true, | 576 whitelisted: true, |
573 userDefined: false, | 577 userDefined: false, |
574 subscription: "EasyList" | 578 subscription: "EasyList" |
575 } | 579 } |
576 }); | 580 }); |
577 | 581 |
578 // request with long URL and no filter matches | 582 // request with long URL and no filter matches |
579 panel.sendMessage({ | 583 port.postMessage({ |
580 type: "add-record", | 584 type: "add-record", |
581 request: { | 585 request: { |
582 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", |
583 type: "XMLHTTPREQUEST", | 587 type: "XMLHTTPREQUEST", |
584 docDomain: "example.com" | 588 docDomain: "example.com" |
585 }, | 589 }, |
586 filter: null | 590 filter: null |
587 }); | 591 }); |
588 | 592 |
589 // matching element hiding filter | 593 // matching element hiding filter |
590 panel.sendMessage({ | 594 port.postMessage({ |
591 type: "add-record", | 595 type: "add-record", |
592 request: { | 596 request: { |
593 type: "ELEMHIDE", | 597 type: "ELEMHIDE", |
594 docDomain: "example.com" | 598 docDomain: "example.com" |
595 }, | 599 }, |
596 filter: { | 600 filter: { |
597 text: "example.com##.ad_banner", | 601 text: "example.com##.ad_banner", |
598 whitelisted: false, | 602 whitelisted: false, |
599 userDefined: false, | 603 userDefined: false, |
600 subscription: "EasyList" | 604 subscription: "EasyList" |
601 } | 605 } |
602 }); | 606 }); |
603 | 607 |
604 // user-defined filter | 608 // user-defined filter |
605 panel.sendMessage({ | 609 port.postMessage({ |
606 type: "add-record", | 610 type: "add-record", |
607 request: { | 611 request: { |
608 url: "http://example.com/some-annoying-popup", | 612 url: "http://example.com/some-annoying-popup", |
609 type: "POPUP", | 613 type: "POPUP", |
610 docDomain: "example.com" | 614 docDomain: "example.com" |
611 }, | 615 }, |
612 filter: { | 616 filter: { |
613 text: "||example.com/some-annoying-popup$popup", | 617 text: "||example.com/some-annoying-popup$popup", |
614 whitelisted: false, | 618 whitelisted: false, |
615 userDefined: true, | 619 userDefined: true, |
616 subscription: null | 620 subscription: null |
617 } | 621 } |
618 }); | 622 }); |
619 }); | 623 }); |
620 }()); | 624 }()); |
OLD | NEW |