-
Notifications
You must be signed in to change notification settings - Fork 0
/
TrueSlackLinks.user.js
38 lines (34 loc) · 1.29 KB
/
TrueSlackLinks.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
// ==UserScript==
// @author An_dz
// @version 2.1
// @name TrueSlackLink
// @description Remove the Slack tracking in links
// @date 2019 March 15
// @include https://*.slack.com/*
// @run-at document-start
// @grant none
// @license MIT
// @downloadURL https://github.com/An-dz/TrueLinks/raw/master/TrueSlackLinks.user.js
// ==/UserScript==
(function TrueSlackLink() {
// mutation observer is asynchronous, the link will load unchanged for a fraction of miliseconds but this should make the page more responsive
const observer = new MutationObserver((changes) => {
changes.forEach((chg) => {
chg.addedNodes.forEach((element) => {
// if the added node is not an element, e.g. Text Node
if (!element.querySelectorAll) {
return;
}
const links = element.querySelectorAll("a[target='_blank'][class='']:not([data-fixed])");
links.forEach((link) => {
const newLink = link.cloneNode(true);
newLink.dataset.fixed = true;
newLink.href = decodeURIComponent(newLink.href.replace("https://slack-redir.net/link?url=", ""));
link.parentNode.replaceChild(newLink, link);
});
});
});
});
// starts the mutation observer
observer.observe(document, {childList: true, subtree: true});
}());