| 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 |
| 192 getRelatedTabIds(details).then(tabIds => | 209 getRelatedTabIds(details).then(tabIds => |
| 193 { | 210 { |
| 194 logRequest( | 211 logRequest( |
| 195 tabIds, | 212 tabIds, |
| 196 {url: details.url, type, docDomain, thirdParty, sitekey, specificOnly}, | 213 { |
| 214 url: details.url, type, docDomain, thirdParty, |
| 215 sitekey, specificOnly, rewrittenUrl |
| 216 }, |
| 197 filter | 217 filter |
| 198 ); | 218 ); |
| 199 }); | 219 }); |
| 200 | 220 |
| 201 if (filter instanceof BlockingFilter) | 221 return result; |
| 202 return {cancel: true}; | |
| 203 }, {urls: ["<all_urls>"]}, ["blocking"]); | 222 }, {urls: ["<all_urls>"]}, ["blocking"]); |
| 204 | 223 |
| 205 port.on("filters.collapse", (message, sender) => | 224 port.on("filters.collapse", (message, sender) => |
| 206 { | 225 { |
| 207 let {page, frame} = sender; | 226 let {page, frame} = sender; |
| 208 | 227 |
| 209 if (checkWhitelisted(page, frame)) | 228 if (checkWhitelisted(page, frame)) |
| 210 return false; | 229 return false; |
| 211 | 230 |
| 212 let blocked = false; | 231 let blocked = false; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 } | 328 } |
| 310 | 329 |
| 311 FilterNotifier.on("subscription.added", onFilterChange); | 330 FilterNotifier.on("subscription.added", onFilterChange); |
| 312 FilterNotifier.on("subscription.removed", onFilterChange); | 331 FilterNotifier.on("subscription.removed", onFilterChange); |
| 313 FilterNotifier.on("subscription.updated", onFilterChange); | 332 FilterNotifier.on("subscription.updated", onFilterChange); |
| 314 FilterNotifier.on("subscription.disabled", arg => onFilterChange(arg, true)); | 333 FilterNotifier.on("subscription.disabled", arg => onFilterChange(arg, true)); |
| 315 FilterNotifier.on("filter.added", onFilterChange); | 334 FilterNotifier.on("filter.added", onFilterChange); |
| 316 FilterNotifier.on("filter.removed", onFilterChange); | 335 FilterNotifier.on("filter.removed", onFilterChange); |
| 317 FilterNotifier.on("filter.disabled", arg => onFilterChange(arg, true)); | 336 FilterNotifier.on("filter.disabled", arg => onFilterChange(arg, true)); |
| 318 FilterNotifier.on("load", onFilterChange); | 337 FilterNotifier.on("load", onFilterChange); |
| OLD | NEW |