Greasy Fork is available in English.
将网页中的网址文字都替换成链接
当前为
// ==UserScript==
// @name 生成链接
// @namespace Violentmonkey Scripts
// @match *://*/*
// @grant none
// @version 1.1.2
// @author amateur
// @description 将网页中的网址文字都替换成链接
// ==/UserScript==
// 网页加载完成后执行
window.onload = function () {
let res = new Array();
// res[0] = new RegExp('https?://.*/(.*?\.(html|htm|php|jsp))?', 'g');
res[0] = new RegExp('https?://.*([/ ]|html|htm|php|jsp)', 'g');
// 根据选择器获取标签
body = document.querySelector('body');
for (const re of res) {
let urls = body.innerText.match(re);
for (const url of urls) {
body.innerHTML = body.innerHTML.replace(url, `<a href=${url} target="_blank">${url}</a>`);
}
}
}