// ==UserScript==
// @name 网页文本转链接
// @description 网页中文本转为可点击链接 添加颜色下划线
// @version 2.4
// @author WJ
// @match *://*/*
// @license MIT
// @grant none
// @namespace https://greasyfork.org/users/914996
// @downloadURL none
// ==/UserScript==
(function(){
document.head.insertAdjacentHTML('beforeend','');
const r=/\b[\w.:/?=%-]{3,}\.(?:app|aero|aer|art|asia|beer|biz|cat|cc|chat|ci|cloud|club|cn|com|cool|coop|co|dev|edu|email|fit|fun|gov|group|hk|host|icu|info|ink|int|io|jobs|kim|love|ltd|luxe|me|mil|mobi|moe|museum|name|net|nl|network|one|online|org|plus|post|press|pro|red|ren|run|ru|shop|site|si|space|store|tech|tel|top|travel|tv|tw|uk|us|video|vip|wang|website|wiki|wml|work|ws|xin|xyz|yoga|zone)(?!\w)[\w.:/?=%-]*/gi;
const w=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT,{acceptNode:n=>['TEXTAREA','BUTTON','SCRIPT','SELECT','OPTION','STYLE','CODE','PRE','A'].includes(n.parentNode.tagName)?0:1});
const p=[];
while(n=w.nextNode()){
if(!r.test(n.textContent))continue;
const s=document.createElement('span');
s.innerHTML=n.textContent.replace(r,m=>`${m}`);
p.push([n,s])};
p.forEach(([n,s])=>n.parentNode.replaceChild(s,n));
})();