yousihai 大佬有话说 :
论坛目田补丁
本帖最后由 yousihai 于 2021-6-17 11:13 编辑
脚本在附件中,下面的代码仅用过示例,由于论坛自动替换文字,所以不要使用!不要使用!不要使用
// ==UserScript==
// @name freeloc
// @namespace http://tampermonkey.net/
// @version 0.1
// @descriptiontry to take over the world!
// @author You
// @match https://www.hostloc.com/thread-*
// @match https://www.hostloc.com/forum.php?mod=viewthread*
// @match https://hostloc.com/forum.php?mod=viewthread*
// @match https://hostloc.com/thread-*
// @icon https://www.google.com/s2/favicons?domain=hostloc.com
// @grant none
// ==/UserScript==
(function() {
‘use strict’;
let keywordpairs = [{
a: "油管|有图比|油兔",
b: "有图比"
}, {
a: "推特",
b: "推特"
}, {
a: "脸书",
b: "FB"
}]
function free4all() {
document.querySelectorAll(".plhin td.t_f, .psti").forEach(el=>{
let html = el.innerHTML
keywordpairs.forEach(v=>{
html = html.replace(new RegExp("("+v.a+")", "g"), v.b)
});
html = html.replace(/((<a[^>]*>|")?)((s*)(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|])/g, ($0, $1, $2, $3, $4)=>{
return $1.length ? $0: $4+"<a href=’"+$3+"’ target=’_blank’>"+$3+"</a>"
})
el.innerHTML = html
})
}
if (document.readyState == "complete" || document.readyState == "loaded" || document.readyState == "interactive") {
free4all()
} else {
document.addEventListener("DOMContentLoaded", function(event) {
free4all();
});
}
})();
效果:
https://z3.ax1x.com/2021/06/17/2jX5Kf.png
说明:
不改变原始发帖效果。没有脚本的人看到的还是原来的样子。
不影响编辑,不影响引用回复,依然会引用原始内容。
不会替换已经是链接的文字。
r1172464137 大佬有话说 :
牛蛙牛蛙:lol
cherbim 大佬有话说 :
可以,这个就很赞
zxxx 大佬有话说 :
能不能在发帖的时候自动把网址转换成链接的形式?
yousihai 大佬有话说 :
本帖最后由 yousihai 于 2021-6-17 11:10 编辑
zxxx 大佬有话说 : 2021-6-17 11:08
能不能在发帖的时候自动把网址转换成链接的形式?
论坛的设置比较变态,转换链接有点麻烦,建议论坛大师可以实现一下,我这个主要是看帖方便点
论坛大师 大佬有话说 :
yousihai 大佬有话说 : 2021-6-17 11:09
论坛的设置比较变态,转换链接有点麻烦,建议论坛大师可以实现一下,我这个主要是看帖方便点 …
小众需求吧https://cdn.jsdelivr.net/gh/hishis/forum-master/public/images/patch.gif
zxxx 大佬有话说 :
论坛大师 大佬有话说 : 2021-6-17 11:13
小众需求吧
大佬能加一下吗