drukscode-v2/docs/zh/extensions/api-reference.md
OpenCode AI e9899d2e6d
Some checks failed
Android CI Build / check (push) Has been cancelled
Android CI Build / package-apks (push) Has been cancelled
Docs Deploy / build (push) Has been cancelled
Module Market Check / Validate modules/ (push) Has been cancelled
Module Market Publish / Generate submissions.json (push) Has been cancelled
Docs Deploy / deploy (push) Has been cancelled
Initial DruksCode V2: fresh fork of web-to-app (f3b488e) with DruksCode identity
- Package rename com.webtoapp -> br.com.drukstech.codeapp
- Product rename WebToApp/web-to-app -> DruksCode/drukscode
- Design system Wta* -> Dkc*
- applicationId br.com.drukstech.codeapp (.play for gplay flavor)
- rootProject.name DruksCode
- Fresh git history (upstream kept as remote for sync)
2026-09-12 02:42:02 +02:00

2.2 KiB

API 参考

扩展 API 的汇总参考。状态图例:

  • ✅ 可用 —— 按预期工作。
  • 🟡 部分 —— 可用但有注意事项(见说明)。
  • ⬜ 桩 —— 存在但返回默认值 / no-op。

油猴脚本 GM_*

API 状态 说明
GM_getValue / GM_setValue / GM_deleteValue / GM_listValues ✅ SharedPreferences 支撑,按脚本命名空间
GM_xmlhttpRequest ✅ 经 OkHttp;完整回调集
GM_addStyle ✅
GM_setClipboard ✅
GM_openInTab ✅
GM_log ✅
GM_getResourceText / GM_getResourceURL ✅
GM_registerMenuCommand / GM_unregisterMenuCommand ✅ 浮窗菜单
GM_openScriptWindow / GM_updateScriptWindow / GM_closeScriptWindow ✅ DruksCode 专属
GM_info ✅
unsafeWindow ✅ 等于 window(无沙箱)
GM_notification 🟡 仅记录日志;无系统通知
@grant 门控 ⬜ 无论声明的 grant,所有 API 都暴露
GM.*(Promise) ✅ 镜像上述全部

Chrome chrome.*

命名空间 状态 说明
runtime ✅ 消息、生命周期、getURL、getManifest
storage ✅ local/sync/session;managed no-op
tabs ✅ 核心增删改查 + 事件
scripting ✅ 动态 content script 注册
cookies ✅
alarms ✅
declarativeNetRequest ✅ block/allow/redirect/modifyHeaders/upgradeScheme
downloads 🟡 download 可用
webRequest 🟡 onBeforeRequest 经原生桥过滤
i18n / notifications / permissions / contextMenus / commands ✅
webNavigation / extension / idle / tabGroups 🟡
action / sidePanel 🟡
windows / management / topSites / fontSettings ⬜ 桩
identity / history / proxy / privacy ⬜ 桩
system.cpu/memory/display/storage ⬜ 桩
bookmarks / offscreen / tts ⬜ 桩
browserAction / pageAction(MV2) 🟡 兼容别名

::: tip 本表是活文档 可用/桩状态正在逐项核实。有疑问时,请以当前构建实测为准。 :::