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

Side by Side Diff: background.js

Issue 5646124035604480: Issue 154 - Added UI for devtools panel on Chrome (Closed)
Patch Set: Rebased and adapted for API changes Created March 12, 2015, 4:08 p.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 | devtools-panel.html » ('j') | devtools-panel.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-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 }, 99 },
100 100
101 removeSubscription: function(subscription) 101 removeSubscription: function(subscription)
102 { 102 {
103 var index = subscriptions.indexOf(subscription.url); 103 var index = subscriptions.indexOf(subscription.url);
104 if (index >= 0) 104 if (index >= 0)
105 { 105 {
106 subscriptions.splice(index, 1); 106 subscriptions.splice(index, 1);
107 modules.filterNotifier.FilterNotifier.triggerListeners("subscription.r emoved", subscription); 107 modules.filterNotifier.FilterNotifier.triggerListeners("subscription.r emoved", subscription);
108 } 108 }
109 } 109 },
110
111 addFilter: function() {},
112 removeFilter: function() {}
110 } 113 }
111 }; 114 };
112 115
113 modules.filterClasses = { 116 modules.filterClasses = {
117 Filter: function(text)
118 {
119 this.text = text;
120 },
114 BlockingFilter: function() {} 121 BlockingFilter: function() {}
115 }; 122 };
123 modules.filterClasses.Filter.fromText = function(text)
124 {
125 return new modules.filterClasses.Filter(text);
126 };
116 127
117 modules.synchronizer = { 128 modules.synchronizer = {
118 Synchronizer: {} 129 Synchronizer: {}
119 }; 130 };
120 131
121 modules.matcher = { 132 modules.matcher = {
122 defaultMatcher: { 133 defaultMatcher: {
123 matchesAny: function(url, requestType, docDomain, thirdParty) 134 matchesAny: function(url, requestType, docDomain, thirdParty)
124 { 135 {
125 var params = {blockedURLs: ""}; 136 var params = {blockedURLs: ""};
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 { 184 {
174 return parseFloat(v1) - parseFloat(v2); 185 return parseFloat(v1) - parseFloat(v2);
175 } 186 }
176 } 187 }
177 }; 188 };
178 189
179 var issues = {seenDataCorruption: false, filterlistsReinitialized: false}; 190 var issues = {seenDataCorruption: false, filterlistsReinitialized: false};
180 updateFromURL(issues); 191 updateFromURL(issues);
181 global.seenDataCorruption = issues.seenDataCorruption; 192 global.seenDataCorruption = issues.seenDataCorruption;
182 global.filterlistsReinitialized = issues.filterlistsReinitialized; 193 global.filterlistsReinitialized = issues.filterlistsReinitialized;
194
195 ext.devtools.onCreated.addListener(function(panel)
196 {
197 // blocked request
198 panel.sendMessage({
199 type: "add-record",
200 request: {
201 url: "http://adserver.example.com/ad_banner.png",
202 type: "IMAGE",
203 docDomain: "example.com"
204 },
205 filter: {
206 text: "/ad_banner*$domain=example.com",
207 whitelisted: false,
208 userDefined: false,
209 subscription: "EasyList"
210 }
211 });
212
213 // whiletisted request
Thomas Greiner 2015/03/13 11:11:05 Replace "whiletisted" with "whitelisted"
Sebastian Noack 2015/03/13 13:07:38 Done.
214 panel.sendMessage({
215 type: "add-record",
216 request: {
217 url: "http://example.com/looks_like_an_ad_but_isnt_one.html",
218 type: "SUBDOCUMENT",
219 docDomain: "example.com"
220 },
221 filter: {
222 text: "@@||example.com/looks_like_an_ad_but_isnt_one.html",
223 whitelisted: true,
224 userDefined: false,
225 subscription: "EasyList"
226 }
227 });
228
229 // request with long URL and no filter matches
230 panel.sendMessage({
231 type: "add-record",
232 request: {
233 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",
234 type: "XMLHTTPREQUEST",
235 docDomain: "example.com"
236 },
237 filter: null
238 });
239
240 // matching element hiding filter
241 panel.sendMessage({
242 type: "add-record",
243 request: {
244 type: "ELEMHIDE",
245 docDomain: "example.com"
246 },
247 filter: {
248 text: "example.com##.ad_banner",
249 whitelisted: false,
250 userDefined: false,
251 subscription: "EasyList"
252 }
253 });
254
255 // user-defined filter
256 panel.sendMessage({
257 type: "add-record",
258 request: {
259 url: "http://example.com/some-annoying-popup",
260 type: "POPUP",
261 docDomain: "example.com"
262 },
263 filter: {
264 text: "||example.com/some-annoying-popup$popup",
265 whitelisted: false,
266 userDefined: true,
267 subscription: null
268 }
269 });
270 });
183 })(this); 271 })(this);
OLDNEW
« no previous file with comments | « no previous file | devtools-panel.html » ('j') | devtools-panel.js » ('J')

Powered by Google App Engine
This is Rietveld