1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

确认页直接跳转完成;更新jQuery版本;引入MyukiToast页内弹窗小工具

This commit is contained in:
2023-01-07 04:59:45 +08:00
parent e90859286e
commit 2a18d6da17
11 changed files with 1007 additions and 11 deletions

View File

@@ -0,0 +1,60 @@
/**
* 规则定义
*/
const RedirectRule = {
// 腾讯QQ
"c.pc.qq.com": {
path: "/middlem.html",
param: "pfurl",
},
// 腾讯文档
"docs.qq.com": {
path: "/scenario/link.html",
param: "url",
},
"www.tianyancha.com": {
path: "/security",
param: "target",
},
"jump.bdimg.com": {
path: "/safecheck/index",
param: "url",
},
"jump2.bdimg.com": {
path: "/safecheck/index",
param: "url",
},
"www.chinaz.com": {
path: "/go.shtml",
param: "url",
},
"www.douban.com": {
path: "/link2/",
param: "url",
},
"link.csdn.net": {
path: "/",
param: "target",
},
"link.zhihu.com": {
path: "/",
param: "target",
},
"link.juejin.cn": {
path: "/",
param: "target",
},
"links.jianshu.com": {
path: "/go",
param: "url",
},
"www.jianshu.com": {
path: "/go-wild", // "/go-wild?ac=2&url="
param: "url",
},
// QQ、腾讯文档、天眼查、百度贴吧、站长之家、豆瓣、Zaker、开发者知识库、CSDN、知乎、掘金、简书etc...
}
if (typeof module !== 'undefined') {
module.exports = RedirectRule
}

View File

@@ -0,0 +1,18 @@
/**
* 测试用网址:
* 知乎
* https://link.zhihu.com/?target=http%3A//only4.work
*
* 腾讯文档
* https://docs.qq.com/scenario/link.html?url=only4.work
*
* CSDN
* https://link.csdn.net/?target=https%3A//only4.work
*
* 简书
* https://links.jianshu.com/go?to=http%3A%2F%2Fwww.only4.work%2F
* https://www.jianshu.com/go-wild?ac=2&url=http%3A%2F%2Fwww.only4.work%2F
*
* QQ
* https://c.pc.qq.com/middlem.html?pfurl=https%3A%2F%2Fwww.only4.work%2F&pfuin=2291200076&pfto=qq.msg&type=0&gjlevel=15&gjsublevel=2804&iscontinue=0&ADUIN=2291200076&ADSESSION=1673029605&ADTAG=CLIENT.QQ.5941_AIO.0&ADPUBNO=27268
*/

73
scripts/direct-url/url.js Normal file
View File

@@ -0,0 +1,73 @@
window.onload = function () {
// 判断功能是否启用
let isEnabled = new Promise((resolve) => {
chrome.storage.sync.get("State_DirectUrl", ({ State_DirectUrl }) => {
resolve(State_DirectUrl)
})
})
if (!isEnabled) {
console.log("[小墨助手]", "确认跳转页直接跳转功能未开启,将不进行跳转")
return;
}
console.log("[小墨助手]", "确认跳转页直接跳转模块加载成功")
// 创建一个MyukiToast的实例 // $MT = MyukiToast
// let toastObj = $MT("#xiaomo_chrome_extension_toast")
let toastObj = $MT("", {
'type': 'info', // 'type': 'warning',
'top': '60px',
'fontSize': '16px',
'width': '300px',
"dismissible": false,
'autoHide': false,
'animation': 'normal-shake' // 'vibrate-2', 'heartbeat'
})
// 获取参数
function getParams(key) {
let dict = {}
location.search.substring(1).split("&").forEach(str => {
let s = str.split("=")
dict[s[0]] = s.length > 1 ? s[1] : null
})
if (!key) return dict
else return dict[key]
}
function redirect() {
let url = location.href
let host = location.host
let path = location.pathname
let search = location.search
// console.log(url, host, path, search)
// 匹配 host
const rule = RedirectRule[host]
if (!rule) return
console.log("host匹配成功")
// 匹配 path
console.log(`real path: [${path}], rule path: [${rule.path}]`)
if (!path.startsWith(rule.path)) return
console.log("path匹配成功")
// 调用toast方法
toastObj.toast("[小墨助手] 正在自动跳转⛄️")
// 获取参数
let target = decodeURIComponent(getParams(rule.param))
// 如果不是 http(s):// 开头,则手动添加 schema
if (!target.startsWith("http"))
target = "http://" + target
// 跳转
// location.replace(target)
location.href = target
}
// setTimeout(redirect, 500)
redirect()
}