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