Twitter remove t.co

将 Twitter 中所有 t.co 转为真实链接,仅适用于新 UI

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Twitter remove t.co
// @namespace    https://greasyfork.org/zh-CN/users/193133-pana
// @homepage     https://sailboatweb.com
// @version      1.0.0
// @description  将 Twitter 中所有 t.co 转为真实链接,仅适用于新 UI
// @author       pana
// @include      http*://*twitter.com/*
// @require      https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
// @grant        none
// ==/UserScript==

(function() {
	'use strict';

	function init() {
		let a_tags = $('a[href^="https://t.co/"]');
		$.each(a_tags, function(index, item) {
			let real_url;
			if (a_tags.eq(index).attr('data-expanded-url') !== undefined) {
				real_url = a_tags.eq(index).attr('data-expanded-url')
			} else if (item.title !== '') {
				real_url = item.title
			} else if ((a_tags.eq(index).find('div').length === 0) && (item.innerText !== "") && (item.innerText.indexOf('…') === -1)) {
				if (/^https?:\/\//i.test(item.innerText)) {
					real_url = item.innerText
				} else {
					real_url = 'http://' + item.innerText
				}
			} else {
				real_url = item.href
			}
			item.href = real_url
		})
	}
	init();
	let observer = new MutationObserver(function() {
		init()
	});
	let listenerContainer = document.body;
	let option = {
		'childList': true,
		'characterData': true,
		'subtree': true,
	};
	observer.observe(listenerContainer, option)
})();