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

Side by Side Diff: background.js

Issue 29573905: Issue 4580 - Replace ext.devtools with devtools Base URL: https://hg.adblockplus.org/adblockplusui/
Patch Set: Use Location.pathname Created Oct. 18, 2017, 12:23 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | desktop-options.js » ('j') | ext/background.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 window.require = function(module) 82
83 { 83 window.require = module => modules[module];
84 return modules[module];
85 };
86 84
87 modules.utils = { 85 modules.utils = {
88 Utils: { 86 Utils: {
89 getDocLink(link) 87 getDocLink(link)
90 { 88 {
91 return "https://adblockplus.org/redirect?link=" + encodeURIComponent(lin k); 89 return "https://adblockplus.org/redirect?link=" + encodeURIComponent(lin k);
92 }, 90 },
93 get appLocale() 91 get appLocale()
94 { 92 {
95 return chrome.i18n.getUILanguage(); 93 return chrome.i18n.getUILanguage();
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 showOptions(callback) 409 showOptions(callback)
412 { 410 {
413 if (!/\/(?:mobile|desktop)-options\.html\b/.test(top.location.href)) 411 if (!/\/(?:mobile|desktop)-options\.html\b/.test(top.location.href))
414 window.open("desktop-options.html", "_blank"); 412 window.open("desktop-options.html", "_blank");
415 413
416 if (callback) 414 if (callback)
417 callback(); 415 callback();
418 } 416 }
419 }; 417 };
420 418
419 modules.requestBlocker = {
420 filterTypes: []
421 };
422
421 window.addEventListener("message", (event) => 423 window.addEventListener("message", (event) =>
422 { 424 {
423 if (event.data.type != "message") 425 if (event.data.type != "message")
424 return; 426 return;
425 let message = event.data.payload; 427 let message = event.data.payload;
426 let {messageId} = event.data; 428 let {messageId} = event.data;
427 let sender = { 429 let sender = {
428 page: new ext.Page(event.source) 430 page: new ext.Page(event.source)
429 }; 431 };
430 432
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 { 536 {
535 host, 537 host,
536 whitelisted: isWhitelisted 538 whitelisted: isWhitelisted
537 } 539 }
538 ] 540 ]
539 } 541 }
540 }, "*"); 542 }, "*");
541 }, 1000); 543 }, 1000);
542 } 544 }
543 545
544 ext.devtools.onCreated.addListener((panel) => 546 chrome.runtime.onConnect.addListener(port =>
545 { 547 {
546 // blocked request 548 // blocked request
547 panel.sendMessage({ 549 port.postMessage({
548 type: "add-record", 550 type: "add-record",
549 request: { 551 request: {
550 url: "http://adserver.example.com/ad_banner.png", 552 url: "http://adserver.example.com/ad_banner.png",
551 type: "IMAGE", 553 type: "IMAGE",
552 docDomain: "example.com" 554 docDomain: "example.com"
553 }, 555 },
554 filter: { 556 filter: {
555 text: "/ad_banner*$domain=example.com", 557 text: "/ad_banner*$domain=example.com",
556 whitelisted: false, 558 whitelisted: false,
557 userDefined: false, 559 userDefined: false,
558 subscription: "EasyList" 560 subscription: "EasyList"
559 } 561 }
560 }); 562 });
561 563
562 // whitelisted request 564 // whitelisted request
563 panel.sendMessage({ 565 port.postMessage({
564 type: "add-record", 566 type: "add-record",
565 request: { 567 request: {
566 url: "http://example.com/looks_like_an_ad_but_isnt_one.html", 568 url: "http://example.com/looks_like_an_ad_but_isnt_one.html",
567 type: "SUBDOCUMENT", 569 type: "SUBDOCUMENT",
568 docDomain: "example.com" 570 docDomain: "example.com"
569 }, 571 },
570 filter: { 572 filter: {
571 text: "@@||example.com/looks_like_an_ad_but_isnt_one.html", 573 text: "@@||example.com/looks_like_an_ad_but_isnt_one.html",
572 whitelisted: true, 574 whitelisted: true,
573 userDefined: false, 575 userDefined: false,
574 subscription: "EasyList" 576 subscription: "EasyList"
575 } 577 }
576 }); 578 });
577 579
578 // request with long URL and no filter matches 580 // request with long URL and no filter matches
579 panel.sendMessage({ 581 port.postMessage({
580 type: "add-record", 582 type: "add-record",
581 request: { 583 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", 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",
583 type: "XMLHTTPREQUEST", 585 type: "XMLHTTPREQUEST",
584 docDomain: "example.com" 586 docDomain: "example.com"
585 }, 587 },
586 filter: null 588 filter: null
587 }); 589 });
588 590
589 // matching element hiding filter 591 // matching element hiding filter
590 panel.sendMessage({ 592 port.postMessage({
591 type: "add-record", 593 type: "add-record",
592 request: { 594 request: {
593 type: "ELEMHIDE", 595 type: "ELEMHIDE",
594 docDomain: "example.com" 596 docDomain: "example.com"
595 }, 597 },
596 filter: { 598 filter: {
597 text: "example.com##.ad_banner", 599 text: "example.com##.ad_banner",
598 whitelisted: false, 600 whitelisted: false,
599 userDefined: false, 601 userDefined: false,
600 subscription: "EasyList" 602 subscription: "EasyList"
601 } 603 }
602 }); 604 });
603 605
604 // user-defined filter 606 // user-defined filter
605 panel.sendMessage({ 607 port.postMessage({
606 type: "add-record", 608 type: "add-record",
607 request: { 609 request: {
608 url: "http://example.com/some-annoying-popup", 610 url: "http://example.com/some-annoying-popup",
609 type: "POPUP", 611 type: "POPUP",
610 docDomain: "example.com" 612 docDomain: "example.com"
611 }, 613 },
612 filter: { 614 filter: {
613 text: "||example.com/some-annoying-popup$popup", 615 text: "||example.com/some-annoying-popup$popup",
614 whitelisted: false, 616 whitelisted: false,
615 userDefined: true, 617 userDefined: true,
616 subscription: null 618 subscription: null
617 } 619 }
618 }); 620 });
619 }); 621 });
620 }()); 622 }());
OLDNEW
« no previous file with comments | « no previous file | desktop-options.js » ('j') | ext/background.js » ('J')

Powered by Google App Engine
This is Rietveld