MCPcopy
hub / github.com/ClearURLs/Addon / removeFieldsFormURL

Function removeFieldsFormURL

clearurls.js:40–167  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

38 * @return {Array} Array with changes and url fields
39 */
40function 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

Callers 2

clearUrlFunction · 0.85
_cleaningFunction · 0.85

Calls 13

checkLocalURLFunction · 0.85
decodeURLFunction · 0.85
pushToLogFunction · 0.85
increaseTotalCounterFunction · 0.85
increaseBadgedFunction · 0.85
extractFragmentsFunction · 0.85
urlWithoutParamsAndHashFunction · 0.85
urlSearchParamsToStringFunction · 0.85
forEachMethod · 0.80
toStringMethod · 0.80
translateFunction · 0.50
keysMethod · 0.45

Tested by

no test coverage detected