您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Direct links out
当前为
// ==UserScript== // @name Direct links // @name:ru Прямые ссылки // @namespace FIX // @version 0.0.6 // @description Direct links out // @description:ru Замена ссылок на прямые // @author raletag // @match *://*/* // @grant unsafeWindow // ==/UserScript== (function() { 'use strict'; console.time('Direct links load'); var win = unsafeWindow || window; var impCodes = '%3B%2C%2F%3F%3A%40%26%3D%2B%24%23', impRegex = new RegExp((impCodes.replace(/%/g,'|%').replace('|','')), 'gi'), impDecoded = decodeURIComponent(impCodes), impReplacer = function(ch) { return impDecoded[impCodes.indexOf(ch.toUpperCase())/3]; }; function decodeImportant(text) { return text.replace(impRegex, impReplacer); } function Handler (e) { console.time('HandlerTime'); try { var link = e.target, url = link.href, tourl; while (!url && link !== this) { link = link.parentNode; url = link.href; } link.removeEventListener('mouseenter', Handler, false); if (!url || /\/(share|intent\/tweet)([^?]*)\?/i.test(url)) { return true; } tourl = ((url.match(/[?&](url|r|z|to|u|go|st.link)=([^&]*)(&|$)/i)||url.match(/(\/leech_out\.php\?.:|\/phpBB2\/goto\/|\/go\/\?)(.*)/i)||[])[2]); if (!tourl) { return true; } try { tourl = decodeURIComponent(tourl); tourl = win.atob(tourl); tourl = decodeURIComponent(tourl); tourl = escape(tourl); } catch (err) { } tourl = decodeImportant(tourl); if (tourl.match(/^http(|s):\/\//i)) { console.group("Direct links"); console.info(url); console.info(tourl); link.href = tourl; console.timeEnd('HandlerTime'); console.groupEnd(); } } catch (err) { console.error('Direct links error: ' + err); console.timeEnd('HandlerTime'); alert('Direct links error: ' + err); return true; } return true; } function attachEvent (e) { var links = e.querySelectorAll('a[href]'); for (var i = links.length - 1; i >= 0; --i) { links[i].addEventListener('mouseenter', Handler, false); } } attachEvent(document); var o = new MutationObserver(function(ms){ ms.forEach(function(m){ m.addedNodes.forEach(function(n){ if (n.nodeType !== Node.ELEMENT_NODE) { return; } if (n.href) { n.addEventListener('mouseenter', Handler, false); } else { attachEvent(n); } }); }); }); o.observe(document, {childList: true, subtree: true}); console.timeEnd('Direct links load'); })();