Greasy Fork is available in English.
针对不同域名的网站,替换成自己使用的域名再打开。
当前为
// ==UserScript==
// @name 南+跳转自己域名对应的其他资源网站
// @namespace http://tampermonkey.net/dva
// @version 1.1
// @description 针对不同域名的网站,替换成自己使用的域名再打开。
// @author Dva
// @match *://*.south-plus.net/read.php?tid*
// @match *://*.summer-plus.net/read.php?tid*
// @match *://*.level-plus.net/read.php?tid*
// @match *://*.south-plus.org/read.php?tid*
// @match *://*.white-plus.net/read.php?tid*
// @match *://*.imoutolove.me/read.php?tid*
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==
(function() {
'use strict';
// 把"hjd"冒号右边的双引号里替换成你用的2048域名,把"ch"冒号右边的双引号里替换成你用的村花地址,如果你使用的和我的一样则不用替换
const doms={
"hjd":"bs.qj0u.xyz", //2048网址 https://替换为中间这部分/2048/
"ch":"www.cunhua.guru", //村花网址 https://替换为中间这部分/thread/
}
const re = /\d{5}\d/g;
let readTopic = document.getElementById("read_tpc");
let topicText = readTopic.textContent;
let links = readTopic.getElementsByTagName("a");
if(links.length>0 && isBasic(links[0])){
//添加打开全部链接的按钮
const topic = document.getElementById("subject_tpc").parentNode;
const allBtn = document.createElement("button");
allBtn.style.marginLeft="5px";
allBtn.setAttribute("type","button");
allBtn.textContent="打开所有";
allBtn.onclick=function(){
openAll(links);
}
topic.appendChild(allBtn);
//添加每个打开链接的按钮
//let link;
for(let l=0;l<links.length;l++){
let btn = document.createElement("button");
btn.style.marginLeft="5px";
btn.setAttribute("type","button");
btn.textContent="打开";
btn.onclick=function(){
openSingle(links[l]);
}
readTopic.insertBefore(btn,links[l].nextSibling);
}
}
//打开全部链接
function openAll(links){
let link;
for(link of links){
if(isHjd(link)){
window.open(link.href.replace(link.href.split("/")[2],doms.hjd));
}else{
window.open("https://"+doms.ch+"/thread-"+link.href.match(re)[0]+"-1-1.html");
}
}
}
//打开单个链接
function openSingle(link){
if(isHjd(link)){
window.open(link.href.replace(link.href.split("/")[2],doms.hjd));
}else{
window.open("https://"+doms.ch+"/thread-"+link.href.match(re)[0]+"-1-1.html");
}
}
//判断是否是hjd的链接
function isHjd(link){
return link.href.split("/")[3]=="2048";
}
//判断是否是2048或cunhua的帖子
function isBasic(link){
let re = new RegExp("cunhua");
return isHjd(link) || re.test(link);
}
})();