// ==UserScript== // @name 应用宝一键跳转下载 // @namespace https://github.com/fanxing724/yyb-auto-jump // @version 2.1 // @description 访问应用宝详情页时自动提取包名,一键跳转到 simple.jsp 下载页,省去手动查找的麻烦 // @author Marvis // @license MIT // @match https://sj.qq.com/appdetail/* // @match https://android.myapp.com/myapp/detail.htm* // @match https://sj.qq.com/myapp/detail.htm* // @run-at document-start // @grant none // @homepageURL https://github.com/fanxing724/yyb-auto-jump // @supportURL https://github.com/fanxing724/yyb-auto-jump/issues // ==/UserScript== (function () { "use strict"; const url = location.href; // 已在目标下载页,不处理(防止死循环) if (url.startsWith("https://a.app.qq.com/o/simple.jsp?")) return; // 包名校验正则:标准的 Android 包名格式 const PKG_RE = /^[a-zA-Z][a-zA-Z0-9_]*(?:\.[a-zA-Z][a-zA-Z0-9_]*){1,}$/; let pkgname = null; // ① 路径提取:/appdetail/<包名>(最常见) const pathMatch = url.match(/\/appdetail\/([^/?]+)/); if (pathMatch && PKG_RE.test(pathMatch[1])) { pkgname = pathMatch[1]; } // ② URL 参数提取:pkgname=xxx 或 apkName=xxx if (!pkgname) { try { const params = new URL(url).searchParams; pkgname = params.get("pkgname") || params.get("apkName"); if (pkgname && !PKG_RE.test(pkgname)) pkgname = null; } catch (e) { // URL 解析失败,忽略 } } if (!pkgname) return; console.log(`[应用宝跳转] 检测到包名: ${pkgname},正在跳转下载页...`); location.replace( `https://a.app.qq.com/o/simple.jsp?pkgname=${encodeURIComponent(pkgname)}` ); })();