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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 port.on("filters.isWhitelisted", message => | 86 port.on("filters.isWhitelisted", message => |
87 { | 87 { |
88 return !!checkWhitelisted(new ext.Page(message.tab)); | 88 return !!checkWhitelisted(new ext.Page(message.tab)); |
89 }); | 89 }); |
90 | 90 |
91 port.on("filters.whitelist", message => | 91 port.on("filters.whitelist", message => |
92 { | 92 { |
93 let page = new ext.Page(message.tab); | 93 let page = new ext.Page(message.tab); |
94 let host = page.url.hostname.replace(/^www\./, ""); | 94 let host = page.url.hostname.replace(/^www\./, ""); |
95 let filter = Filter.fromText("@@||" + host + "^$document"); | 95 let filter = Filter.fromText("@@||" + host + "^$document"); |
96 if (filter.subscriptions.length && filter.disabled) | 96 if (filter.subscriptions.size && filter.disabled) |
97 { | 97 { |
98 filter.disabled = false; | 98 filter.disabled = false; |
99 } | 99 } |
100 else | 100 else |
101 { | 101 { |
102 filter.disabled = false; | 102 filter.disabled = false; |
103 FilterStorage.addFilter(filter); | 103 FilterStorage.addFilter(filter); |
104 } | 104 } |
105 }); | 105 }); |
106 | 106 |
107 port.on("filters.unwhitelist", message => | 107 port.on("filters.unwhitelist", message => |
108 { | 108 { |
109 let page = new ext.Page(message.tab); | 109 let page = new ext.Page(message.tab); |
110 // Remove any exception rules applying to this URL | 110 // Remove any exception rules applying to this URL |
111 let filter = checkWhitelisted(page); | 111 let filter = checkWhitelisted(page); |
112 while (filter) | 112 while (filter) |
113 { | 113 { |
114 FilterStorage.removeFilter(filter); | 114 FilterStorage.removeFilter(filter); |
115 if (filter.subscriptions.length) | 115 if (filter.subscriptions.size) |
116 filter.disabled = true; | 116 filter.disabled = true; |
117 filter = checkWhitelisted(page); | 117 filter = checkWhitelisted(page); |
118 } | 118 } |
119 }); | 119 }); |
120 | 120 |
121 function revalidateWhitelistingState(page) | 121 function revalidateWhitelistingState(page) |
122 { | 122 { |
123 FilterNotifier.emit( | 123 FilterNotifier.emit( |
124 "page.WhitelistingStateRevalidate", | 124 "page.WhitelistingStateRevalidate", |
125 page, checkWhitelisted(page) | 125 page, checkWhitelisted(page) |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 { | 234 { |
235 browser.webRequest.onHeadersReceived.addListener( | 235 browser.webRequest.onHeadersReceived.addListener( |
236 onHeadersReceived, | 236 onHeadersReceived, |
237 { | 237 { |
238 urls: ["http://*/*", "https://*/*"], | 238 urls: ["http://*/*", "https://*/*"], |
239 types: ["main_frame", "sub_frame"] | 239 types: ["main_frame", "sub_frame"] |
240 }, | 240 }, |
241 ["responseHeaders"] | 241 ["responseHeaders"] |
242 ); | 242 ); |
243 } | 243 } |
OLD | NEW |