Decloak links and open directly

Open redirected/cloaked links directly

目前为 2017-05-25 提交的版本。查看 最新版本

// ==UserScript==
// @name          Decloak links and open directly
// @description   Open redirected/cloaked links directly
// @version       1.1.3
// @author        wOxxOm
// @namespace     wOxxOm.scripts
// @icon          https://i.imgur.com/cfmXJHv.png
// @license       MIT License
// @run-at        document-start
// @match         *://*/*
// ==/UserScript==

/* jshint lastsemic:true, multistr:true, laxbreak:true, -W030, -W041, -W084 */

window.addEventListener('mousedown', decloak, true);
window.addEventListener('keydown', function(e) { if (e.keyCode == 13) decloak(e) }, true);

function decloak(e) {
	var a = e.target.closest('a');
	if (!a || !a.href.match(/^(http|ftp)/))
		return;

	if (e.altKey)
		return console.debug('Decloak skipped: Alt key is pressed.');

	if (location.hostname.indexOf('yandex.') >= 0) {
		a.onmousedown = null;
		a.onclick = null;
	}

	var m = a.href.match(/=(\w+(?::\/\/|%3[Aa]%2[Ff]%2[Ff])[^+&?]+)/);
	if (!m) {
		return;
	}

	var realUrl = decodeURIComponent(m[1]);
	if (new URL(realUrl).hostname == a.hostname)
		return console.debug('Decloak skipped: the hostnames are same, assumed a login redirection.');

	if (a.hostname == 'disq.us' && realUrl.lastIndexOf(':') != realUrl.indexOf(':'))
		realUrl = realUrl.substr(0, realUrl.lastIndexOf(':'));
	a.href = realUrl;
}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址