您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
自动将页面所有文本转换为链接
当前为
// ==UserScript== // @name AutoLinker // @namespace tea.pm // @include * // @grant none // @version 1.0 // @author cljnnn // @description 自动将页面所有文本转换为链接 // @description_en trun url in text to link // ==/UserScript== String.prototype.isEmpty = function() { return (this.length === 0 || !this.trim()); }; const reUrl = /\b(https?:\/\/\S*)\b/g; function fixURL(node) { value = node.nodeValue; // console.log("updating link... ", value); newValue = value.replace(reUrl, '<a target="_blank" href="$1">$1</a>'); var replacementNode = document.createElement('span'); replacementNode.innerHTML = newValue; node.parentNode.insertBefore(replacementNode, node); node.parentNode.removeChild(node); } function traverse(node) { if(!node) { return; } if(node.nodeType != Node.ELEMENT_NODE && node.nodeType != Node.TEXT_NODE) { return; } let name = node.nodeName; if(name == "SCRIPT" || name == "STYLE" || name == "A") { return; } if(node.nodeType == Node.TEXT_NODE) { let value = node.nodeValue; if(!value.isEmpty()) { if(value.match(reUrl)) { fixURL(node); } } } for(let child of node.childNodes) { traverse(child); } } setTimeout(function(){ traverse(document.body); }, 2000);
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址