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

Side by Side Diff: background.js

Issue 5838948538515456: Issue 370 - Make "Block element" hide elements for added filters (Closed)
Patch Set: Restored failsafe code Created March 4, 2015, 3:07 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 | block.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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 with(require("filterClasses")) 18 with(require("filterClasses"))
19 { 19 {
20 this.Filter = Filter; 20 this.Filter = Filter;
21 this.BlockingFilter = BlockingFilter; 21 this.BlockingFilter = BlockingFilter;
22 this.WhitelistFilter = WhitelistFilter; 22 this.WhitelistFilter = WhitelistFilter;
23 this.ElemHideFilter = ElemHideFilter;
23 } 24 }
24 with(require("subscriptionClasses")) 25 with(require("subscriptionClasses"))
25 { 26 {
26 this.Subscription = Subscription; 27 this.Subscription = Subscription;
27 this.DownloadableSubscription = DownloadableSubscription; 28 this.DownloadableSubscription = DownloadableSubscription;
28 this.SpecialSubscription = SpecialSubscription; 29 this.SpecialSubscription = SpecialSubscription;
29 } 30 }
30 with(require("whitelisting")) 31 with(require("whitelisting"))
31 { 32 {
32 this.isPageWhitelisted = isPageWhitelisted; 33 this.isPageWhitelisted = isPageWhitelisted;
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 try 528 try
528 { 529 {
529 filters = parseFilters(msg.text); 530 filters = parseFilters(msg.text);
530 } 531 }
531 catch (error) 532 catch (error)
532 { 533 {
533 sendResponse({status: "invalid", error: error}); 534 sendResponse({status: "invalid", error: error});
534 break; 535 break;
535 } 536 }
536 537
538 var selectors = [];
537 for (var i = 0; i < filters.length; i++) 539 for (var i = 0; i < filters.length; i++)
538 FilterStorage.addFilter(filters[i]); 540 {
541 var filter = filters[i];
542 FilterStorage.addFilter(filter);
539 543
540 sendResponse({status: "ok"}); 544 if (filter instanceof ElemHideFilter)
545 selectors.push(filter.selector);
546 }
547
548 sendResponse({status: "ok", selectors: selectors});
541 break; 549 break;
542 case "add-subscription": 550 case "add-subscription":
543 ext.showOptions(function(page) 551 ext.showOptions(function(page)
544 { 552 {
545 page.sendMessage(msg); 553 page.sendMessage(msg);
546 }); 554 });
547 break; 555 break;
548 case "add-sitekey": 556 case "add-sitekey":
549 processKey(msg.token, sender.page, sender.frame); 557 processKey(msg.token, sender.page, sender.frame);
550 break; 558 break;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 page.sendMessage({type: "clickhide-deactivate"}); 595 page.sendMessage({type: "clickhide-deactivate"});
588 refreshIconAndContextMenu(page); 596 refreshIconAndContextMenu(page);
589 }); 597 });
590 598
591 setTimeout(function() 599 setTimeout(function()
592 { 600 {
593 var notificationToShow = NotificationStorage.getNextToShow(); 601 var notificationToShow = NotificationStorage.getNextToShow();
594 if (notificationToShow) 602 if (notificationToShow)
595 showNotification(notificationToShow); 603 showNotification(notificationToShow);
596 }, 3 * 60 * 1000); 604 }, 3 * 60 * 1000);
OLDNEW
« no previous file with comments | « no previous file | block.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld