您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Turn plain text URLs into clickable links
当前为
- // ==UserScript==
- // @name Linkify Plain Text URLs
- // @version 1.0.0
- // @author salad: https://greasyfork.org/en/users/241444-salad
- // @description Turn plain text URLs into clickable links
- // @namespace https://greasyfork.org/users/241444
- // @include *
- // @run-at document-idle
- // @grant GM_registerMenuCommand
- // ==/UserScript==
- /* dunno who wrote this. I just converted a bookmarklet to a userscript. */
- (function () {
- function linkifyPlainText() {
- document.body.normalize();
- function linkifyNode(n) {
- var M, R, currentNode;
- if (n.nodeType == 3) {
- const urlPosition = n.data.search(/https?:\/\/[^\s]*/);
- if (urlPosition < 0) return;
- M = n.splitText(urlPosition);
- R = M.splitText(RegExp.lastMatch.length);
- const linkTag = document.createElement("A");
- linkTag.href = M.data;
- linkTag.appendChild(M);
- R.parentNode.insertBefore(linkTag, R);
- } else if (n.tagName != "STYLE" && n.tagName != "SCRIPT" && n.tagName != "A")
- for (let i = 0; currentNode = n.childNodes[i]; ++i) {
- linkifyNode(currentNode);
- }
- }
- linkifyNode(document.body);
- }
- GM_registerMenuCommand('Linkify Plain Text URLs', linkifyPlainText);
- })();