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

Side by Side Diff: background.js

Issue 5138680696012800: Issue 616 - Enforce $generichide and $genericblock in Chrome (Closed)
Patch Set: Rebased onto typeMask changes Created July 14, 2015, 4:54 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 | popupBlocker.js » ('j') | no next file with comments »
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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 { 298 {
299 switch (msg.type) 299 switch (msg.type)
300 { 300 {
301 case "get-selectors": 301 case "get-selectors":
302 var selectors = []; 302 var selectors = [];
303 303
304 if (!isFrameWhitelisted(sender.page, sender.frame, 304 if (!isFrameWhitelisted(sender.page, sender.frame,
305 RegExpFilter.typeMap.DOCUMENT | RegExpFilter.typeM ap.ELEMHIDE)) 305 RegExpFilter.typeMap.DOCUMENT | RegExpFilter.typeM ap.ELEMHIDE))
306 { 306 {
307 var noStyleRules = false; 307 var noStyleRules = false;
308 var specificOnly = isFrameWhitelisted(sender.page, sender.frame, RegExpF ilter.typeMap.GENERICHIDE);
308 var host = extractHostFromFrame(sender.frame); 309 var host = extractHostFromFrame(sender.frame);
310
309 for (var i = 0; i < noStyleRulesHosts.length; i++) 311 for (var i = 0; i < noStyleRulesHosts.length; i++)
310 { 312 {
311 var noStyleHost = noStyleRulesHosts[i]; 313 var noStyleHost = noStyleRulesHosts[i];
312 if (host == noStyleHost || (host.length > noStyleHost.length && 314 if (host == noStyleHost || (host.length > noStyleHost.length &&
313 host.substr(host.length - noStyleHost.leng th - 1) == "." + noStyleHost)) 315 host.substr(host.length - noStyleHost.leng th - 1) == "." + noStyleHost))
314 { 316 {
315 noStyleRules = true; 317 noStyleRules = true;
316 } 318 }
317 } 319 }
318 selectors = ElemHide.getSelectorsForDomain(host, false); 320 selectors = ElemHide.getSelectorsForDomain(host, specificOnly);
319 if (noStyleRules) 321 if (noStyleRules)
320 { 322 {
321 selectors = selectors.filter(function(s) 323 selectors = selectors.filter(function(s)
322 { 324 {
323 return !/\[style[\^\$]?=/.test(s); 325 return !/\[style[\^\$]?=/.test(s);
324 }); 326 });
325 } 327 }
326 } 328 }
327 329
328 sendResponse(selectors); 330 sendResponse(selectors);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 break; 426 break;
425 } 427 }
426 }); 428 });
427 429
428 // update icon when page changes location 430 // update icon when page changes location
429 ext.pages.onLoading.addListener(function(page) 431 ext.pages.onLoading.addListener(function(page)
430 { 432 {
431 page.sendMessage({type: "clickhide-deactivate"}); 433 page.sendMessage({type: "clickhide-deactivate"});
432 refreshIconAndContextMenu(page); 434 refreshIconAndContextMenu(page);
433 }); 435 });
OLDNEW
« no previous file with comments | « no previous file | popupBlocker.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld