| OLD | NEW | 
|---|
| 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-2016 Eyeo GmbH | 3  * Copyright (C) 2006-2016 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.BlockingFilter = BlockingFilter; | 20   this.RegExpFilter = RegExpFilter; | 
| 21   this.WhitelistFilter = WhitelistFilter; | 21   this.WhitelistFilter = WhitelistFilter; | 
| 22   this.RegExpFilter = RegExpFilter; |  | 
| 23 } |  | 
| 24 with(require("whitelisting")) |  | 
| 25 { |  | 
| 26   this.checkWhitelisted = checkWhitelisted; |  | 
| 27   this.getKey = getKey; |  | 
| 28 } |  | 
| 29 with(require("url")) |  | 
| 30 { |  | 
| 31   this.stringifyURL = stringifyURL; |  | 
| 32   this.isThirdParty = isThirdParty; |  | 
| 33   this.extractHostFromFrame = extractHostFromFrame; |  | 
| 34 } | 22 } | 
| 35 var FilterStorage = require("filterStorage").FilterStorage; | 23 var FilterStorage = require("filterStorage").FilterStorage; | 
| 36 var SpecialSubscription = require("subscriptionClasses").SpecialSubscription; | 24 var SpecialSubscription = require("subscriptionClasses").SpecialSubscription; | 
| 37 var ElemHide = require("elemHide").ElemHide; | 25 var ElemHide = require("elemHide").ElemHide; | 
| 38 var defaultMatcher = require("matcher").defaultMatcher; | 26 var checkWhitelisted = require("whitelisting").checkWhitelisted; | 
| 39 var Prefs = require("prefs").Prefs; | 27 var extractHostFromFrame = require("url").extractHostFromFrame; | 
| 40 var port = require("messaging").port; | 28 var port = require("messaging").port; | 
| 41 var devtools = require("devtools"); | 29 var devtools = require("devtools"); | 
| 42 | 30 | 
| 43 // This is a hack to speedup loading of the options page on Safari. | 31 // This is a hack to speedup loading of the options page on Safari. | 
| 44 // Once we replaced the background page proxy with message passing | 32 // Once we replaced the background page proxy with message passing | 
| 45 // this global function should removed. | 33 // this global function should removed. | 
| 46 function getUserFilters() | 34 function getUserFilters() | 
| 47 { | 35 { | 
| 48   var filters = []; | 36   var filters = []; | 
| 49   var exceptions = []; | 37   var exceptions = []; | 
| (...skipping 29 matching lines...) Expand all  Loading... | 
| 79       extractHostFromFrame(sender.frame), | 67       extractHostFromFrame(sender.frame), | 
| 80       checkWhitelisted(sender.page, sender.frame, | 68       checkWhitelisted(sender.page, sender.frame, | 
| 81                        RegExpFilter.typeMap.GENERICHIDE) | 69                        RegExpFilter.typeMap.GENERICHIDE) | 
| 82     ); | 70     ); | 
| 83   else | 71   else | 
| 84     selectors = []; | 72     selectors = []; | 
| 85 | 73 | 
| 86   return {selectors: selectors, trace: trace}; | 74   return {selectors: selectors, trace: trace}; | 
| 87 }); | 75 }); | 
| 88 | 76 | 
| 89 port.on("should-collapse", function(msg, sender) |  | 
| 90 { |  | 
| 91   if (checkWhitelisted(sender.page, sender.frame)) |  | 
| 92     return false; |  | 
| 93 |  | 
| 94   var typeMask = RegExpFilter.typeMap[msg.mediatype]; |  | 
| 95   var documentHost = extractHostFromFrame(sender.frame); |  | 
| 96   var sitekey = getKey(sender.page, sender.frame); |  | 
| 97   var blocked = false; |  | 
| 98 |  | 
| 99   var specificOnly = checkWhitelisted( |  | 
| 100     sender.page, sender.frame, |  | 
| 101     RegExpFilter.typeMap.GENERICBLOCK |  | 
| 102   ); |  | 
| 103 |  | 
| 104   for (var i = 0; i < msg.urls.length; i++) |  | 
| 105   { |  | 
| 106     var url = new URL(msg.urls[i], msg.baseURL); |  | 
| 107     var filter = defaultMatcher.matchesAny( |  | 
| 108       stringifyURL(url), typeMask, |  | 
| 109       documentHost, isThirdParty(url, documentHost), |  | 
| 110       sitekey, specificOnly |  | 
| 111     ); |  | 
| 112 |  | 
| 113     if (filter instanceof BlockingFilter) |  | 
| 114     { |  | 
| 115       if (filter.collapse != null) |  | 
| 116         return filter.collapse; |  | 
| 117 |  | 
| 118       blocked = true; |  | 
| 119     } |  | 
| 120   } |  | 
| 121 |  | 
| 122   return blocked && Prefs.hidePlaceholders; |  | 
| 123 }); |  | 
| 124 |  | 
| 125 port.on("forward", function(msg, sender) | 77 port.on("forward", function(msg, sender) | 
| 126 { | 78 { | 
| 127   var targetPage; | 79   var targetPage; | 
| 128   if (msg.targetPageId) | 80   if (msg.targetPageId) | 
| 129     targetPage = ext.getPage(msg.targetPageId); | 81     targetPage = ext.getPage(msg.targetPageId); | 
| 130   else | 82   else | 
| 131     targetPage = sender.page; | 83     targetPage = sender.page; | 
| 132 | 84 | 
| 133   if (targetPage) | 85   if (targetPage) | 
| 134   { | 86   { | 
| 135     msg.payload.sender = sender.page.id; | 87     msg.payload.sender = sender.page.id; | 
| 136     if (msg.expectsResponse) | 88     if (msg.expectsResponse) | 
| 137       return new Promise(targetPage.sendMessage.bind(targetPage, msg.payload)); | 89       return new Promise(targetPage.sendMessage.bind(targetPage, msg.payload)); | 
| 138     targetPage.sendMessage(msg.payload); | 90     targetPage.sendMessage(msg.payload); | 
| 139   } | 91   } | 
| 140 }); | 92 }); | 
| OLD | NEW | 
|---|