// ==UserScript== // @name 无忌摄影论坛外链复原脚本 // @namespace https://forum.xitek.com/ // @version 0.2 // @description 无忌论坛最近很多外链被转义无法正常访问,不少图床图片也因为转义显示异常,通过3行js代码进行恢复处理 // @author 老鼠不相往来 // @match *://*.xitek.com/thread* // @match *://*.xitek.com/*viewthread* // @match *://*.xitek.com/*tid=* // @grant none // @run-at document-end // @downloadURL none // ==/UserScript== (function () { 'use strict'; var els = document.getElementsByClassName('t_f');//查找帖子节点 [].forEach.call(els, function (el) {//遍历帖子节点 Array.prototype.forEach.call(el.childNodes, function (son) {//遍历帖子节点的子节点 //console.log(Object.prototype.toString.call(son)); if (son instanceof Text) {//纯文本节点中可能存在外链域名替换,进行文本替换修正 son.data = son.data.replaceAll('·', '.'); } else if (son instanceof HTMLImageElement) {//图片节点中可能存在外链域名替换,图片源进行替换修正 son.src = son.attributes["src"].value.replaceAll('·', '.'); } else if (son instanceof HTMLAnchorElement) {//链接节点中可能存在外链域名替换,进行内容替换修正 son.innerHTML = son.innerHTML.replaceAll('·', '.'); }; }); }); })();