Greasy Fork is available in English.
针对不同域名的网站,替换成自己使用的域名再打开。
当前为
// ==UserScript==
/*jshint esversion: 6 */
// @name 南+跳转自己域名对应的其他资源网站
// @namespace http://tampermonkey.net/dva
// @version 1.0.6
// @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*
// @match *://*.spring-plus.net/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 regs={
"hjd":"2048",
"ch1":"cunhua",
"ch2":"huo.wtf",
}
const re = /\d{4,}\d/g;
let readTopic = document.getElementById("read_tpc");
let topicText = readTopic.textContent;
let links = readTopic.getElementsByTagName("a");
if(links.length > 0){
let hasBasic = false;
for(let l of links){
if(isBasic(l)){
hasBasic = true;
}
}
if(hasBasic){
//添加打开全部链接的按钮
const topic = document.getElementById("subject_tpc").parentNode;
const allBtn = document.createElement("button");
allBtn.style.marginLeft="5px";
allBtn.style.cursor = "pointer"
allBtn.setAttribute("type","button");
allBtn.textContent="打开所有";
allBtn.onclick=function(){
openAll(links);
}
topic.appendChild(allBtn);
//添加每个打开链接的按钮
for(let l=0;l<links.length;l++){
if(isBasic(links[l])){
let btn = document.createElement("button");
btn.style.marginLeft="5px";
btn.style.cursor = "pointer"
btn.setAttribute("type","button");
btn.textContent="打开";
btn.onclick=function(){
openSingle(links[l]);
};
readTopic.insertBefore(btn,links[l].nextSibling);
}
}
}
}
//打开全部链接
function openAll(links){
for(let link of links){
if(isHjd(link)){
window.open(link.href.replace(link.href.split("/")[2],doms.hjd));
}else if(isCh(link)){
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 if(isCh(link)){
window.open("https://"+doms.ch+"/thread-"+link.href.match(re)[0]+"-1-1.html");
}
}
//判断是否是hjd的链接
function isHjd(link){
return link.href.split("/")[3]==regs.hjd;
}
//判断是否是cunhua
function isCh(link){
let reg1 = new RegExp(regs.ch1);
let reg2 = new RegExp(regs.ch2);
return reg1.test(link) || reg2.test(link);
}
//判断是否是2048或cunhua的帖子
function isBasic(link){
return isHjd(link) || isCh(link);
}
})();