From 261b4a312fde57eb96dc49eb9b65694b78567481 Mon Sep 17 00:00:00 2001 From: maomao <1714487678@qq.com> Date: Fri, 20 Sep 2024 12:59:15 +0800 Subject: [PATCH] =?UTF-8?q?feat(remove-redirect):=20=E9=80=82=E9=85=8D=20A?= =?UTF-8?q?CG=20=E7=9B=92=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/mean-pears-matter.md | 5 +++ packages/remove-redirect/metablock.json | 4 +-- .../remove-redirect/src/sites/acgbox.link.ts | 35 +++++++++++++++++++ packages/remove-redirect/src/sites/index.ts | 1 + 4 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 .changeset/mean-pears-matter.md create mode 100644 packages/remove-redirect/src/sites/acgbox.link.ts diff --git a/.changeset/mean-pears-matter.md b/.changeset/mean-pears-matter.md new file mode 100644 index 0000000..bdbc236 --- /dev/null +++ b/.changeset/mean-pears-matter.md @@ -0,0 +1,5 @@ +--- +'remove-redirect': minor +--- + +适配 ACG 盒子 diff --git a/packages/remove-redirect/metablock.json b/packages/remove-redirect/metablock.json index 8694b76..c3e0c40 100644 --- a/packages/remove-redirect/metablock.json +++ b/packages/remove-redirect/metablock.json @@ -1,11 +1,11 @@ { "name": "跳转链接修复(移除重定向外链直达)", "name:zh-CN": "跳转链接修复(移除重定向外链直达)", - "name:zh-TW": "跳转链接修复(移除重定向外链直达)", + "name:zh-TW": "跳轉連結修復(移除重定向外鏈直達)", "name:en": "Remove Redirect", "namespace": "maomao1996.remove-redirect", "version": "1.12.0", - "description": "提升用户体验:修复跳转链接为站外直链(移除重定向直接跳转),免去拦截页面点击步骤可直达站外;拦截页面自动跳转(无须额外操作);已适配爱发电、百度搜索、百度贴吧、Bing 搜索、书签地球、酷安、CSDN、豆瓣、Facebook、码云、Google 搜索、Google 重定向页、花瓣网、InfoQ、Instagram、简书、掘金、金山文档、链滴、力扣(Leetcode)、51CTO 博客、NGA 玩家社区、牛客网、开源中国、pixiv、微信、微信开放社区、QQ 邮箱、PC 版 QQ、腾讯文档、腾讯兔小巢、石墨文档、360 搜索、搜狗搜索、少数派、腾讯云开发者社区、推特(Twitter)、微博、YouTube、语雀、知乎、知乎专栏", + "description": "提升用户体验:修复跳转链接为站外直链(移除重定向直接跳转),免去拦截页面点击步骤可直达站外;拦截页面自动跳转(无须额外操作);已适配ACG盒子、爱发电、百度搜索、百度贴吧、Bing 搜索、书签地球、酷安、CSDN、豆瓣、Facebook、码云、Google 搜索、Google 重定向页、花瓣网、InfoQ、Instagram、简书、掘金、金山文档、链滴、力扣(Leetcode)、51CTO 博客、NGA 玩家社区、牛客网、开源中国、pixiv、微信、微信开放社区、QQ 邮箱、PC 版 QQ、腾讯文档、腾讯兔小巢、石墨文档、360 搜索、搜狗搜索、少数派、腾讯云开发者社区、推特(Twitter)、微博、YouTube、语雀、知乎、知乎专栏", "author": "", "homepage": "", "supportURL": "", diff --git a/packages/remove-redirect/src/sites/acgbox.link.ts b/packages/remove-redirect/src/sites/acgbox.link.ts new file mode 100644 index 0000000..9bb0acb --- /dev/null +++ b/packages/remove-redirect/src/sites/acgbox.link.ts @@ -0,0 +1,35 @@ +import { validateUrl } from '@femm/shared-utils' +import { defineSite } from 'src/utils' + +/****************************************************************************** + ** ACG盒子 + ** - https://www.acgbox.link + ** - https://www.acgbox.link/h/58.html + ** - https://www.acgbox.link/go/?url=aHR0cHM6Ly93d3cucGl4aXYubmV0Lw%3D%3D + ******************************************************************************/ +const sites = [ + defineSite([ + 'ACG盒子', + 'acgbox.link', + { + transform: { + selector: 'a[href*="/go/?url"]', + customTransform(node) { + let originUrl = decodeURIComponent(node.href.split('?url=')[1]) + try { + originUrl = atob(originUrl) + if (validateUrl(originUrl)) { + node.href = originUrl + } + } catch {} + }, + }, + autojump: { + validator: ({ pathname }) => pathname === '/go/', + selector: 'a.loading-btn', + }, + }, + ]), +] + +export default sites diff --git a/packages/remove-redirect/src/sites/index.ts b/packages/remove-redirect/src/sites/index.ts index c01cb69..cc306ea 100644 --- a/packages/remove-redirect/src/sites/index.ts +++ b/packages/remove-redirect/src/sites/index.ts @@ -1,4 +1,5 @@ export { default as m_51CtoCom } from './51cto.com' +export { default as acgboxLink } from './acgbox.link' export { default as afdianCom } from './afdian.com' export { default as baiduCom } from './baidu.com' export { default as bingCom } from './bing.com'