// ==UserScript==
// @name 链接助手
// @namespace https://github.com/oneNorth7
// @include *
// @version 1.7.8
// @author 一个北七
// @run-at document-body
// @description 大部分主流网盘和小众网盘自动填写密码; 跳转页面自动跳转; 文本转链接; 净化跳转链接; 维基百科及镜像、开发者文档、谷歌商店自动切换中文, 维基百科、谷歌开发者、谷歌商店链接转为镜像链接; 新标签打开链接; (外部)链接净化直达
// @icon https://gitee.com/oneNorth7/pics/raw/master/picgo/link-helper.png
// @compatible chrome 69+
// @compatible firefox 78+
// @compatible edge Latest
// @noframes
// @license GPL-3.0 License
// @grant GM_registerMenuCommand
// @grant GM_unregisterMenuCommand
// @grant GM_notification
// @grant GM_info
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// @grant GM_openInTab
// @grant GM_xmlhttpRequest
// @grant GM_addStyle
// @require https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.min.js
// @require https://cdn.jsdelivr.net/npm/[email protected]/dist/sweetalert2.all.min.js
// @created 2021年3月19日 09:48:14
// ==/UserScript==
$(function () {
"use strict";
const scriptInfo = GM_info.script,
locHost = location.host,
locHref = location.href,
locHash = location.hash,
locPath = location.pathname;
let t = {
showNotice(msg) {
GM_notification({
text: msg,
title: scriptInfo.name,
image: scriptInfo.icon,
highlight: false,
silent: false,
timeout: 1500,
});
},
clog() {
console.group('[链接助手]');
for (let m of arguments) {
if (void 0 !== m) console.log(m);
}
console.groupEnd();
},
get(name, def) {
return GM_getValue(name, def);
},
set(name, value) {
GM_setValue(name, value);
},
delete(name) {
GM_deleteValue(name);
},
registerMenu(title, func) {
return GM_registerMenuCommand(title, func);
},
unregisterMenu(menuID) {
GM_unregisterMenuCommand(menuID);
},
open(url, options = { active: true, insert: true, setParent :true }) {
GM_openInTab(url, options);
},
http(link, s = false) {
return link.startsWith("http")
? link
: (s ? "https://" : "http://") + link;
},
title(a, mark='') {
if (a.title)
a.title += "\n" + mark + decodeURIComponent(a.href);
else a.title = mark + decodeURIComponent(a.href);
},
hashcode(l=location) {
return l.hash.slice(1);
},
search(l=location, p = 'password') {
let args = l.search.slice(1).split('&');
for (let a of args) {
if (a.includes(p + '='))
return a.replace(p + '=', '');
}
return '';
},
clean(src, str) {
for (let s of str) {
src = src.replace(s, "");
}
return src;
},
loop(func, times) {
let tid = setInterval(() => {
if (times <= 0) clearInterval(tid);
func();
this.clog(times);
times--;
}, 100);
},
confirm(title, yes, no, deny) {
let option = {
toast: true,
showCancelButton: true,
position: 'center',
title,
confirmButtonText: '是',
cancelButtonText: '否',
showDenyButton: deny,
denyButtonText: '取消',
// customClass
};
return Swal.fire(option).then((res) => {
if (res.isConfirmed) yes();
else if (res.isDismissed) no();
else if (res.isDenied) deny();
});
},
increase() {
success_times = +this.get("success_times") + 1;
this.set("success_times", success_times);
},
subscribe() {
let isFollowed = t.get('isFollowed', false), least_times = t.get('least_times', 50);
success_times = +this.get("success_times");
if (success_times > least_times && !isFollowed) {
Swal.fire({
title: '\u5173\u6ce8\u516c\u4f17\u53f7\uff0c\u4e0d\u8ff7\u8def\uff01',
html: $(
`<div><img style="width: 300px;margin: 5px auto;" src="https://gitee.com/oneNorth7/pics/raw/master/picgo/oneNorth7.png"><p style="font-size: 16px;color: red;">\u7b2c\u4e00\u65f6\u95f4\u83b7\u53d6<span style="color: gray;font-weight: 800;">\u3010\u94fe\u63a5\u52a9\u624b\u3011</span>\u66f4\u65b0\u63a8\u9001\uff01</p></div>`
)[0],
showCancelButton: true,
allowOutsideClick: false,
confirmButtonColor: '#d33',
confirmButtonText: '\u5df2\u5173\u6ce8\uff0c\u4e0d\u518d\u63d0\u9192\uff01',
cancelButtonColor: '#3085d6',
cancelButtonText: '\u7a0d\u540e\u5173\u6ce8',
}).then((result) => {
if (result.isConfirmed) {
Swal.fire({
position: 'center',
icon: 'success',
title: '\u611f\u8c22\u5173\u6ce8\uff01\uff01\uff01',
text: '\u4e00\u4e2a\u5317\u4e03\u4f1a\u7ee7\u7eed\u4e0d\u9057\u4f59\u529b\u5730\u521b\u4f5c\u66f4\u591a\u5b9e\u7528\u5de5\u5177',
showConfirmButton: false,
timer: 2000
});
t.set('isFollowed', true);
} else t.set('least_times', least_times + 50);
});
}
},
update(name, value) {
if (this.get('updated_version', '') != scriptInfo.version) {
let data = this.get(name, false);
if (data) {
for (let v of value) {
if (!data.some(d => d == v)) {
data.push(v);
}
}
this.set('updated_version', scriptInfo.version);
this.set(name, data);
}
}
},
};
let url_re_str = "((?<![.@])\\w(?:[\\w._-])+@\\w[\\w\\._-]+\\.(?:com|cn|org|net|info|tv|cc|gov|edu|nz|me)|(?:https?:\\/\\/|www\\.)[\\w_\\-\\.~\\/\\=\\?&#%\\+:!*\\u4e00-\\u9fa5]+|(?<!@)(?:\\w[\\w._-]+\\.(?:com|cn|org|net|info|tv|cc|gov|edu|nz|me))(?:\\/[\\w_\\-\\.~\\/\\=\\?&#%\\+:!*\\u4e00-\\u9fa5]*)?)",
url_regexp = new RegExp(url_re_str, "i");
let Preprocess = {
"www.38hack.com": function () {
if (/http:\/\/www\.38hack\.com\/\d+\.html/.test(locHref)) {
let lines = $("div.down-line");
if (lines.length)
lines.last().append(lines.first().prev().prev());
}
},
"www.mikuclub.xyz": function () {
if (/https:\/\/www\.mikuclub\.xyz\/\d+/.test(locHref)) {
let password = $(".password1"),
link = $("a.download");
if (password.length && link.length)
link[0].hash = password[0].value;
}
},
"www.acggw.com": function () {
if (/https:\/\/www\.acggw\.com\/\d+\.html/.test(locHref)) {
let paragraphs = $(".single-content>p"),
weiyun = null,
mega = null;
for (let p of paragraphs) {
let text = $(p).text();
if (text.startsWith("链接:")) weiyun = $(p);
if (weiyun && text.startsWith("密码:"))
weiyun.text(
weiyun.text() + "#" + text.replace("密码:", "")
);
if (mega && text.startsWith("国外M盘:"))
mega.text(
mega.text() + "#" + text.replace("国外M盘:", "")
);
if (text.startsWith("国外M盘:http")) mega = $(p);
}
}
},
"www.olecn.com": function () {
if (
/http:\/\/www\.olecn\.com\/download\.php\?id=\d+/.test(locHref)
) {
let link = $("div.panel-body a"),
pass = $("div.plus_l li:eq(3)");
if (link.length && pass.length)
link[0].hash = pass
.text()
.trim()
.replace("网盘提取码 :", "");
}
},
"www.qiuziyuan.net": function () {
if (
/https:\/\/www\.qiuziyuan\.net\/(?:pcrj\/|Android\/\d+\.html)/.test(
locHref
)
) {
let filetit = $("div.filetit:first");
for (let child of filetit.children()) {
if (child.href) {
let result = url_regexp.exec(child.innerHTML);
if (result) child.href = t.http(result[1]);
}
if (
child.innerHTML.startsWith("90网盘:") ||
child.innerHTML.includes("90pan")
) {
let dom = filetit.next().next(),
result = /(?:90网盘:|\/\s*)(\d+)/.exec(dom.html());
if (result) child.href += "#" + result[1];
}
}
}
},
"www.gopojie.net": function () {
if (/https:\/\/www\.gopojie\.net\/download\?post_id=/.test(locHref)) {
setTimeout(() => {
let a = $('a.empty.button'), url = a.prop('href'), code = $('#tq').attr('data-clipboard-text');
if (url) a.prop('href', url + '#' + code);
}, 1000);
}
},
};
if (Preprocess[locHost]) Preprocess[locHost]();
let YunDisk = {
sites: {
"pan.baidu.com": {
// 百度云
inputSelector: "#accessCode",
buttonSelector: "#submitBtn",
regStr: "[a-z\\d]{4}",
},
"eyun.baidu.com": {
// 百度企业网盘
inputSelector: "input.share-access-code",
buttonSelector: "a.g-button",
regStr: "[a-z\\d]{4}",
},
"cloud.189.cn": {
// 天翼云
inputSelector: "#code_txt",
buttonSelector: "a.btn-primary",
regStr: "[a-z\\d]{4}",
clickTimeout: 500,
},
"lanzou.com": {
// 蓝奏云
inputSelector: "#pwd",
buttonSelector: "#sub, .passwddiv-btn",
regStr: "[a-z\\d]{2,10}",
redirect: true,
},
"ct.ghpym.com": {
// 果核城通网盘
inputSelector: "#passcode",
buttonSelector: "button.btn-primary",
regStr: "[a-z\\d]{4,6}",
timeout: 200, // >=125
},
"www.90pan.com": {
// 90网盘
inputSelector: "#code",
buttonSelector: "button.btn-info",
regStr: "[a-z\\d]{4,6}",
},
"vdisk.weibo.com": {
// 微盘
inputSelector: "#keypass",
buttonSelector: "div.search_btn_wrap>a",
regStr: "[a-z\\d]{4}",
},
"pan.xunlei.com": {
// 迅雷云盘
inputSelector: "#__nuxt input.td-input__inner",
buttonSelector: "#__nuxt button.td-button",
regStr: "[a-z\\d]{4}",
timeout: 1200,
store: true,
inputEvent: true,
},
"share.weiyun.com": {
// 微云
inputSelector: "input.input-txt",
buttonSelector: "button.btn-main",
regStr: "[a-z\\d]{4,6}",
timeout: 500,
inputEvent: true,
},
"115.com": {
// 115网盘
inputSelector: "input.text",
buttonSelector: "a.btn-large",
regStr: "[a-z\\d]{4}",
timeout: 500,
password: true,
},
"quqi.com": {
// 曲奇云
inputSelector: "div.webix_el_box>input",
buttonSelector: "button.webixtype_base",
regStr: "[a-z\\d]{6}",
timeout: 800,
},
"caiyun.139.com": {
// 和彩云
inputSelector: "input",
buttonSelector: "a.btn-token",
regStr: "[a-z\\d]{4}",
timeout: 100,
clickTimeout: 10,
inputEvent: true,
store: true,
},
"mo.own-cloud.cn": {
// 小麦魔方
inputSelector: "#pwd",
buttonSelector: "button.MuiButton-root",
regStr: "[a-z\\d\\u4e00-\\u9fa5]{2,8}",
timeout: 500,
password: true,
},
"moecloud.cn": {
// 萌云
inputSelector: "#pwd",
buttonSelector: "button.MuiButton-root",
regStr: "[a-z\\d]{4,8}",
timeout: 500,
password: true,
},
"www.wenshushu.cn": {
// 文叔叔
inputSelector: "input.ivu-input",
buttonSelector: "button.m-mg_t40",
regStr: "[a-z\\d]{4}",
timeout: 1000,
inputEvent: true,
},
"mega.nz": {
regStr: "[a-z\\d\\-_]{22}",
},
"gofile.me": {
inputSelector: "#login_passwd",
buttonSelector: 'button[aria-label="进入"]',
regStr: "[a-z\\d]{4}",
clickTimeout: 1000,
store: true,
},
"www.jianguoyun.com": {
// 坚果云
inputSelector: "#access-pwd",
buttonSelector: "button.action-button",
regStr: "[a-z\\d]{6}",
},
"yunpan.360.cn": {
// 360安全云盘
inputSelector: "input.pwd-input",
buttonSelector: "input.submit-btn",
regStr: "[a-z\\d]{4}",
},
"pan-yz.chaoxing.com": {
// 超星云盘
inputSelector: "input.tqInp",
buttonSelector: "a.blueBgBtn",
regStr: "[a-z\\d]{6}",
},
"shandianpan.com": {
// 闪电盘
inputSelector: 'input[placeholder="请输入文件密码"]',
buttonSelector: "div.btn",
regStr: "[a-z\\d]{4}",
timeout: 200,
inputEvent: true,
store: true,
},
"drive.dnxshare.cn": {}, // 电脑小分享
"my.sharepoint.com": {
// OneDrive
inputSelector: '#txtPassword',
buttonSelector: "#btnSubmitPassword",
regStr: "[a-z\\d]{4}",
},
"disk.yandex.com": {}, // YandexDisk
},
pans: [
"cowtransfer.com", // 奶牛快传
"www.mediafire.com", // MediaFire
"drive.google.com", // GoogleDrive
"down.52pojie.cn", // 爱盘
"www.yunzhongzhuan.com", // 云中转
"yiqixie.qingque.cn", // 一起写
"www.androiddownload.net",
"www.dropbox.com", // Dropbox
"www.kufile.net", // 库云
"www.kdocs.cn", // 金山文档
],
mapHost(host) {
return host
.replace('yun.baidu.com', 'pan.baidu.com')
.replace(/.*lanzou[isx]?.com/, 'lanzou.com')
.replace(/^(?:[a-z]\d{3}|\d{3}[a-z])\.com$/, 'ct.ghpym.com')
.replace(/quqi\.\w+\.com/, 'quqi.com')
.replace('feixin.10086.cn', '139.com')
.replace('ws28.cn', 'www.wenshushu.cn')
.replace('zb.my.to:5000', 'gofile.me')
.replace('cloud.dnxshare.cn', 'drive.dnxshare.cn')
.replace(/\w+\-my\.sharepoint\.(?:com|cn)/, 'my.sharepoint.com')
.replace(/\w{6}.link.yunpan.360.cn|yunpan.cn/, 'yunpan.360.cn')
.replace('mofile.own-cloud.cn', 'mo.own-cloud.cn')
.replace('cloud.qingstore.cn', 'moecloud.cn')
.replace('pan.mebk.org', 'moecloud.cn')
.replace('cncncloud.com', 'moecloud.cn')
.replace('ilolita945.softether.net:5212', 'moecloud.cn')
.replace('my-file.cn', 'moecloud.cn')
.replace('pan.bilnn.com', 'moecloud.cn')
.replace('yadi.sk', 'disk.yandex.com');
},
autoFill(host) {
let site = this.sites[host];
if (site.timeout) setTimeout(fillOnce, site.timeout);
else fillOnce();
function fillOnce() {
if (site.inputSelector) {
let input = $(site.inputSelector),
button = $(site.buttonSelector),
code = null;
function click() {
if (site.clickTimeout)
setTimeout(() => {
button = $(site.buttonSelector);
button[0].click();
}, site.clickTimeout);
else button[0].click();
}
if (input.length) {
if (site.store) code = t.get(host);
else if (site.password) code = decodeURIComponent(t.search());
else code = t.hashcode();
if (code) {
let codeRe = RegExp("^" + site.regStr + "$", "i");
if (codeRe.test(code)) {
if (site.inputEvent) {
let tid = setInterval(() => {
input.val(code);
if (input.val() !== "") {
if (InputEvent) {
input[0].dispatchEvent(
new InputEvent("input")
);
} else if (KeyboardEvent) {
input[0].dispatchEvent(
new KeyboardEvent("input")
);
}
clearInterval(tid);
click();
}
}, 1000);
} else if (site.password) {
click();
} else {
input.val(code);
click();
}
t.increase();
t.subscribe();
} else {
t.clog("未找到合适的提取码!");
}
} else {
t.clog("未找到提取码!");
}
} else {
t.clog("无需填写密码!");
}
}
}
},
addCode(a) {
let mapped = this.mapHost(a.host),
site = this.sites[mapped],
codeRe = new RegExp("^" + site.regStr + "$", "i");
if (site.password) {
let result = a.hash && /#(\/s\/\w{6})/.exec(a.hash);
if (result)
if (a.pathname == '/') {
a.pathname = result[1];
a.hash = '';
}
} else if (site.redirect) {
a.host = a.host.replace('lanzous', 'lanzoux');
}
if (!codeRe.test(t.hashcode(a)) && !codeRe.test(t.search(a))) {
let reg = new RegExp(
"\\s*(?:提[取示]|访问|查阅|密\\s*|艾|Extracted-code|key|password|pwd)[码碼]?\\s*[:: ((]?\\s*(" +
site.regStr +
")|^[码碼]?\\s*[::【\\[ ((]?\\s*(" +
site.regStr +
")[】\\]]?$",
"i"
),
code = reg.exec($(a).text().trim());
outloop: for (
let i = 10, current = a;
current && !code && i > 0;
i--, current = current.parentElement
) {
let next = current;
while (!code) {
next = next.nextSibling;
if (!next) break;
else if ((node => {
if (node.href) return true;
else if (node.innerHTML)
if (/<a.*href=.*/i.test(node.innerHTML))
return true;
})(next)) break outloop;
else code = reg.exec($(next).text().trim());
}
}
if (code) {
let c = code[1] || code[2];
if (site.store) t.set(mapped, c);
else if (site.password) {
if (!t.search(a))
a.search = a.search ? a.search + '&' + 'password=' + encodeURIComponent(c) : 'password=' + encodeURIComponent(c);
} else a.hash = c;
} else {
if (site.store) t.delete(mapped);
t.clog("找不到code!");
}
}
},
};
let success_times = t.get("success_times");
if (!success_times) t.set("success_times", 0);
let dealedHost = YunDisk.mapHost(locHost);
if (YunDisk.sites[dealedHost]) YunDisk.autoFill(dealedHost);
else {
let RedirectPage = {
sites: {
"show.bookmarkearth.com": {
// 书签地球
include: "http://show.bookmarkearth.com/view/",
selector: "a.open-in-new-window",
},
"t.cn": {
// 微博
include: "http://t.cn/",
selector: "a.m-btn-orange",
},
"sunbox.cc": {
// 阳光盒子
include:
"https://sunbox.cc/wp-content/themes/begin/go.php?url=",
selector: "a.alert-btn",
},
"www.itdaan.com": {
// 开发者知识库
include: "https://www.itdaan.com/link/",
selector: "a.c-footer-a1",
},
"to.redircdn.com": {
include:
"https://to.redircdn.com/?action=image&url=",
selector: "a.bglink",
},
"link.csdn.net": {
// CSDN
include: "https://link.csdn.net/?target=",
selector: "a.loading-btn",
timeout: 100,
},
"niao.su": {
// 不死鸟
include: "https://niao.su/go/",
selector: "a.c-footer-a1",
},
"support.qq.com": {
include: "support.qq.com/products/",
selector: "span.link_url",
},
"www.imaybes.cc": {
// 也许吧
include: "www.imaybes.cc/wl?url=",
selector: "a.button"
},
},
redirect(host) {
let site = this.sites[host];
if (locHref.includes(site.include)) {
if (site.timeout) setTimeout(redirect, site.timeout);
else redirect();
function redirect() {
let target = $(site.selector);
if (target.length) location.replace(target[0].href || target[0].innerText);
else t.clog('找不到跳转目标!');
t.increase();
}
}
},
wiki() {
let isZh = locHost.includes("zh"),
jumpToZh = t.get("jumpToZh", true),
a = $("a.interlanguage-link-target[lang='zh']");
if (!isZh && jumpToZh) {
history.pushState(null, null, locHref);
if (a.length) location.replace(a[0].href);
else t.showNotice("没有找到中文页面!");
}
let menuID = t.registerMenu(
`${jumpToZh ? "[✔]" : "[✖]"}自动切换中文`,
autoJump
);
function autoJump() {
jumpToZh = !jumpToZh;
t.set("jumpToZh", jumpToZh);
t.unregisterMenu(menuID);
menuID = t.registerMenu(
`${jumpToZh ? "[✔]" : "[✖]"}自动切换中文`,
autoJump
);
if (!isZh && jumpToZh) {
history.pushState(null, null, locHref);
if (a.length) location.replace(a[0].href);
else t.showNotice("没有找到中文页面!");
}// else history.back();
}
},
mozilla() {
let isZh = locPath.includes("zh-CN"),
jumpToZh = t.get("jumpToZh", true);
jump();
function jump() {
if (!isZh && jumpToZh) {
let result = /developer\.mozilla\.org\/(.+?)\//.exec(
locHref
), options = $("#language-selector").children(), flag = false;
if (result) {
for (let i = options.length; i > 0; i--) {
if (options[i - 1].value === "zh-CN") {
flag = true;
break;
}
}
if (flag) {
let zh_url = locHref.replace(result[1], "zh-CN");
history.pushState(null, null, locHref);
location.replace(zh_url);
}
else t.showNotice("没有找到中文页面!");
}
}
}
let menuID = t.registerMenu(
`${jumpToZh ? "[✔]" : "[✖]"}自动切换中文`,
autoJump
);
function autoJump() {
jumpToZh = !jumpToZh;
t.set("jumpToZh", jumpToZh);
t.unregisterMenu(menuID);
menuID = t.registerMenu(
`${jumpToZh ? "[✔]" : "[✖]"}自动切换中文`,
autoJump
);
jump();
}
},
MSDocs() {
let isZh = locPath.includes("zh-cn"),
jumpToZh = t.get("jumpToZh", true);
if (!isZh && jumpToZh) {
history.pushState(null, null, locHref);
location.replace(locHref.replace(/docs.microsoft.com\/[a-z\-]{5}\//i, 'docs.microsoft.com/zh-cn/'));
}
let menuID = t.registerMenu(
`${jumpToZh ? "[✔]" : "[✖]"}自动切换中文`,
autoJump
);
function autoJump() {
jumpToZh = !jumpToZh;
t.set("jumpToZh", jumpToZh);
t.unregisterMenu(menuID);
menuID = t.registerMenu(
`${jumpToZh ? "[✔]" : "[✖]"}自动切换中文`,
autoJump
);
if (!isZh && jumpToZh) {
history.pushState(null, null, locHref);
location.replace(locHref.replace(/docs.microsoft.com\/[a-z\-]{5}\//i, 'docs.microsoft.com/zh-cn/'));
}
}
},
chrome() {
let isZh = location.search.includes('hl=zh-CN'),
jumpToZh = t.get("jumpToZh", true);
if (!isZh && jumpToZh) {
history.pushState(null, null, locHref);
location.search = location.search.replace(/hl=[a-zA-Z]{2}-[a-zA-Z]{2}/, 'hl=zh-CN');
}
let menuID = t.registerMenu(
`${jumpToZh ? "[✔]" : "[✖]"}自动切换中文`,
autoJump
);
function autoJump() {
jumpToZh = !jumpToZh;
t.set("jumpToZh", jumpToZh);
t.unregisterMenu(menuID);
menuID = t.registerMenu(
`${jumpToZh ? "[✔]" : "[✖]"}自动切换中文`,
autoJump
);
if (!isZh && jumpToZh) {
history.pushState(null, null, locHref);
location.search = location.search.replace(/hl=[a-zA-Z]{2}-[a-zA-Z]{2}/, 'hl=zh-CN');
}
}
},
};
if (locHost.match(/.+wiki(?:\.sxisa|pedia)\.org/))
RedirectPage.wiki();
else if (locHost == 'chrome.google.com')
RedirectPage.chrome();
else {
if (locHost === "developer.mozilla.org") RedirectPage.mozilla();
else if (locHost === "docs.microsoft.com") RedirectPage.MSDocs();
let isChromium = navigator.appVersion.includes('Chrome');
$(document).on("mouseup", (obj) => listener(obj));
if (isChromium && locHost == 'www.52pojie.cn')
$(document).on("selectstart", (obj) => listener(obj));
if (locHost.includes('blog.csdn.net'))
document.body.addEventListener('click', function (obj) {
let e = obj.target;
if (e.nodeName.toLocaleLowerCase() === 'a') {
obj.stopImmediatePropagation();
window.open(e.href);
obj.preventDefault();
}
}, true);
async function listener(obj) {
let e = obj.originalEvent.explicitOriginalTarget || obj.originalEvent.target,
isTextToLink = false, isInput = false;
if (e && !e.href) {
let flag = true,
selectNode = null;
for (
let current = e, limit = 5;
current.localName !== "html" && current.localName !== "body" && limit > 0;
current = current.parentElement, limit--
) {
if (current.localName === "a") {
e = current;
break;
} else if (
["code", "pre"].some(
(tag) => tag === current.localName
)
) {
let selection = getSelection(),
text = selection.toString();
if (url_regexp.test(text))
selectNode =
selection.anchorNode || selection.focusNode;
else flag = false;
break;
} else if (['input', 'textarea'].some((tag) => tag === current.localName) && current.className == 'direct-input') {
let text = t.clean(current.value, [/[\u4e00-\u9fa5\u3002\uff1b\uff0c\uff1a\u201c\u201d\uff08\uff09\u3001\uff1f\u300a\u300b]+/g, /^[::]/, /App.*$/]),
result = url_regexp.exec(text);
if (result) {
selectNode = document.createTextNode(text);
isInput = true;
}
else flag = false;
break;
}
}
if (e.localName !== "a" && flag) {
let node = selectNode || e;
if (node && node.nodeValue) e = text2Link(node);
else e = textToLink(e);
if (e)
isTextToLink = true;
}
}
if (e && e.localName === "a" && e.href) {
let a = e, isPrevent = false;
if (locHref.includes("mod.3dmgame.com/mod/"))
a.search = "3dmgame.com";
if (locHost == "bbs.nga.cn" || locHost == "nga.178.com" || locHost == "ngabbs.com") {
if (!(a.host == "bbs.nga.cn" || a.host == "nga.178.com" || a.host == "ngabbs.com"))
if (a.attributes.onclick && a.attributes.onclick.nodeValue.startsWith("ubbcode.showUrlAlert(event,this)"))
a.onclick = null;
}
if (locHost == "twitter.com" && a.host == "t.co") a.href = t.http(a.innerText, true);
if (locHost == "www.youtube.com" && a.href.includes("www.youtube.com/redirect?")) {
if (!a.style.padding) {
$("#secondary-links.ytd-c4-tabbed-header-renderer a.ytd-c4-tabbed-header-renderer").css({padding: "10px 10px 10px 2px", lineHeight: 0, display: "inline-block"});
$("#secondary-links.ytd-c4-tabbed-header-renderer a.ytd-c4-tabbed-header-renderer:first-child").css("padding-left", "10px");
}
a.classList.remove("yt-simple-endpoint");
}
if (locHost == "www.facebook.com") {
a.onclick = function() { return false; };
t.open(a.href);
}
if (!cleanRedirectLink(a) && RegExp("^" + url_re_str + "$", "i").test(a.innerText)) {
if (isLinkText(a)) {
t.title(a, '【替换】');
a.href = t.http(a.innerText, true);
t.increase();
}
else if (!isTextToLink && !a.parentElement.className.includes('text2Link') && !a.parentElement.className.includes('textToLink') && locHost != 'blog.csdn.net' && isDifferent(a)) {
a.onclick = function() { return false; };
isPrevent = true;
await t.confirm("是否使用链接文本替换目标链接后打开?",
() => {
// 是
let linkTextPrefixes = t.get("linkTextPrefixes", []),
reg = /(?:http|https|\/|\%2F).*?\?.+?=|.*?\?/,
result = reg.exec(a.href);
if (result) {
linkTextPrefixes.push(result[0]);
t.set("linkTextPrefixes", linkTextPrefixes);
}
t.title(a, '【替换】');
a.href = t.http(a.innerText, true);
t.increase();
},
() => {
// 否
},
() => {
// 取消
isPrevent = false;
a.onclick = null;
});
}
}
if (jumpToMirror) {
if (a.host.includes("wikipedia.org")) {
// 维基百科
if (!locHost == "www.bing.com" || !locHost.includes("www.google."))
a.href = a.href.replace(
"wikipedia.org",
"wiki.sxisa.org"
);
} else if (a.host.includes("developers.google.com")) {
// 谷歌开发者
if (!locHost == "developers.google.com")
a.href = a.href.replace(
"developers.google.com",
"developers.google.cn"
);
} else if (a.host.includes("chrome.google.com")) {
// 谷歌应用商店
if (isChromium) {
a.onclick = function() { return false; };
isPrevent = true;
await t.confirm('是否跳转到【crx4chrome】镜像站?',
() => {
// 是
t.title(a);
a.href = a.href.replace(/chrome\.google\.com\/webstore\/detail[\/\w\-%]*(?=\w{32})/i, 'www.crx4chrome.com/extensions/');
},
() => {
// 否
},
() => {
// 取消
isPrevent = false;
a.onclick = null;
});
}
}
}
let pan = YunDisk.sites[YunDisk.mapHost(a.host)];
if (pan) YunDisk.addCode(a);
if (isTextToLink) {
let isClicked = false;
if (pan || t.get("autoClickSites", []).concat(YunDisk.pans).some(h => h == a.host)) {
a.click();
isClicked = true;
}
if (isInput) {
if (!isClicked) a.click();
$('#L_DirectInput').val('');
}
}
add_blank(a);
if (isPrevent) {
a.onclick = null;
t.open(a.href);
}
}
}
// 注册菜单项添加文本转链接后自动跳转域名
t.registerMenu('添加自动跳转域名', addAutoClick);
function addAutoClick() {
let autoClickSites = t.get("autoClickSites", []), input = prompt("输入的域名的链接文本转链接后会自动跳转", locHost);
if (input) {
if (/[\w]+(\.[\w]+)+/.test(input)) {
if (!autoClickSites.some((s) => s.includes(input))) {
autoClickSites.push(input);
t.set("autoClickSites", autoClickSites);
} else t.showNotice(`域名 <${input}> 已存在!!!`);
} else t.showNotice(`<${input}> 不是有效域名!!!`);
}
}
// 注册菜单项自动切换镜像
let jumpToMirror = t.get("jumpToMirror", true);
let menuID = t.registerMenu(
`${jumpToMirror ? "[✔]" : "[✖]"}自动切换镜像`,
autoJump
);
function autoJump() {
jumpToMirror = !jumpToMirror;
t.set("jumpToMirror", jumpToMirror);
t.unregisterMenu(menuID);
menuID = t.registerMenu(
`${jumpToMirror ? "[✔]" : "[✖]"}自动切换镜像`,
autoJump
);
}
if (RedirectPage.sites[locHost]) RedirectPage.redirect(locHost);
let textLength = t.get("textLength", 200);
// t.registerMenu(
// `设置文本字数限制(${textLength})`,
// limitText
// );
// function limitText() {
// let input = prompt(
// "请输入文本字数限制: ",
// t.get("textLength", 200)
// );
// }
let url_regexp_g = new RegExp(
"\\b(" + url_re_str +
"|" +
"ed2k:\\/\\/\\|file\\|[^\\|]+\\|\\d+\\|\\w{32}\\|(?:h=\\w{32}\\|)?\\/" +
"|" +
"magnet:\\?xt=urn:btih:\\w{40}(&[\\w\\s]+)?" +
")",
"ig"
);
function textToLink(e) {
if (
!["body", "code", "pre", "select", "main", "input", "textarea"].some(
(tag) => tag === e.localName
) &&
!["www.google."].some((h) => locHost.includes(h))
) {
let span = null,
count = 0;
if (e.childNodes.length < 10)
for (
let i = e.childNodes.length - 1;
i >= 0;
i--
) {
let child = e.childNodes[i];
if (
!["a", "br", "code", "pre", "img", "script", "option", "input", "textarea"].some(
(tag) => tag === child.localName
) &&
child.className !== "textToLink" &&
child.textContent.length < textLength
) {
let text = child.textContent,
result = url_regexp_g.test(text);
if (result) {
span = $("<span class='textToLink'></span>");
span.html(
text.replace(url_regexp_g, function ($1) {
count++;
if ($1.includes("@")) return `<a href="mailto:${$1}">${$1}</a>`;
return $1.startsWith("http") ||
$1.includes("magnet") ||
$1.includes("ed2k")
? `<a href="${$1}" target="_blank">${$1}</a>`
: `<a href="https://${$1}" target="_blank">${$1}</a>`;
})
);
$(child).replaceWith(span);
}
}
}
if (count) t.increase();
return count == 1 && span && span.children()[0];
}
}
function text2Link(node) {
if (node.nodeValue.length < textLength) {
let text = node.nodeValue,
result = url_regexp_g.test(text),
span = null,
count = 0;
if (result) {
span = $("<span class='text2Link'></span>");
span.html(
text.replace(url_regexp_g, function ($1) {
count++;
if ($1.includes("@")) return `<a href="mailto:${$1}">${$1}</a>`;
return $1.startsWith("http") ||
$1.includes("magnet") ||
$1.includes("ed2k")
? `<a href="${$1}" target="_blank">${$1}</a>`
: `<a href="https://${$1}" target="_blank">${$1}</a>`;
}).replace(/点/g, '.')
);
$(node).replaceWith(span);
}
if (count) t.increase();
return count == 1 && span && span.children()[0];
}
}
function isLinkText(a) {
let keywords = [
"niao.su/go",
"www.sunweihu.com/go/?url=",
"jump.bdimg.com/safecheck/index?url=",
"jump2.bdimg.com/safecheck/index?url=",
"zhouxiaoben.info/wp-content/themes/begin/go.php?url=",
"www.423down.com/wp-content/plugins/momgo/go.php?url=",
"www.423down.com/go.php?url=",
"www.ccava.net/xc_url/?url=",
"www.imaybes.cc/wl?url=",
],
linkTextPrefixes = t.get("linkTextPrefixes", []);
return keywords.some((k) => a.href.includes(k)) || linkTextPrefixes.some((k) => a.href.includes(k));
}
function isDifferent(a) {
if (/(?:http|https|\/|\%2F).*?\?.+?=|.*?\?/.test(a.href)) {
let hash = a.hash, search = a.search, password = t.search(a);
a.hash = "";
if (password) a.search = "";
let text = decodeURIComponent(a.innerText).toLowerCase().replace(/^https?:\/\/|\/$/, ''), href = decodeURIComponent(a.href).toLowerCase().replace(/^https?:\/\/|\/$/, '');
a.hash = hash;
if (password) a.search = search;
return !(text.includes('...') || !text.includes('/') || text == href);
}
return false;
}
let excludeSites = [
"v.qq.com",
"v.youku.com",
"blog.csdn.net",
"cloud.tencent.com",
"translate.google.com",
"domains.live.com",
"passport.yandex.ru",
"www.iconfont.cn",
"www.kdocs.cn",
"help.aliyun.com",
"cn.bing.com",
"service.weibo.com",
"zhannei.baidu.com",
"pc.woozooo.com",
"play.google.com",
];
t.update('excludeSites', excludeSites);
excludeSites = t.get("excludeSites", excludeSites);
t.registerMenu("添加例外域名", addExcludeSite);
// 添加例外域名
function addExcludeSite() {
let input = prompt("输入的域名下的链接不会被净化: ", locHost);
if (input) {
if (/[\w]+(\.[\w]+)+/.test(input)) {
if (!excludeSites.some((s) => s.includes(input))) {
excludeSites.push(input);
t.set("excludeSites", excludeSites);
} else t.showNotice(`例外域名 <${input}> 已存在!!!`);
} else t.showNotice(`<${input}> 不是有效域名!!!`);
}
}
function cleanRedirectLink(a) {
// 小众软件
if (locHost == 'www.appinn.com' && (a.search.includes('ref=appinn') || a.hash.includes('ref=appinn'))) {
t.title(a, '【净化】');
a.search = a.search.replace(/[?&]ref=appinn$/, '');
a.hash = a.hash.replace(/[#&]ref=appinn$/, '');
t.increase();
return true;
}
// 净化跳转链接
let hosts = ['dalao.ru', 'niao.su', 'iao.su', 'nicelinks.site', 'www.appinn.com', 'support.qq.com', locHost];
for (let h of hosts) {
let reg = RegExp(`\\?(?:utm_source=)?${h}$`), result = reg.exec(a.href);
if (result) {
t.title(a, '【净化】');
a.href = a.href.replace(result[0], '');
t.increase();
}
}
let reg = new RegExp('((?:http|https|\\/|\\%2F)(?:.*?[?&].+?=|.*?[?&]))' + url_re_str, "i"),
result = reg.exec(decodeURIComponent(a.href));
if (result) {
let temp = decodeURIComponent(
decodeURIComponent(result[2])
).replace(/https?:\/\//, '');
if (
!(
decodeURIComponent(locHref).replace(/https?:\/\//, '').includes(
temp.split("&")[0]
) || ['login', 'oauth'].some(k => locHref.includes(k)) || a.innerText.includes('登录') ||
excludeSites.some((s) => result[1].includes(s)) ||
YunDisk.sites[YunDisk.mapHost(a.host)]
)
) {
if (!/t\d+\.html/i.test(temp)) {
let href = decodeURIComponent(
decodeURIComponent(
result[3]
? "http://" + result[3]
: result[2].startsWith("http")
? result[2]
: location.origin + result[2]
)
);
t.title(a, '【净化】');
if (["c.pc.qq.com","mail.qq.com", "m.sogou.com", "www.douban.com", "www.google.com", "txt.guoqiangti.ga", "g.luciaz.me"].some((h) => a.host == h))
a.href = href.split("&")[0];
else a.href = href.replace(/______/g, '.');
}
t.increase();
return true;
}
}
}
let defaultTargetSites = t.get("defaultTargetSites", ['shuax.com', 'app.infinityfree.net']);
let isAddBlank = t.get("isAddBlank", false);
let isDefault = defaultTargetSites.some((s) => s == location.host);
// 注册菜单项该站链接保持默认打开方式
if (!isDefault) {
let menuID2 = t.registerMenu(
"该站链接保持默认打开方式",
function () {
defaultTargetSites.push(location.host);
t.set("defaultTargetSites", defaultTargetSites);
isDefault = defaultTargetSites.some(
(s) => s == location.host
);
t.unregisterMenu(menuID2);
t.unregisterMenu(menuID);
}
);
// 注册菜单项启停在新标签打开链接
let menuID = t.registerMenu(
`${isAddBlank ? "[✔]" : "[✖]"}在新标签打开链接`,
addBlank
);
// 启停在新标签打开链接
function addBlank() {
isAddBlank = !isAddBlank;
t.set("isAddBlank", isAddBlank);
t.unregisterMenu(menuID);
menuID = t.registerMenu(
`${isAddBlank ? "[✔]" : "[✖]"}在新标签打开链接`,
addBlank
);
}
}
// 给链接添加[target="_blank"]属性
function add_blank(a) {
if (isAddBlank && !isDefault) {
let result =
a.href == "" || a.target == "_blank" ||
/javascript[\w:;()]+/.test(a.href) ||
/\/\w+-\d+-\d+\.html|.+page\/\d+|category-\d+_?\d*/.test(
a.href
) ||
/[前后上下首末].+[页篇张]|^\.*\s*\d+\s*\.*$|^next$|^previous$/i.test(
a.innerText
) ||
["prev", "next"].some(
(r) =>
r == a.attributes.rel &&
a.attributes.rel.nodeValue
) ||
["prev", "next", "nxt"].some((r) =>
a.className.includes(r)
) ||
a.href == location.origin + "/" ||
a.href.endsWith(".user.js"),
relative = t.get("relative", false);
if (!relative)
result =
result ||
!/^(?:https?|\/\/).+/.test(
a.attributes.href && a.attributes.href.nodeValue
);
if (!result) a.target = "_blank";
}
}
// 添加链接直达输入框
let addDirectTo = t.get('addDirectTo', true);
if (addDirectTo) add_direct();
let menuID2 = t.registerMenu(`${addDirectTo ? "[✔]" : "[✖]"}显示链接直达输入框`, directToMenu);
function directToMenu() {
addDirectTo = !addDirectTo;
t.set('addDirectTo', addDirectTo);
t.unregisterMenu(menuID2);
menuID2 = t.registerMenu(`${addDirectTo ? "[✔]" : "[✖]"}显示链接直达输入框`, directToMenu);
if (addDirectTo) add_direct();
else if ($('#L_DirectTo').length) $('#L_DirectTo').remove();
}
function add_direct() {
$('body').append(`<div id="L_DirectTo" class="l-direct-to">
<input type="image" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAaU0lEQVR4nO2deVgUZ57Hm8S4k50cc2SSzGR2J5ccAg1yI0c30A10QzcgllxyNw0iRAkao0bTKGhUPDIJGpMYjZoLowZEvEVlc+xONjOTmXWfOEncuJNhMpmNkozRiPrZP0j7VFVXI5AmIPbneb5/hPq+7/t969exq6veqlKp3Lhx48aNGzdu3Lhx48aNGzdu3Lhx48aNGzdu3PRJ4Ezu9SmnwLuCVZ7ltHlO47jXNLrGVXDGs4JvvKbxhWcFJ8dN422vaWz2ns487yq0v6zh5uHO7maQ+FgJ8qyk0auCk54VMChN47x3OfvGVVJ0v5Xbh3tObq6CrYMx3uXk+FTwnnc5uFQVfO07jbUPWnlguOfpRgEfK+njrXzoY4Uh1sXxVjb4zeCu4Z6zG1Xv97uflX2+VnAmPytnfcs5ON7K4+pyJvuWE6Cu4E5tJbcIAjf6T+PHPtP5la+VOP9pWP3KeN63nBNX6fOMfwVVKhUew70PrlvUFib7l3Harwzk8i/jor+VnWoLk4VBHsyFTcfTz8Lj/mV8rDSGXxn4W2mLKeZnrp6bmz7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2jxZ5Gz4u/057hCm7ahPDAd9bQEUPWGP4jVqnZ8R59K1ft1sFPNIblfrBZ/vmxR816LP22t/rzQ6s9rrX50vqHm5NXa7QpUfnNmRyh3v+HPcYU27uJ/V1Dh0eJPW4sfiLVLrbySFhU3tPkys8WfM/I2g1WrL+3twY53JqlUvcXf5cdxh3bu4ruO9hh+1ubHn3f5gl1tvlze7eRDoFKpVPvU3NnqyxNtfpwRtxuI2vzoaPGTPtBZTJs/97f5ckKhnbv4rqbFD/VuP8609Rb/itr9WNPX5eB9an64R01Omy/bdvnxmby9WLv96NntyzvtvtS1BfV9g2mrL6G7felS6MNd/KGi3RvNnvGcax8PYu3xpfOowq8DOajwOOTDr/arSdjnS/Y+f6x7/Cna50P6/kAC3w2++tO0UOHR7svMdl++kedo92GXu/hDTLs3mr0+nNnjA2LtG8/p9vFUD+XikH1q/Pb6clg+9h4f2OPN1ndH+yNbRgp7fQnY78Of9/mAg8bzx72+5Lryg7Dfh3F7fXhu/3h6FMf0ZoV7Ze/3TPuD/OyAF7v3e4MTnTw4nrqj4wb3sIh9an64z5fs/d607vfmkuIYPnxxwNd9a/ewgQqPDm+qDnpx5qAX9KGPDnmy8eB4yvd7krDfh3F7I/lJs8DYA/dz+1sB3HPYm+AOT7IOerHosDdHDnlx7ip97jnkM4req3ctc9CPuw5788IhLy4e8oKh1GFP/nTU6zp4neq1yKEHeeCoD+uOeHKuwxNcqSOevNfhQ3az6hp+1Pr1QkcgP+r0ovjoOPYfGcf5I+NgMDrqycfHvFjxtg9Bwz0nN4PkrV9y87EH0RzzZt7RB3nx2DjeOubJyU4vvuj05ELnOLqPefKXY54cPzqO1s4HWfmmJ/nv3u++YdONGzdu3Lhx48aNGzdu3Lhx48aNGzdu3Lhx4+Zq/D+9fBbn0eLVnwAAAABJRU5ErkJggg==" alt="直达" id="L_DirectButton" class="direct-button" />
<span title="粘贴或输入包含单链接的文本后点击输入框直达链接">
<input type="text" id="L_DirectInput" class="direct-input" placeholder="粘贴或输入链接" />
</span>
</div>`);
GM_addStyle(`#L_DirectTo input {
outline: none;
}
#L_DirectTo {
position: fixed;
left: 0;
top: 25%;
}
#L_DirectButton {
width: 30px;
height: 30px;
position: absolute;
z-index: 1;
left: -16px;
}
#L_DirectInput {
width: 300px;
height: 22px;
position: absolute;
left: -350px;
border: 3px solid #b52bff;
border-radius: 20px;
background-color: #99adf7;
padding-left: 10px;
box-sizing: content-box;
}
`);
let direct = $('#L_DirectTo'),
input = $('#L_DirectInput'),
button = $('#L_DirectButton');
input.on('click', obj => listener(obj));
input.on('paste', () => {
setTimeout(() => input[0].click(), 500);
});
// 清空输入框文本内容
input.val('');
button.on('click', () => {
if (button.hasClass('open')) {
input.animate({ left: '-350px' }).val('').blur();
button.removeClass('open');
button.prop('title', '点击展开输入框');
} else {
button.addClass('open');
input.focus().animate({ left: '28px' });
button.prop('title', '点击收起输入框');
}
})
.on('mouseover', () => {
button.animate({ left: 0 });
if (!button.hasClass('open')) button.click();
})
.on('mouseout', () => {
if (!button.hasClass('open'))
button.animate({ left: '-16px' });
});
let timeId = null;
direct.on('mouseout', () => {
timeId = setTimeout(() => {
if (button.hasClass('open')) {
button.click();
button.animate({ left: '-16px' });
}
}, 5000);
})
.on('mouseover', () => {
if (timeId) clearTimeout(timeId);
});
}
}
}
});