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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 | 182 |
183 if (checkWhitelisted(page, frame, originUrl)) | 183 if (checkWhitelisted(page, frame, originUrl)) |
184 return; | 184 return; |
185 | 185 |
186 let type = resourceTypes.get(details.type) || "OTHER"; | 186 let type = resourceTypes.get(details.type) || "OTHER"; |
187 let [docDomain, sitekey, specificOnly] = getDocumentInfo(page, frame, | 187 let [docDomain, sitekey, specificOnly] = getDocumentInfo(page, frame, |
188 originUrl); | 188 originUrl); |
189 let [filter, thirdParty] = matchRequest(url, type, docDomain, | 189 let [filter, thirdParty] = matchRequest(url, type, docDomain, |
190 sitekey, specificOnly); | 190 sitekey, specificOnly); |
191 | 191 |
192 let result; | |
193 let rewrittenUrl; | |
194 | |
195 if (filter instanceof BlockingFilter) | |
196 { | |
197 if (filter.rewrite) | |
198 { | |
199 rewrittenUrl = filter.rewriteUrl(details.url); | |
200 // If no rewrite happened (error, different origin), we'll | |
201 // return undefined in order to avoid an "infinite" loop. | |
202 if (rewrittenUrl != details.url) | |
203 result = {redirectUrl: rewrittenUrl}; | |
204 } | |
205 else | |
206 result = {cancel: true}; | |
207 } | |
208 | |
209 getRelatedTabIds(details).then(tabIds => | 192 getRelatedTabIds(details).then(tabIds => |
210 { | 193 { |
211 logRequest( | 194 logRequest( |
212 tabIds, | 195 tabIds, |
213 { | 196 {url: details.url, type, docDomain, thirdParty, sitekey, specificOnly}, |
214 url: details.url, type, docDomain, thirdParty, | |
215 sitekey, specificOnly, rewrittenUrl | |
216 }, | |
217 filter | 197 filter |
218 ); | 198 ); |
219 }); | 199 }); |
220 | 200 |
221 return result; | 201 if (filter instanceof BlockingFilter) |
| 202 return {cancel: true}; |
222 }, {urls: ["<all_urls>"]}, ["blocking"]); | 203 }, {urls: ["<all_urls>"]}, ["blocking"]); |
223 | 204 |
224 port.on("filters.collapse", (message, sender) => | 205 port.on("filters.collapse", (message, sender) => |
225 { | 206 { |
226 let {page, frame} = sender; | 207 let {page, frame} = sender; |
227 | 208 |
228 if (checkWhitelisted(page, frame)) | 209 if (checkWhitelisted(page, frame)) |
229 return false; | 210 return false; |
230 | 211 |
231 let blocked = false; | 212 let blocked = false; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 } | 309 } |
329 | 310 |
330 FilterNotifier.on("subscription.added", onFilterChange); | 311 FilterNotifier.on("subscription.added", onFilterChange); |
331 FilterNotifier.on("subscription.removed", onFilterChange); | 312 FilterNotifier.on("subscription.removed", onFilterChange); |
332 FilterNotifier.on("subscription.updated", onFilterChange); | 313 FilterNotifier.on("subscription.updated", onFilterChange); |
333 FilterNotifier.on("subscription.disabled", arg => onFilterChange(arg, true)); | 314 FilterNotifier.on("subscription.disabled", arg => onFilterChange(arg, true)); |
334 FilterNotifier.on("filter.added", onFilterChange); | 315 FilterNotifier.on("filter.added", onFilterChange); |
335 FilterNotifier.on("filter.removed", onFilterChange); | 316 FilterNotifier.on("filter.removed", onFilterChange); |
336 FilterNotifier.on("filter.disabled", arg => onFilterChange(arg, true)); | 317 FilterNotifier.on("filter.disabled", arg => onFilterChange(arg, true)); |
337 FilterNotifier.on("load", onFilterChange); | 318 FilterNotifier.on("load", onFilterChange); |
OLD | NEW |