-
Notifications
You must be signed in to change notification settings - Fork 2
/
removetco.user.js
37 lines (35 loc) · 1.01 KB
/
removetco.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
// ==UserScript==
// @name remove t.co
// @description Bypass t.co redirection from Twitter external links
// @namespace https://github.com/kkren
// @match *://twitter.com/*
// @grant none
// @require https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js
// @run-at document-end
// @downloadURL https://raw.githubusercontent.com/kkren/remove_t.co/master/removetco.user.js
// @version 0.5
// ==/UserScript==
function replace() {
var i = 0;
var urls = $("[href*='t.co']").length;
for (; i < urls; i++) {
if ($("[href*='t.co']").eq(i).attr("data-expanded-url") != undefined) {
var expanded = $("[href*='t.co']").eq(i).attr("data-expanded-url");
} else {
var expanded = $("[href*='t.co']").eq(i).attr("title");
}
$("[href*='t.co']").eq(i).attr("href", expanded);
}
}
//滚动加载
mo = new MutationObserver(function(allmutations) {
//alert();
replace();
});
var targets = document.body;
mo.observe(targets, {
'childList': true,
'characterData': true,
'subtree': true
});
replace();