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