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

Side by Side Diff: background.js

Issue 4734012065054720: Issue 2634 - Consider alternative URLs for element collapsing (Closed)
Patch Set: Consider all URLs for element collapsing Created June 7, 2015, 3:14 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 | include.postload.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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 326
327 sendResponse(selectors); 327 sendResponse(selectors);
328 break; 328 break;
329 case "should-collapse": 329 case "should-collapse":
330 if (isFrameWhitelisted(sender.page, sender.frame, "DOCUMENT")) 330 if (isFrameWhitelisted(sender.page, sender.frame, "DOCUMENT"))
331 { 331 {
332 sendResponse(false); 332 sendResponse(false);
333 break; 333 break;
334 } 334 }
335 335
336 var url = new URL(msg.url);
337 var documentHost = extractHostFromFrame(sender.frame); 336 var documentHost = extractHostFromFrame(sender.frame);
338 var filter = defaultMatcher.matchesAny( 337 var blocked = false;
339 stringifyURL(url), msg.mediatype,
340 documentHost, isThirdParty(url, documentHost)
341 );
342 338
343 if (filter instanceof BlockingFilter) 339 for (var i = 0; i < msg.urls.length; i++)
344 { 340 {
345 var collapse = filter.collapse; 341 var url = new URL(msg.urls[i], msg.baseURL);
346 if (collapse == null) 342 var filter = defaultMatcher.matchesAny(
347 collapse = Prefs.hidePlaceholders; 343 stringifyURL(url), msg.mediatype,
348 sendResponse(collapse); 344 documentHost, isThirdParty(url, documentHost)
345 );
346
347 if (filter instanceof BlockingFilter)
348 {
349 if (filter.collapse != null)
350 {
351 sendResponse(filter.collapse);
352 return;
353 }
354
355 blocked = true;
356 }
349 } 357 }
350 else 358
351 sendResponse(false); 359 sendResponse(blocked && Prefs.hidePlaceholders);
352 break; 360 break;
353 case "get-domain-enabled-state": 361 case "get-domain-enabled-state":
354 // Returns whether this domain is in the exclusion list. 362 // Returns whether this domain is in the exclusion list.
355 // The browser action popup asks us this. 363 // The browser action popup asks us this.
356 if(sender.page) 364 if(sender.page)
357 { 365 {
358 sendResponse({enabled: !isPageWhitelisted(sender.page)}); 366 sendResponse({enabled: !isPageWhitelisted(sender.page)});
359 return; 367 return;
360 } 368 }
361 break; 369 break;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 break; 422 break;
415 } 423 }
416 }); 424 });
417 425
418 // update icon when page changes location 426 // update icon when page changes location
419 ext.pages.onLoading.addListener(function(page) 427 ext.pages.onLoading.addListener(function(page)
420 { 428 {
421 page.sendMessage({type: "clickhide-deactivate"}); 429 page.sendMessage({type: "clickhide-deactivate"});
422 refreshIconAndContextMenu(page); 430 refreshIconAndContextMenu(page);
423 }); 431 });
OLDNEW
« no previous file with comments | « no previous file | include.postload.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld