您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Create DOM elements with a createElement-like jsx function
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.gf.qytechs.cn/scripts/477758/1267093/%40suchipijsxdom.js
// ==UserScript== // @name @suchipi/jsxdom // @version 0.4.1 // @description Create DOM elements with a createElement-like jsx function // @author Lily Skye // @grant none // @license MIT // ==/UserScript== (function () { "use strict"; const ref = (...args) => { return { current: args.length > 0 ? args[0] : null }; }; const nodeFactory = (type, props) => { if (typeof type !== "string") { return document.createDocumentFragment(); } const otherProps = Object.assign({}, props); { delete otherProps.style; delete otherProps.ref; delete otherProps.namespaceURI; delete otherProps.children; delete otherProps.tagName; } let node; if (props.namespaceURI) { node = document.createElementNS(props.namespaceURI, type); } else { node = document.createElement(type); } if (props.style != null) { Object.assign(node.style, props.style); } if (props.ref != null) { if (typeof props.ref === "function") { props.ref.call(null, node); } else { props.ref.current = node; } } Object.assign(node, otherProps); return node; }; const jsx = (type, ...args) => { let rawProps = null; let children = null; if (typeof args[0] === "object" && args[0] != null) { if (args[0] instanceof Node) { children = args; } else { rawProps = args[0]; children = args.slice(1); } } else { children = args; } children = children.flat(Infinity); const props = rawProps || {}; props.children = children; if (type === DocumentFragment || typeof type === "string") { const node = nodeFactory(type, props); for (const child of children) { if (child == null) continue; if (typeof child === "object") { node.appendChild(child); } else { const textNode = document.createTextNode(String(child)); node.appendChild(textNode); } } return node; } else { return type(props); } }; const createElement = jsx; const Fragment = DocumentFragment; var jsxdom = /*#__PURE__*/ Object.freeze({ __proto__: null, Fragment: Fragment, createElement: createElement, jsx: jsx, nodeFactory: nodeFactory, ref: ref, }); globalThis.jsxdom = jsxdom; })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址