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

Delta Between Two Patch Sets: background.js

Issue 29573905: Issue 4580 - Replace ext.devtools with devtools Base URL: https://hg.adblockplus.org/adblockplusui/
Left Patch Set: Created Oct. 11, 2017, 10:38 p.m.
Right Patch Set: Rebase Created Oct. 18, 2017, 1: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 | « no previous file | desktop-options.js » ('j') | polyfill.js » ('J')
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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
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 chrome.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 }());
LEFTRIGHT
« no previous file | desktop-options.js » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld