* Helper function which remove the tracking fields * for each provider given as parameter. * * @param {Provider} provider Provider-Object * @param pureUrl URL as String * @param {boolean} quiet if the action should be displayed in log and statistics * @param {
(provider, pureUrl, quiet = false, request = null)
| 38 | * @return {Array} Array with changes and url fields |
| 39 | */ |
| 40 | function removeFieldsFormURL(provider, pureUrl, quiet = false, request = null) { |
| 41 | let url = pureUrl; |
| 42 | let domain = ""; |
| 43 | let fragments = ""; |
| 44 | let fields = ""; |
| 45 | let rules = provider.getRules(); |
| 46 | let changes = false; |
| 47 | let rawRules = provider.getRawRules(); |
| 48 | let urlObject = new URL(url); |
| 49 | |
| 50 | if (storage.localHostsSkipping && checkLocalURL(urlObject)) { |
| 51 | return { |
| 52 | "changes": false, |
| 53 | "url": url, |
| 54 | "cancel": false |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | /* |
| 59 | * Expand the url by provider redirections. So no tracking on |
| 60 | * url redirections form sites to sites. |
| 61 | */ |
| 62 | let re = provider.getRedirection(url); |
| 63 | if (re !== null) { |
| 64 | url = decodeURL(re); |
| 65 | |
| 66 | //Log the action |
| 67 | if (!quiet) { |
| 68 | pushToLog(pureUrl, url, translate('log_redirect')); |
| 69 | increaseTotalCounter(1); |
| 70 | increaseBadged(false, request) |
| 71 | } |
| 72 | |
| 73 | return { |
| 74 | "redirect": true, |
| 75 | "url": url |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | if (provider.isCaneling() && storage.domainBlocking) { |
| 80 | if (!quiet) pushToLog(pureUrl, pureUrl, translate('log_domain_blocked')); |
| 81 | increaseTotalCounter(1); |
| 82 | increaseBadged(quiet, request); |
| 83 | return { |
| 84 | "cancel": true, |
| 85 | "url": url |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | /* |
| 90 | * Apply raw rules to the URL. |
| 91 | */ |
| 92 | rawRules.forEach(function (rawRule) { |
| 93 | let beforeReplace = url; |
| 94 | url = url.replace(new RegExp(rawRule, "gi"), ""); |
| 95 | |
| 96 | if (beforeReplace !== url) { |
| 97 | //Log the action |
no test coverage detected