-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfb-untract-links.user.js
48 lines (42 loc) · 1.58 KB
/
fb-untract-links.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// ==UserScript==
// @name Facebook untrack links
// @namespace https://github.com/burtek/tampermonkey-scripts
// @version 1.0.1
// @description Remove facebook tracking data from any link you open or copy through facebook. If something doesn't work let me know and I'll fix it!
// @author burtek <[email protected]>
// @match https://www.facebook.com/*
// @run-at document-body
// @supportURL https://github.com/burtek/tampermonkey-scripts/issues
// ==/UserScript==
(function(TRACKING_KEYS) {
function onClick(event) {
console.log(event);
if ([0, 1, 2].includes(event.button)) {
var aParent = event.target.closest('a[href]');
if (!aParent) {
return;
}
var url = new URL(aParent.href);
var keysToRemove = [];
url.searchParams.forEach(function(value, key) {
function doesKeyPatternTest(keyPattern) {
return keyPattern.test(key);
};
if (TRACKING_KEYS.some(doesKeyPatternTest)) {
console.log('Removed key', key, 'with value', value, 'from element', aParent);
keysToRemove.push(key);
}
});
keysToRemove.forEach(function(key) {
url.searchParams.delete(key);
});
aParent.href = url.toString();
}
}
document.addEventListener('click', onClick, true);
document.addEventListener('auxclick', onClick, true);
})([
/^__xts__/,
/^__tn__$/,
/^fbclid$/
]);