-
如何真的关闭 JS 代码片段?
2026-11-12 11:47@wilsons 我现在有个利用 Document.currentScript 的新方法,不需要填 id 了,每个 JS 片段都通用:
(function () { // 在同步阶段取值,进入回调 / await 之后为 null const selfScript = document.currentScript; if (!selfScript) return; const observer = new MutationObserver(function (mutationsList, observer) { for (const mutation of mutationsList) { mutation.removedNodes.forEach(function (node) { if (node === selfScript) { observer.disconnect(); // 停止监听 // ↓ 这里写清理逻辑 // document.removeEventListener('event', handler); // if (style.isConnected) style.remove(); // if (element.isConnected) element.remove(); } }); } }); observer.observe(document.head, { childList: true, subtree: true }); })(); -
大家开发 plugin 用的哪个 sample 模板?
2026-11-11 12:43你把 https://github.com/siyuan-note/plugin-sample 链接和你的需求都告诉 AI,并且让 AI 选一个长期维护比较好的框架,AI 会自己选
-
大家开发 plugin 用的哪个 sample 模板?
2026-11-11 11:16直接用 https://github.com/siyuan-note/plugin-sample 就行了,官方维护,纯 TS 让 AI Agent 也能轻松理解。现在 AI 做个脚手架快得很,随便什么前端框架信手拈来,都不需要另外两个了。


