diff --git a/_locales/zh_CN/messages.json b/_locales/zh_CN/messages.json index e24f5e5..74d2856 100644 --- a/_locales/zh_CN/messages.json +++ b/_locales/zh_CN/messages.json @@ -4,7 +4,7 @@ "description": "插件名称" }, "extDescription": { - "message": "AutoRedirector 是一款智能跳转插件,可自动绕过各大网站的中转链接,直接跳转到目标页面,提升浏览体验,减少不必要的等待和手动点击。支持 QQ、微信、CSDN、知乎、掘金、微博、豆瓣、LeetCode 等常见网站,智能解析 URL 或 HTML 页面中的真实目标链接,确保用户快速访问所需内容。", + "message": "AutoRedirector 是一款智能跳转插件,可自动绕过各大网站的中转链接,直接跳转到目标页面,提升浏览体验,减少不必要的等待和手动点击。", "description": "插件简介" } } diff --git a/background.js b/background.js index d503d03..6572b48 100644 --- a/background.js +++ b/background.js @@ -1,42 +1,42 @@ // 配置对象:每个 hostname 对应一个跳转规则 const redirectMap = { // 常规操作 - "link.juejin.cn": { testHref: "https://link.juejin.cn/?target=https://github.com/galaxy-sea" }, - "link.csdn.net": { testHref: "https://link.csdn.net/?target=https://github.com/galaxy-sea" }, - "link.zhihu.com": { testHref: "https://link.zhihu.com/?target=https://github.com/galaxy-sea" }, - "c.pc.qq.com": { testHref: "https://c.pc.qq.com/pc.html?url=https://github.com/galaxy-sea" }, - "hd.nowcoder.com": { testHref: "https://hd.nowcoder.com/link.html?target=https://github.com/galaxy-sea" }, - "link.uisdc.com": { testHref: "https://link.uisdc.com/?redirect=https://github.com/galaxy-sea" }, + "link.juejin.cn": { testHref: "https://link.juejin.cn/?target=https://github.com/galaxy-sea/AutoRedirector" }, + "link.csdn.net": { testHref: "https://link.csdn.net/?target=https://github.com/galaxy-sea/AutoRedirector" }, + "link.zhihu.com": { testHref: "https://link.zhihu.com/?target=https://github.com/galaxy-sea/AutoRedirector" }, + "c.pc.qq.com": { testHref: "https://c.pc.qq.com/pc.html?url=https://github.com/galaxy-sea/AutoRedirector" }, + "hd.nowcoder.com": { testHref: "https://hd.nowcoder.com/link.html?target=https://github.com/galaxy-sea/AutoRedirector" }, + "link.uisdc.com": { testHref: "https://link.uisdc.com/?redirect=https://github.com/galaxy-sea/AutoRedirector" }, // 需要判断域名和路径 - "www.jianshu.com": { path: "/go-wild", testHref: "https://www.jianshu.com/go-wild?ac=2&url=https://github.com/galaxy-sea" }, - "www.douban.com": { path: "/link2", testHref: "https://www.douban.com/link2/?url=https://github.com/galaxy-sea" }, - "steamcommunity.com": { path: "/linkfilter", testHref: "https://steamcommunity.com/linkfilter/?url=https://github.com/galaxy-sea" }, + "www.jianshu.com": { path: "/go-wild", testHref: "https://www.jianshu.com/go-wild?ac=2&url=https://github.com/galaxy-sea/AutoRedirector" }, + "www.douban.com": { path: "/link2", testHref: "https://www.douban.com/link2/?url=https://github.com/galaxy-sea/AutoRedirector" }, + "steamcommunity.com": { path: "/linkfilter", testHref: "https://steamcommunity.com/linkfilter/?url=https://github.com/galaxy-sea/AutoRedirector" }, "www.tianyancha.com": { path: "/security", testHref: "https://www.tianyancha.com/security?target=http://github.com/galaxy-sea" }, - "game.bilibili.com": { path: "/linkfilter", testHref: "https://game.bilibili.com/linkfilter/?url=https://github.com/galaxy-sea" }, - "www.chinaz.com": { path: "/go.shtml", testHref: "https://www.chinaz.com/go.shtml?url=https://github.com/galaxy-sea" }, - "www.youtube.com": { path: "/redirect", testHref: "https://www.youtube.com/redirect?q=https://github.com/galaxy-sea" }, - "mail.qq.com": { path: "/cgi-bin/readtemplate", testHref: "https://mail.qq.com/cgi-bin/readtemplate?t=safety&check=false&gourl=https://github.com/galaxy-sea&subtemplate=gray&evil=0" }, - "weibo.cn": { path: "/sinaurl", testHref: "https://weibo.cn/sinaurl?u=https://github.com/galaxy-sea" }, - "afdian.com": { path: "/link", testHref: "https://afdian.com/link?target=https://github.com/galaxy-sea" }, - "ask.latexstudio.net": { path: "/go/index", testHref: "https://ask.latexstudio.net/go/index?url=https://github.com/galaxy-sea" }, - "blzxteam.com": { path: "/gowild", testHref: "https://blzxteam.com/gowild.htm?url=https://github.com/galaxy-sea" }, + "game.bilibili.com": { path: "/linkfilter", testHref: "https://game.bilibili.com/linkfilter/?url=https://github.com/galaxy-sea/AutoRedirector" }, + "www.chinaz.com": { path: "/go.shtml", testHref: "https://www.chinaz.com/go.shtml?url=https://github.com/galaxy-sea/AutoRedirector" }, + "www.youtube.com": { path: "/redirect", testHref: "https://www.youtube.com/redirect?q=https://github.com/galaxy-sea/AutoRedirector" }, + "mail.qq.com": { path: "/cgi-bin/readtemplate", testHref: "https://mail.qq.com/cgi-bin/readtemplate?t=safety&check=false&gourl=https://github.com/galaxy-sea/AutoRedirector&subtemplate=gray&evil=0" }, + "weibo.cn": { path: "/sinaurl", testHref: "https://weibo.cn/sinaurl?u=https://github.com/galaxy-sea/AutoRedirector" }, + "afdian.com": { path: "/link", testHref: "https://afdian.com/link?target=https://github.com/galaxy-sea/AutoRedirector" }, + "ask.latexstudio.net": { path: "/go/index", testHref: "https://ask.latexstudio.net/go/index?url=https://github.com/galaxy-sea/AutoRedirector" }, + "blzxteam.com": { path: "/gowild", testHref: "https://blzxteam.com/gowild.htm?url=https://github.com/galaxy-sea/AutoRedirector" }, "cloud.tencent.com": { path: "/developer/tools/blog-entry", testHref: "https://cloud.tencent.com/developer/tools/blog-entry?target=http%3A%2F%2Fgithub.com%2Foctokit&objectId=1434763&objectType=1&isNewArticle=undefined" }, - "docs.qq.com": { path: "/scenario/link.html", testHref: "https://docs.qq.com/scenario/link.html?url=https://github.com/galaxy-sea" }, - "gitee.com": { path: "/link", testHref: "https://gitee.com/link?target=https://github.com/galaxy-sea" }, - "leetcode.cn": { path: "/link", testHref: "https://leetcode.cn/link/?target=https://github.com/galaxy-sea" }, - "sspai.com": { path: "/link", testHref: "https://sspai.com/link?target=https://github.com/galaxy-sea" }, - "t.me": { path: "/iv", testHref: "https://t.me/iv?url=https://github.com/galaxy-sea" }, - "tieba.baidu.com": { path: "/mo/q/checkurl", testHref: "https://tieba.baidu.com/mo/q/checkurl?url=https://github.com/galaxy-sea" }, - "www.gcores.com": { path: "/link", testHref: "https://www.gcores.com/link?target=https://github.com/galaxy-sea" }, - "www.kookapp.cn": { path: "/go-wild", testHref: "https://www.kookapp.cn/go-wild.html?url=https://github.com/galaxy-sea" }, - "www.oschina.net": { path: "/action/GoToLink", testHref: "https://www.oschina.net/action/GoToLink?url=https://github.com/galaxy-sea" }, - "www.qcc.com": { path: "/web/transfer-link", testHref: "https://www.qcc.com/web/transfer-link?link=https://github.com/galaxy-sea" }, - "www.yuque.com": { path: "/r/goto", testHref: "https://www.yuque.com/r/goto?url=https://github.com/galaxy-sea" }, - "xie.infoq.cn": { path: "/link", testHref: "https://xie.infoq.cn/link?target=https://github.com/galaxy-sea" }, - "www.baike.com": { path: "/redirect_link", testHref: "https://www.baike.com/redirect_link?url=https://github.com/galaxy-sea" }, - "developers.weixin.qq.com": { path: "/community/middlepage/href", testHref: "https://developers.weixin.qq.com/community/middlepage/href?href=https://github.com/galaxy-sea" }, - "developer.aliyun.com": { path: "/redirect", testHref: "https://developer.aliyun.com/redirect?target=https://github.com/galaxy-sea" }, + "docs.qq.com": { path: "/scenario/link.html", testHref: "https://docs.qq.com/scenario/link.html?url=https://github.com/galaxy-sea/AutoRedirector" }, + "gitee.com": { path: "/link", testHref: "https://gitee.com/link?target=https://github.com/galaxy-sea/AutoRedirector" }, + "leetcode.cn": { path: "/link", testHref: "https://leetcode.cn/link/?target=https://github.com/galaxy-sea/AutoRedirector" }, + "sspai.com": { path: "/link", testHref: "https://sspai.com/link?target=https://github.com/galaxy-sea/AutoRedirector" }, + "t.me": { path: "/iv", testHref: "https://t.me/iv?url=https://github.com/galaxy-sea/AutoRedirector" }, + "tieba.baidu.com": { path: "/mo/q/checkurl", testHref: "https://tieba.baidu.com/mo/q/checkurl?url=https://github.com/galaxy-sea/AutoRedirector" }, + "www.gcores.com": { path: "/link", testHref: "https://www.gcores.com/link?target=https://github.com/galaxy-sea/AutoRedirector" }, + "www.kookapp.cn": { path: "/go-wild", testHref: "https://www.kookapp.cn/go-wild.html?url=https://github.com/galaxy-sea/AutoRedirector" }, + "www.oschina.net": { path: "/action/GoToLink", testHref: "https://www.oschina.net/action/GoToLink?url=https://github.com/galaxy-sea/AutoRedirector" }, + "www.qcc.com": { path: "/web/transfer-link", testHref: "https://www.qcc.com/web/transfer-link?link=https://github.com/galaxy-sea/AutoRedirector" }, + "www.yuque.com": { path: "/r/goto", testHref: "https://www.yuque.com/r/goto?url=https://github.com/galaxy-sea/AutoRedirector" }, + "xie.infoq.cn": { path: "/link", testHref: "https://xie.infoq.cn/link?target=https://github.com/galaxy-sea/AutoRedirector" }, + "www.baike.com": { path: "/redirect_link", testHref: "https://www.baike.com/redirect_link?url=https://github.com/galaxy-sea/AutoRedirector" }, + "developers.weixin.qq.com": { path: "/community/middlepage/href", testHref: "https://developers.weixin.qq.com/community/middlepage/href?href=https://github.com/galaxy-sea/AutoRedirector" }, + "developer.aliyun.com": { path: "/redirect", testHref: "https://developer.aliyun.com/redirect?target=https://github.com/galaxy-sea/AutoRedirector" }, // "1111111": { path: "/111111", testHref: "" }, @@ -68,7 +68,7 @@ const redirectMap = { chrome.tabs.update(tabId, { url: decodeURIComponent(url.replace("https://blog.51cto.com/transfer?", "")) }); }, path: "/transfer", - testHref: "https://blog.51cto.com/transfer?https://github.com/galaxy-sea" + testHref: "https://blog.51cto.com/transfer?https://github.com/galaxy-sea/AutoRedirector" }, }; diff --git a/doc/cpcqq.png b/doc/cpcqq.png new file mode 100644 index 0000000..a9ddbcf Binary files /dev/null and b/doc/cpcqq.png differ diff --git a/doc/gitee.png b/doc/gitee.png new file mode 100644 index 0000000..5f9e0c7 Binary files /dev/null and b/doc/gitee.png differ diff --git a/doc/jianshu.png b/doc/jianshu.png new file mode 100644 index 0000000..7b2c417 Binary files /dev/null and b/doc/jianshu.png differ diff --git a/doc/mailqq.png b/doc/mailqq.png new file mode 100644 index 0000000..1e117af Binary files /dev/null and b/doc/mailqq.png differ diff --git a/doc/weibo.png b/doc/weibo.png new file mode 100644 index 0000000..8fa4e04 Binary files /dev/null and b/doc/weibo.png differ diff --git a/manifest.json b/manifest-chrome.json similarity index 91% rename from manifest.json rename to manifest-chrome.json index 9f22518..cfc4b59 100644 --- a/manifest.json +++ b/manifest-chrome.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": " __MSG_extName__", - "version": "1.0", + "version": "2025.02.01.13.53", "description": "__MSG_extDescription__", "default_locale": "zh_CN", "action": { @@ -22,10 +22,8 @@ "128": "icons/icon128.png" }, "permissions": [ - "activeTab", "tabs", - "scripting", - "notifications" + "scripting" ], "host_permissions": [ "*://weixin110.qq.com/*", diff --git a/pack_extension.sh b/pack_extension.sh new file mode 100644 index 0000000..0a747a9 --- /dev/null +++ b/pack_extension.sh @@ -0,0 +1,80 @@ +#!/bin/bash + +# 获取当前目录路径 +EXT_DIR=$(cd "$(dirname "$0")" && pwd) + +# 生成 YYYY.MM.DD.HH.MM 格式的时间戳 +VERSION=$(date +%y.%m%d.%H%M) + +# 颜色输出 +GREEN='\033[0;32m' +RED='\033[0;31m' +NC='\033[0m' # 无颜色 + +# 选择浏览器类型 +echo "请选择要打包的插件类型:" +echo "0) 全部打包" +echo "1) Chrome" +echo "2) Firefox" +echo "3) Edge" +echo "9) 删除打包文件" +read -p "输入选项 (1/2/3/4): " BROWSER_CHOICE + +# 定义打包函数 +pack_extension() { + local BROWSER_NAME=$1 + local MANIFEST_FILE=$2 + local ZIP_NAME="extension_${BROWSER_NAME}.zip" + + echo "🔹 正在打包 ${BROWSER_NAME} 插件..." + cp "$EXT_DIR/$MANIFEST_FILE" "$EXT_DIR/manifest.json" + + # 确保 manifest.json 存在 + if [ ! -f "$EXT_DIR/manifest.json" ]; then + echo -e "${RED}❌ 错误: manifest.json 未找到!${NC}" + exit 1 + fi + + # 更新 manifest.json 的 version + sed -i '' "s/\"version\": *\"[0-9\.]*\"/\"version\": \"$VERSION\"/" "$EXT_DIR/manifest.json" + + # 开始打包 ZIP(排除不必要文件) + zip -r "$ZIP_NAME" . -x "*.zip" "node_modules/*" ".git/*" "doc/*" ".DS_Store" "pack_extension.sh" + + # 结果输出 + if [ -f "$ZIP_NAME" ]; then + echo -e "${GREEN}✅ ${BROWSER_NAME} 插件打包成功!文件名: $ZIP_NAME 版本号: $VERSION${NC}" + else + echo -e "${RED}❌ ${BROWSER_NAME} 插件打包失败!${NC}" + fi +} + +delete_zip_file() { + rm extension_Chrome.zip extension_Edge.zip extension_Firefox.zip manifest.json +} + +# 根据用户选择执行打包 +case $BROWSER_CHOICE in + 0) + echo "🔄 开始打包所有浏览器插件..." + pack_extension "Chrome" "manifest-chrome.json" + pack_extension "Firefox" "manifest-firefox.json" + pack_extension "Edge" "manifest-edge.json" + ;; + 1) + pack_extension "Chrome" "manifest-chrome.json" + ;; + 2) + pack_extension "Firefox" "manifest-firefox.json" + ;; + 3) + pack_extension "Edge" "manifest-edge.json" + ;; + 9) + delete_zip_file + ;; + *) + echo -e "${RED}❌ 无效的选项!请重新运行脚本并输入 1 / 2 / 3 / 4。${NC}" + exit 1 + ;; +esac