UNPKG

rune-sdk

Version:

Build a multiplayer game played by millions! Your game runs inside the Rune app with 10 million installs across [iOS](https://apps.apple.com/app/rune-games-and-voice-chat/id1450358364) and [Android](https://play.google.com/store/apps/details?id=ai.rune.ti

26 lines (25 loc) 776 B
import { parse } from "node-html-parser"; export function extractJsonTags(html) { const parsedHtml = parse(html); const [head] = parsedHtml.getElementsByTagName("head"); let modifiedHtml = html; let scripts = []; if (head) { scripts = head.querySelectorAll("script[type='application/json']"); if (scripts.length > 0) { for (const script of scripts) { script.remove(); } modifiedHtml = parsedHtml.toString(); } } return { modifiedHtml, jsonScripts: scripts.map((scriptTag) => ({ tag: "script", children: scriptTag.innerHTML, attrs: { ...scriptTag.attributes }, injectTo: "head-prepend", })), }; }