nomadro/apps/miniprogram/xhs/release/app.js
eric 9f8fec1723 Ship portal PC/H5 acceptance, VIP ScrollReader, admin analytics and ops anchors.
Adds /api/health, ntfy notify on config save, /admin/analytics charts, and deploy smoke for miniprogram config/API.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-28 23:52:00 -05:00

1060 lines
35 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* bundled classic script for xhs minitool */
/* auto-generated — do not edit */
window.__NAV_DATA__ = {
"brand": "游民导航",
"tagline": "数字游民工具与出海资源合集",
"footer": "2026 游民导航",
"categories": [
{
"id": "nomad",
"title": "数字游民",
"emoji": "✦",
"groups": [
{
"id": "community",
"title": "游民社区",
"links": [
{
"id": "nomadro",
"title": "nomadro",
"subtitle": "出海导航",
"href": "https://nomadro.com",
"icon": "/icons/nomadro.webp"
},
{
"id": "nomadlist",
"title": "nomadlist",
"subtitle": "海外最大的数字游民社区",
"href": "https://nomads.com?ref=https://nomadro.com",
"icon": "/icons/nomadlist.webp"
},
{
"id": "nomadcna",
"title": "nomadcna",
"subtitle": "国内数字游民社区",
"href": "https://meetup.hackrobot.cn",
"icon": "/icons/nomadcna.webp"
}
]
},
{
"id": "toolbox",
"title": "工具箱",
"links": [
{
"id": "chatgpt",
"title": "ChatGPT",
"subtitle": "OpenAI 开发的人工智能聊天机器人",
"href": "https://chat.openai.com/",
"icon": "/icons/chatgpt.webp"
},
{
"id": "grok",
"title": "Grok",
"subtitle": "xAI 免费 AI 助手,追求真实与客观",
"href": "https://grok.com/",
"icon": "/icons/grok.webp"
}
]
},
{
"id": "us-phone",
"title": "美国手机号",
"links": [
{
"id": "1psim",
"title": "1psim",
"subtitle": "低成本 2.5$/m,支持 eSIM 和实体卡(邮寄中国)",
"href": "https://1psim.com/7GARRL",
"icon": "/icons/1psim.webp"
},
{
"id": "yesim",
"title": "yesim",
"subtitle": "美国手机号,3$/m",
"href": "https://yesim.app/?partner_id=1948",
"icon": "/icons/yesim.webp"
},
{
"id": "tello",
"title": "tello",
"subtitle": "最低 5$/m,支持 eSIM",
"href": "https://tello.com/",
"icon": "/icons/tello.webp"
},
{
"id": "9esim",
"title": "9esim",
"subtitle": "让任何手机支持 eSIM,可写数据的 SIM 实体卡",
"href": "https://www.9esim.com/?coupon=XIAOSHUANGERIC2",
"icon": "/icons/9esim.webp"
}
]
},
{
"id": "finance",
"title": "金融收款",
"links": [
{
"id": "wise",
"title": "wise",
"subtitle": "线上开通境外银行账户(身份证即可)",
"href": "https://wise.com/invite/amc/xiaoshuangh",
"icon": "/icons/wise.webp"
},
{
"id": "okx",
"title": "OKX 交易所",
"subtitle": "加密货币交易所",
"href": "https://okx.com/join/84999861",
"icon": "/icons/okx.webp"
},
{
"id": "safepal",
"title": "safepal (U卡)",
"subtitle": "邀请码 104809,出海神卡,加密货币与法币转换",
"href": "https://www.safepal.com/zh-cn/",
"icon": "/icons/safepal.webp"
},
{
"id": "paypal",
"title": "paypal",
"subtitle": "出海收款必备,TikTok 提现、佣金提现",
"href": "https://py.pl/1tyAwY",
"icon": "/icons/paypal.webp"
},
{
"id": "bmc",
"title": "buy me coffee",
"subtitle": "赞助收款平台",
"href": "https://www.buymeacoffee.com/invite/xiaoshuangi",
"icon": "/icons/bmc.webp"
}
]
}
]
},
{
"id": "studio",
"title": "工作室",
"emoji": "☕",
"groups": [
{
"id": "proxy",
"title": "科学上网",
"links": [
{
"id": "jms",
"title": "just my socks",
"subtitle": "老牌网络代理服务",
"href": "https://justmysocks.net/members/aff.php?aff=12475",
"icon": "/icons/jms.webp"
},
{
"id": "ykk",
"title": "Ykk Cloud",
"subtitle": "性价比高的网络加速服务",
"href": "https://panel.ykkk.best/#/register?code=xYQebIgT",
"icon": "/icons/ykk.webp"
}
]
},
{
"id": "vps",
"title": "VPS 服务器",
"links": [
{
"id": "vultr",
"title": "vultr",
"subtitle": "可按分钟计费的服务器(可支付宝)",
"href": "https://www.vultr.com/?ref=8985003",
"icon": "/icons/vultr.webp"
},
{
"id": "bwh",
"title": "bandwagonhost",
"subtitle": "针对中国线路优化的高质量 VPS",
"href": "https://bandwagonhost.com/aff.php?aff=25463",
"icon": "/icons/bwh.webp"
},
{
"id": "racknerd",
"title": "RackNerd",
"subtitle": "最便宜的美国 VPS 服务器",
"href": "https://my.racknerd.com/aff.php?aff=15630",
"icon": "/icons/racknerd.webp"
},
{
"id": "qcloud",
"title": "腾讯云",
"subtitle": "腾讯服务器,国内速度快",
"href": "https://curl.qcloud.com/BZZ2MBTN",
"icon": "/icons/qcloud.webp"
},
{
"id": "aliyun",
"title": "阿里云",
"subtitle": "阿里巴巴旗下 VPS 服务器",
"href": "https://www.aliyun.com/minisite/goods?userCode=dii0ofzg",
"icon": "/icons/aliyun.webp"
},
{
"id": "colocrossing",
"title": "colocrossing",
"subtitle": "美国 VPS 服务商",
"href": "https://cloud.colocrossing.com/aff.php?aff=1846",
"icon": "/icons/colocrossing.webp"
}
]
},
{
"id": "resi-ip",
"title": "静态住宅 IP",
"links": [
{
"id": "iproyal",
"title": "iproyal",
"subtitle": "静态住宅 IP,出海必备",
"href": "https://iproyal.cn/?r=nomadro",
"icon": "/icons/iproyal.webp"
},
{
"id": "proxy-cheap",
"title": "proxy-cheap",
"subtitle": "便宜的住宅 IP",
"href": "https://app.proxy-cheap.com/r/bmcMoY",
"icon": "/icons/proxy-cheap.webp"
},
{
"id": "smartproxy",
"title": "smartproxy",
"subtitle": "静态住宅 IP 服务商",
"href": "https://www.smartproxy.org/register/?invitation_code=7RXPLM",
"icon": "/icons/smartproxy.webp"
}
]
},
{
"id": "resi-vps",
"title": "住宅 VPS 服务器",
"links": [
{
"id": "lisa",
"title": "lisa",
"subtitle": "住宅 IP 服务器,TikTok 必备",
"href": "https://lisahost.com/aff.php?aff=7566",
"icon": "/icons/lisa.webp"
},
{
"id": "voyracloud",
"title": "voyracloud",
"subtitle": "静态住宅 IP 服务器",
"href": "https://www.voyracloud.com/?ref_code=2LJPRTE5",
"icon": "/icons/voyracloud.webp"
}
]
},
{
"id": "hardware",
"title": "硬件",
"links": [
{
"id": "rpi",
"title": "树莓派",
"subtitle": "无与伦比的 ARM 开发板",
"href": "https://uland.taobao.com/coupon/edetail?e=5hkWkiThOmClhHvvyUNXZfh8CuWt5YH5OVuOuRD5gLJMmdsrkidbOWBzzpT26idJPSbzO0ArF68ertbZl9wqRUbeJevxT02sHgNIxyFsmaMOsi2OxhyQb%2BhYUTTNN7GRRSHvQe2jOLZ9pbNCYX0I%2BPP%2BWUTgK%2F%2B0I%2BtaUgbudUxA%2B536asYsLWVfKa%2BhVnND4NyB1fwjO3bJLf667Yy8Q5jB6TX2HR3Qrq8LCw4Dujjqyaqc1rGLUwdQHHM8iY%2BUDMxLRSiIntldeBz90au3REAmOgZ0RtdnfeSBK3KXa0%2FA9snq37kKL6zL4bZ3EAS%2F2oYsLHTsIOxroXBFP6oz%2BA%3D%3D&traceId=213e032e17650447230113327e0c4f&union_lens=lensId%3APUB%401765044691%400b521400_0da4_19af4dca231_da77%400290EZjuZ2xbgOlH3NTYAyI%40eyJmbG9vcklkIjoyMDg3MTcxMDEwLCJzcG1CIjoiiX3BvcnRhbF92Ml90b29sX3NlbGVjdGlvbmxpc3RfZGV0YWlsX2luZGV4X2h0bSIsInNyY0Zsb29ySWQiiOiiI4MDY2NCJ9",
"icon": "/icons/rpi.webp"
},
{
"id": "mini-pc",
"title": "迷你主机",
"subtitle": "具有性价比的 X86 小主机",
"href": "https://s.click.taobao.com/t?e=m%3D2%26s%3DCb1Quo%2F0Wb5w4vFB6t2Z2ueEDrYVVa64YUrQeSeIhnK53hKxp7mNFuhCZFSw9yq2woqx0EHqItb0JlhLk0Jl4eVWmNyHytKdTKJ80yOOA0Mtd0e5Ku7CIDk5ffgV5fRI1qrpxiwMoCNxc1AtbZGVS936JshS%2F%2FIdwgQgG5hIzyLNEPXytV9ALtCLThlbPuuZLb93Df8fOziGg7JVKZos%2BjLJJgRsfWlWtajntMnDLEHhuApO%2F8klJ62RdK%2B6%2FP7Z6k6s3rDgsC6jO9AJYjY8CXJ%2BwEVkOqHFPSJJXArlDuzso5nyPLY4NPiLqets6lIJ",
"icon": "/icons/mini-pc.webp"
},
{
"id": "gpu",
"title": "GPU 显卡",
"subtitle": "AI 时代的算力基础设施",
"href": "https://union-click.jd.com/jdc?e=618%7Cpc%7C&p=JF8BATUJK1olXwEDUFZVCkkRC18IGloWWwALV19aAUonRzBQRQQlBENHFRxWFlVPRjtUBABAQlRcCEBdCUoUBWkBGFoSVAcdDRsBVXsQB29pbiZRKGMHKlclCEgVWghcGV91UQoyVW5dCUoWAmYPHl4RbTYCU24fZp-esLulkIK0yd6n5V1eOEonA2kPH1oQWQUFV19VCnsQA2Y4El0dWQ4LU1hBC00SCmcJK2slXjYFVFdJDjlWUXsOaWslXTYBZF5cCEoQAGoLH1kRQQYHV1lbAFcXBWgMGl4RXgUKUllYOEkWAmsBK2vL05J3IB9Uajl8UStqSz4dFQ9jitDJGTlnA2sPH0olImF5ECFaSU0VVAdNQDxuW09KFiw8SyljbW1jcih3JWNxNlwaS0hqWBhoX2sQbQEEVW4",
"icon": "/icons/gpu.webp"
}
]
},
{
"id": "software",
"title": "软件",
"links": [
{
"id": "3x-ui",
"title": "3X-UI",
"subtitle": "科学上网仪表盘",
"href": "https://github.com/MHSanaei/3x-ui",
"icon": "/icons/3x-ui.webp"
},
{
"id": "mihomo",
"title": "虚空终端 mihomo",
"subtitle": "代理软件以及配置 wiki",
"href": "https://wiki.metacubex.one/config/",
"icon": "/icons/mihomo.webp"
},
{
"id": "frp",
"title": "frp",
"subtitle": "高性能内网穿透",
"href": "https://gofrp.org/zh-cn/docs/",
"icon": "/icons/frp.webp"
},
{
"id": "wireguard",
"title": "wireguard",
"subtitle": "P2P 打洞组网",
"href": "https://github.com/WireGuard/wireguard-go",
"icon": "/icons/wireguard.webp"
},
{
"id": "lineageos",
"title": "lineageos (pi5)",
"subtitle": "树莓派的安卓 LineageOS",
"href": "https://konstakang.com/devices/rpi5/",
"icon": "/icons/lineageos.webp"
}
]
},
{
"id": "gear",
"title": "数码装备",
"links": [
{
"id": "ai-glasses",
"title": "AI 眼镜",
"subtitle": "第一视角拍摄",
"href": "https://union-click.jd.com/jdc?e=618%7Cpc%7C&p=JF8BATkJK1olXw8AXVxfCU8UA18IGloVWwcKXFlZDUgnRzBQRQQlBENHFRxWFlVPRjtUBABAQlRcCEBdCUoXBW4AE1wRWAUdDRsBVXtwXw1pZzNKAmZgFFwlYUh8UzVBZyZlUQoyVW5dCUoWAmYPHl4RbTYCU24fZpO9hbeBtYKjxt-jwInikZ-fjV8JK1sTWgIDUVtVAEkVA2w4HFscbQ8EXFpVAUwRH2wOHlIdXDYyZF1tD0seF2l6WgkBW3QyZF5tC3sXAm8AGFsVXAEBXEJdDUMVB24UG10SWQcHUVZbAE8fCl8KGloRVDYyitPtY0JrQAYIYj0dXGZKMVc5T5Was35jYlMVXQUTZAQOch9SZTMNbC9gIGdQJi5VCzkRSCpfWDUXVAJlDQoCbw1gcG9qRwYdHnYyUW5aDEgn",
"icon": "/icons/ai-glasses.webp"
},
{
"id": "action-cam",
"title": "运动相机",
"subtitle": "骑行记录仪",
"href": "https://union-click.jd.com/jdc?e=618%7Cpc%7C&p=JF8BASgJK1olXDYCVV9eCE0UB28ME1slGVlaCgFtUQ5SQi0DBUVNGFJeSwUIFxlJX3EIGloWXQABUF5ZAEsIWipURmt3CFhXIQkpbChuRy8JGDpRJUJQDwkbBEcnAl8IGloUXA8FUVtZOHsXBF9edVsUXAcDVV1fDEonAl8IHVwRXAMGVVpaDEsUM2gIEmscWw4GXFdaDlcUBWoBE1olbTYBZFldAV8RcS5aD11nbTYCZF1tCEoXAmsNHl8UXQQeVF1ZDE0UH28OHF8UWAIDUVddCkgnAW4JH1IlbdiMwDxcaAJfBTlNTRpCBHpHLhyDht8GcR8BHFIUTDZ6NSMpYRJweWtBfAUXC2JyXBkpfTNRWi1mGV4UAlgENFpeDA13cRRcTAJLbQMyU1peOA",
"icon": "/icons/action-cam.webp"
},
{
"id": "drone",
"title": "无人机",
"subtitle": "天空视角",
"href": "https://union-click.jd.com/jdc?e=618%7Cpc%7C&p=JF8BASgJK1olXDYCVV9eAUIeB2YMH14lGVlaCgFtUQ5SQi0DBUVNGFJeSwUIFxlJX3EIGloWVA8LUFdZDE4IWipURmtCHHVEABsFVChPYRJAbVhlGRhbFRgLBEcnAl8IGloUXA8FUVtZOHsXBF9edVsUXAcDVV1fDEonAl8IHVwRXAMGVVdbC04VM2gIEmscWw4GXFdaDlcUBWoBE1olbTYBZFldAV8RcS5aD11nbTYCZF1tCEoXAmgLHlgRXgIeVFpfDU0UH28OHF8UWAIDUlteAUwnAW4JH1IlbdiMwCQvcipMBxJhfV9HGgF3FVaDht8GfxgBGVkRTDZUCjsVbzBTYRJbeRkWGG9WAx02D0JcUy5mGRNRFEJiUwgldStzfx1wTj1GbQMyU1peOA",
"icon": "/icons/drone.webp"
}
]
}
]
},
{
"id": "overseas",
"title": "出海掘金",
"emoji": "◎",
"groups": [
{
"id": "tiktok",
"title": "TikTok",
"links": [
{
"id": "tiktok",
"title": "TikTok",
"subtitle": "全球直播平台",
"href": "https://www.tiktok.com/",
"icon": "/icons/tiktok.webp"
},
{
"id": "cloud-phone",
"title": "云手机",
"subtitle": "用开源硬件打造云手机",
"href": "https://www.hackrobot.cn/",
"icon": "/icons/cloud-phone.webp"
},
{
"id": "vcam",
"title": "vcam 虚拟摄像头",
"subtitle": "Xposed 模块,替换摄像头视频流",
"href": "https://pan.baidu.com/s/1NW4GMGA3cxfUQNWZPD9vOg?pwd=live",
"icon": "/icons/vcam.webp"
}
]
},
{
"id": "youtube",
"title": "YouTube",
"links": [
{
"id": "youtube",
"title": "YouTube",
"subtitle": "全球最大的视频网站",
"href": "https://www.youtube.com/",
"icon": "/icons/youtube.webp"
},
{
"id": "smmfollows",
"title": "smmfollows",
"subtitle": "刷粉刷量平台",
"href": "https://smmfollows.com/ref/dfugq",
"icon": "/icons/smmfollows.webp"
},
{
"id": "yt-auto-dismiss",
"title": "YouTube Studio Auto Dismiss",
"subtitle": "油猴脚本,无人直播辅助",
"href": "https://greasyfork.org/zh-CN/scripts/557378-youtube-studio-auto-dismiss",
"icon": "/icons/yt-auto-dismiss.webp"
}
]
},
{
"id": "web",
"title": "Web 网站",
"links": [
{
"id": "namesilo",
"title": "namesilo",
"subtitle": "注册域名",
"href": "https://www.namesilo.com/?rid=3bd4047mc",
"icon": "/icons/namesilo.webp"
},
{
"id": "aapanel",
"title": "aapanel",
"subtitle": "宝塔面板",
"href": "https://www.aapanel.com?referral_code=wcn04vez",
"icon": "/icons/aapanel.webp"
},
{
"id": "cloudflare",
"title": "Cloudflare",
"subtitle": "互联网基础节点",
"href": "https://www.cloudflare.com/",
"icon": "/icons/cloudflare.webp"
},
{
"id": "ga",
"title": "Google Analytics",
"subtitle": "网站流量统计服务",
"href": "https://analytics.google.com/",
"icon": "/icons/ga.webp"
},
{
"id": "adsense",
"title": "Google AdSense",
"subtitle": "Google 广告服务",
"href": "https://www.google.com/adsense/",
"icon": "/icons/adsense.webp"
}
]
}
]
},
{
"id": "live",
"title": "无人直播",
"emoji": "▷",
"groups": [
{
"id": "live-soft",
"title": "软件",
"links": [
{
"id": "obs",
"title": "OBS",
"subtitle": "免费开源:录屏 / 推流直播",
"href": "https://pan.quark.cn/s/03e89f1bbc9b",
"icon": "/icons/obs.webp"
},
{
"id": "ffmpeg",
"title": "ffmpeg",
"subtitle": "命令行视频处理 / 推流,Python 自动化",
"href": "https://www.ffmpeg.org/download.html",
"icon": "/icons/ffmpeg.webp"
},
{
"id": "srs",
"title": "SRS",
"subtitle": "开源直播服务器,拉流推流中转",
"href": "https://ossrs.io/",
"icon": "/icons/srs.webp"
}
]
}
]
},
{
"id": "pay",
"title": "支付网关",
"emoji": "◇",
"groups": [
{
"id": "merchant",
"title": "小微商户",
"links": [
{
"id": "nowpayments",
"title": "NOWPayments",
"subtitle": "加密货币收款",
"href": "https://account.nowpayments.io/create-account?link_id=3680795921",
"icon": "/icons/nowpayments.webp"
},
{
"id": "creem",
"title": "Creem",
"subtitle": "软件出海收款,税务合规",
"href": "https://www.creem.io/",
"icon": "/icons/creem.webp"
},
{
"id": "stripe",
"title": "Stripe",
"subtitle": "全球在线支付",
"href": "https://stripe.com/",
"icon": "/icons/stripe.webp"
},
{
"id": "zpay",
"title": "z-pay",
"subtitle": "支持独角数卡 · 易支付",
"href": "https://z-pay.cn/?uid=22119",
"icon": "/icons/zpay.webp"
},
{
"id": "xorpay",
"title": "xorpay",
"subtitle": "支持收银台支付",
"href": "https://xorpay.com?r=nomadro",
"icon": "/icons/xorpay.webp"
}
]
}
]
},
{
"id": "books",
"title": "书籍",
"emoji": "◈",
"groups": [
{
"id": "handbook",
"title": "手册",
"links": [
{
"id": "nomad-book",
"title": "数字游民手册",
"subtitle": "复制链接后在小红书打开",
"href": "https://www.xiaohongshu.com/s/poster?bgimg=https%3A%2F%2Fsns-redskillhub-s1.xhscdn.com%2Fred_app_image%2F1040g4m8325ke1q36l0404a4druqrlvd5valvb80%3Fsign%3Dbc0c41c2e219f6ca904f52176bd17f54%26t%3D6c9a7a85&xhsshare=&appuid=5acc75ba4eacab15c751fda5&apptime=1790527237&deeplink=xhsdiscover%3A%2F%2FminiTool%2F6ab8984da1e3af0015584e92%3Fsource%3Dh5%26page_key%3D28%26xhsMpScreenMode%3Dfull%26share_id%3D5e90e5979b054c8baf8b3db4c8993d79%26share_channel%3Dcopy_link",
"icon": "/icons/nomad-book.webp",
"action": "copy"
}
]
}
]
},
{
"id": "forum",
"title": "论坛社区",
"emoji": "◉",
"groups": [
{
"id": "blog",
"title": "博客",
"links": [
{
"id": "yidu",
"title": "异度世界",
"subtitle": "独立博客,Hugo 搭建",
"href": "https://blog.hackrobot.cn",
"icon": "/icons/yidu.webp"
},
{
"id": "dsx",
"title": "大师兄",
"subtitle": "AI 实践",
"href": "https://dsx2016.com",
"icon": "/icons/dsx.webp"
}
]
}
]
}
]
};
/* 游民导航 · 小红书小工具(纯离线 classic script) */
(function () {
"use strict";
var data = window.NAV_DATA || {};
var categories = data.categories || [];
var state = {
theme: "light",
activeId: categories[0] ? categories[0].id : "",
drawerOpen: false,
sheetOpen: false,
currentLink: null,
jumping: false,
};
var els = {};
function $(id) {
return document.getElementById(id);
}
function qs(sel, root) {
return (root || document).querySelector(sel);
}
function escapeHtml(str) {
return String(str == null ? "" : str)
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;");
}
function applySafeArea() {
try {
var root = document.documentElement;
var probe = document.createElement("div");
probe.style.cssText =
"position:absolute;visibility:hidden;pointer-events:none;padding-top:constant(safe-area-inset-top);padding-top:env(safe-area-inset-top);";
document.body.appendChild(probe);
var envTop = parseFloat(window.getComputedStyle(probe).paddingTop) || 0;
document.body.removeChild(probe);
// 小红书宿主顶栏(返回 / 分享)常盖住内容;Android 上 env 常为 0
var status = envTop > 0 ? envTop : 28;
var hostBar = 44;
var padTop = Math.max(status + hostBar, 72);
root.style.setProperty("--app-pad-top", padTop + "px");
root.style.setProperty("--safe-area-inset-top", status + "px");
} catch (e) {
document.documentElement.style.setProperty("--app-pad-top", "80px");
}
}
function readTheme() {
try {
var saved = localStorage.getItem("navmini-xhs-theme");
if (saved === "light" || saved === "dark") return saved;
} catch (e) {}
return "light";
}
function setTheme(theme) {
state.theme = theme;
document.documentElement.setAttribute("data-theme", theme);
try {
localStorage.setItem("navmini-xhs-theme", theme);
} catch (e) {}
if (els.themeIcon) {
els.themeIcon.textContent = theme === "dark" ? "☀" : "☾";
}
}
function showToast(msg) {
if (!els.toast) return;
els.toast.textContent = msg;
els.toast.classList.add("show");
clearTimeout(showToast._t);
showToast._t = setTimeout(function () {
els.toast.classList.remove("show");
}, 1600);
}
/** 选中网址文本(容器禁用程序化写入剪贴板,仅做文本选中) */
function selectUrlText() {
try {
var node = els.sheetUrlBox;
if (!node) return false;
var range = document.createRange();
range.selectNodeContents(node);
var sel = window.getSelection();
if (!sel) return false;
sel.removeAllRanges();
sel.addRange(range);
return true;
} catch (e) {
return false;
}
}
function setGuideStep(step) {
var items = els.guideSteps
? els.guideSteps.querySelectorAll(".guide-step")
: [];
for (var i = 0; i < items.length; i++) {
var n = i + 1;
items[i].classList.toggle("is-active", n === step);
items[i].classList.toggle("is-done", n < step);
}
}
function setGuideUi(phase) {
// phase: idle | selected
var selected = phase === "selected";
if (els.sheetUrlBox) {
els.sheetUrlBox.classList.toggle("is-pulse", !selected);
els.sheetUrlBox.classList.toggle("is-selected", selected);
}
if (els.sheetSelect) {
els.sheetSelect.classList.toggle("pulse", !selected);
els.sheetSelect.classList.toggle("is-done", selected);
}
if (els.sheetSelectLabel) {
els.sheetSelectLabel.textContent = selected
? "② 已选中 · 再点可重选"
: "① 点我选中网址";
}
if (els.sheetSelectSub) {
els.sheetSelectSub.textContent = selected
? "下一步:手指按住蓝色网址区"
: "选中后请按住网址复制";
}
// 第一步:只显示向下指按钮的小手;第二步:小手上移指网址,文案在右边
if (els.fingerBtn) {
els.fingerBtn.classList.toggle("is-hidden", selected);
els.fingerBtn.setAttribute("aria-hidden", selected ? "true" : "false");
}
if (els.fingerUrl) {
els.fingerUrl.classList.toggle("is-hidden", !selected);
els.fingerUrl.setAttribute("aria-hidden", selected ? "false" : "true");
}
if (els.sheetUrlWrap) {
els.sheetUrlWrap.classList.toggle("is-pointing", selected);
}
setGuideStep(selected ? 2 : 1);
}
function findCategory(id) {
for (var i = 0; i < categories.length; i++) {
if (categories[i].id === id) return categories[i];
}
return categories[0] || null;
}
function countLinks(cat) {
var n = 0;
var groups = cat.groups || [];
for (var i = 0; i < groups.length; i++) {
n += (groups[i].links || []).length;
}
return n;
}
function renderDrawer() {
var html = "";
for (var i = 0; i < categories.length; i++) {
var cat = categories[i];
var active = cat.id === state.activeId ? " active" : "";
html +=
'<button type="button" class="drawer-item' +
active +
'" data-cat="' +
escapeHtml(cat.id) +
'">' +
'<span class="drawer-emoji" aria-hidden="true">' +
escapeHtml(cat.emoji || "·") +
"</span>" +
'<span class="drawer-item-title">' +
escapeHtml(cat.title) +
"</span>" +
'<span class="drawer-item-count">' +
countLinks(cat) +
"</span>" +
"</button>";
}
els.drawerNav.innerHTML = html;
}
function renderContent() {
var html = "";
for (var i = 0; i < categories.length; i++) {
var cat = categories[i];
html +=
'<section class="cat-panel" id="cat-' +
escapeHtml(cat.id) +
'">' +
'<header class="cat-heading"><h2>' +
escapeHtml(cat.title) +
'</h2><span class="cat-count">' +
countLinks(cat) +
"</span></header>";
var groups = cat.groups || [];
for (var g = 0; g < groups.length; g++) {
var group = groups[g];
html +=
'<div class="group-block"><h3 class="group-title">' +
escapeHtml(group.title) +
'</h3><div class="link-grid">';
var links = group.links || [];
for (var l = 0; l < links.length; l++) {
var link = links[l];
html +=
'<button type="button" class="link-card" data-cat="' +
escapeHtml(cat.id) +
'" data-group="' +
escapeHtml(group.id) +
'" data-id="' +
escapeHtml(link.id) +
'">' +
'<span class="link-icon-wrap"><img class="link-icon" src="' +
escapeHtml(link.icon) +
'" alt="" width="34" height="34" loading="lazy" /></span>' +
'<span class="link-meta"><span class="link-title">' +
escapeHtml(link.title) +
'</span><span class="link-desc">' +
escapeHtml(link.subtitle || "") +
"</span></span></button>";
}
html += "</div></div>";
}
html += "</section>";
}
els.content.innerHTML = html;
}
function setDrawer(open) {
state.drawerOpen = open;
els.drawer.classList.toggle("open", open);
els.drawer.setAttribute("aria-hidden", open ? "false" : "true");
document.body.style.overflow = open || state.sheetOpen ? "hidden" : "";
}
function setSheet(open) {
state.sheetOpen = open;
els.sheet.classList.toggle("open", open);
els.sheet.setAttribute("aria-hidden", open ? "false" : "true");
document.body.style.overflow = open || state.drawerOpen ? "hidden" : "";
}
function findLink(catId, groupId, linkId) {
var cat = findCategory(catId);
if (!cat) return null;
var groups = cat.groups || [];
for (var i = 0; i < groups.length; i++) {
if (groups[i].id !== groupId) continue;
var links = groups[i].links || [];
for (var j = 0; j < links.length; j++) {
if (links[j].id === linkId) return links[j];
}
}
return null;
}
function openLink(link) {
// 容器禁止打开外链 / 跳转其他小工具(见能力清单 §4.2),一律走复制引导
openLinkSheet(link);
}
function openLinkSheet(link) {
state.currentLink = link;
els.sheetIcon.src = link.icon || "./icons/_brand.webp";
els.sheetTitle.textContent = link.title || "";
els.sheetSub.textContent = link.subtitle || "";
els.sheetUrlBox.textContent = link.href || "";
els.sheetStatus.textContent = "按步骤操作:先点绿色按钮选中网址";
els.sheetStatus.classList.remove("is-error");
setGuideUi("idle");
setSheet(true);
}
function markSelected() {
if (!state.currentLink) return;
if (selectUrlText()) {
setGuideUi("selected");
els.sheetStatus.textContent =
"已选中蓝色区域 · 请用手指按住网址,在菜单里点「复制」";
els.sheetStatus.classList.remove("is-error");
showToast("已选中,请按住复制");
// 短暂强调第 3 步
setTimeout(function () {
setGuideStep(3);
var s2 = els.guideSteps && els.guideSteps.querySelector('[data-step="2"]');
if (s2) s2.classList.add("is-done");
}, 1600);
} else {
setGuideUi("idle");
els.sheetStatus.textContent = "自动选中失败,请手指直接按住蓝色网址文字";
els.sheetStatus.classList.add("is-error");
setGuideStep(2);
}
}
function jumpToCategory(id) {
state.activeId = id;
setPill();
renderDrawer();
setDrawer(false);
state.jumping = true;
var el = document.getElementById("cat-" + id);
if (el) {
el.scrollIntoView({ behavior: "smooth", block: "start" });
}
setTimeout(function () {
state.jumping = false;
}, 700);
}
function setPill() {
var cat = findCategory(state.activeId);
if (els.brandCurrent && cat) {
els.brandCurrent.textContent = cat.title;
}
}
function onScroll() {
var y = window.scrollY || document.documentElement.scrollTop || 0;
els.backTop.classList.toggle("show", y > 480);
if (state.jumping) return;
var marker = 100;
var current = categories[0] ? categories[0].id : "";
for (var i = 0; i < categories.length; i++) {
var el = document.getElementById("cat-" + categories[i].id);
if (!el) continue;
if (el.getBoundingClientRect().top <= marker) {
current = categories[i].id;
} else {
break;
}
}
if (current && current !== state.activeId) {
state.activeId = current;
setPill();
renderDrawer();
}
}
function bind() {
els.btnMenu.addEventListener("click", function () {
setDrawer(true);
});
els.drawerMask.addEventListener("click", function () {
setDrawer(false);
});
els.drawerClose.addEventListener("click", function () {
setDrawer(false);
});
els.btnTheme.addEventListener("click", function () {
setTheme(state.theme === "dark" ? "light" : "dark");
});
els.backTop.addEventListener("click", function () {
window.scrollTo({ top: 0, behavior: "smooth" });
});
els.drawerNav.addEventListener("click", function (e) {
var btn = e.target.closest(".drawer-item");
if (!btn) return;
jumpToCategory(btn.getAttribute("data-cat"));
});
els.content.addEventListener("click", function (e) {
var btn = e.target.closest(".link-card");
if (!btn) return;
var link = findLink(
btn.getAttribute("data-cat"),
btn.getAttribute("data-group"),
btn.getAttribute("data-id")
);
if (link) openLink(link);
});
els.sheetMask.addEventListener("click", function () {
setSheet(false);
});
els.sheetClose.addEventListener("click", function () {
setSheet(false);
});
els.sheetSelect.addEventListener("click", function () {
markSelected();
});
els.sheetUrlBox.addEventListener("click", function () {
markSelected();
});
// 用户开始触碰网址区时,推进到第 2/3 步提示
els.sheetUrlBox.addEventListener("touchstart", function () {
if (els.sheetUrlBox.classList.contains("is-selected")) {
setGuideStep(3);
var s2 = els.guideSteps && els.guideSteps.querySelector('[data-step="2"]');
if (s2) s2.classList.add("is-done");
els.sheetStatus.textContent = "按住不放,在弹出菜单中点「复制」";
}
}, { passive: true });
window.addEventListener("scroll", onScroll, { passive: true });
}
function init() {
els = {
brandName: $("brand-name"),
brandCurrent: $("brand-current"),
brandLogo: $("brand-logo"),
footer: $("footer"),
content: $("content"),
drawer: $("drawer"),
drawerNav: $("drawer-nav"),
drawerMask: $("drawer-mask"),
drawerClose: $("drawer-close"),
drawerBrand: $("drawer-brand"),
drawerSub: $("drawer-sub"),
btnMenu: $("btn-menu"),
btnTheme: $("btn-theme"),
themeIcon: $("theme-icon"),
backTop: $("back-top"),
sheet: $("sheet"),
sheetMask: $("sheet-mask"),
sheetIcon: $("sheet-icon"),
sheetTitle: $("sheet-title"),
sheetSub: $("sheet-sub"),
sheetUrlBox: $("sheet-url-box"),
sheetStatus: $("sheet-status"),
sheetSelect: $("sheet-select"),
sheetSelectLabel: $("sheet-select-label"),
sheetSelectSub: $("sheet-select-sub"),
sheetClose: $("sheet-close"),
guideSteps: $("guide-steps"),
sheetUrlWrap: $("sheet-url-wrap"),
fingerBtn: $("finger-btn"),
fingerUrl: $("finger-url"),
toast: $("toast"),
};
applySafeArea();
setTheme(readTheme());
var brand = data.brand || "游民导航";
els.brandName.textContent = brand;
els.footer.textContent = data.footer || "";
els.drawerBrand.textContent = brand;
els.drawerSub.textContent = data.tagline || "";
if (data.brandIcon && els.brandLogo) {
els.brandLogo.src = data.brandIcon;
}
renderDrawer();
renderContent();
setPill();
bind();
onScroll();
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", init);
} else {
init();
}
})();