{"version":3,"file":"chrome-extension/dynamic-scripts.mjs","sources":["../../../src/chrome-extension/dynamic-scripts.ts"],"sourcesContent":["import fs from 'node:fs';\nimport { ifInBrowser, ifInWorker } from '@midscene/shared/utils';\n\n// remember to include this file into extension's package\n// extract html element from page\nlet scriptFileContentCache: string | null = null;\nexport const getHtmlElementScript = async () => {\n  const scriptFileToRetrieve = chrome.runtime.getURL('scripts/htmlElement.js');\n  if (scriptFileContentCache) return scriptFileContentCache;\n  if (ifInBrowser || ifInWorker) {\n    const script = await fetch(scriptFileToRetrieve);\n    scriptFileContentCache = await script.text();\n    return scriptFileContentCache;\n  }\n  return fs.readFileSync(scriptFileToRetrieve, 'utf8');\n};\n\n// inject water flow animation\nlet waterFlowScriptFileContentCache: string | null = null;\nexport const injectWaterFlowAnimation = async () => {\n  const waterFlowScriptFileToRetrieve = chrome.runtime.getURL(\n    'scripts/water-flow.js',\n  );\n  if (waterFlowScriptFileContentCache) return waterFlowScriptFileContentCache;\n  if (ifInBrowser || ifInWorker) {\n    const script = await fetch(waterFlowScriptFileToRetrieve);\n    waterFlowScriptFileContentCache = await script.text();\n    return waterFlowScriptFileContentCache;\n  }\n  return fs.readFileSync(waterFlowScriptFileToRetrieve, 'utf8');\n};\n\n// inject stop water flow animation\nlet stopWaterFlowScriptFileContentCache: string | null = null;\nexport const injectStopWaterFlowAnimation = async () => {\n  const stopWaterFlowScriptFileToRetrieve = chrome.runtime.getURL(\n    'scripts/stop-water-flow.js',\n  );\n  if (stopWaterFlowScriptFileContentCache)\n    return stopWaterFlowScriptFileContentCache;\n  if (ifInBrowser || ifInWorker) {\n    const script = await fetch(stopWaterFlowScriptFileToRetrieve);\n    stopWaterFlowScriptFileContentCache = await script.text();\n    return stopWaterFlowScriptFileContentCache;\n  }\n  return fs.readFileSync(stopWaterFlowScriptFileToRetrieve, 'utf8');\n};\n"],"names":["scriptFileContentCache","getHtmlElementScript","scriptFileToRetrieve","chrome","ifInBrowser","ifInWorker","script","fetch","fs","waterFlowScriptFileContentCache","injectWaterFlowAnimation","waterFlowScriptFileToRetrieve","stopWaterFlowScriptFileContentCache","injectStopWaterFlowAnimation","stopWaterFlowScriptFileToRetrieve"],"mappings":";;AAKA,IAAIA,yBAAwC;AACrC,MAAMC,uBAAuB;IAClC,MAAMC,uBAAuBC,OAAO,OAAO,CAAC,MAAM,CAAC;IACnD,IAAIH,wBAAwB,OAAOA;IACnC,IAAII,eAAeC,YAAY;QAC7B,MAAMC,SAAS,MAAMC,MAAML;QAC3BF,yBAAyB,MAAMM,OAAO,IAAI;QAC1C,OAAON;IACT;IACA,OAAOQ,QAAAA,YAAe,CAACN,sBAAsB;AAC/C;AAGA,IAAIO,kCAAiD;AAC9C,MAAMC,2BAA2B;IACtC,MAAMC,gCAAgCR,OAAO,OAAO,CAAC,MAAM,CACzD;IAEF,IAAIM,iCAAiC,OAAOA;IAC5C,IAAIL,eAAeC,YAAY;QAC7B,MAAMC,SAAS,MAAMC,MAAMI;QAC3BF,kCAAkC,MAAMH,OAAO,IAAI;QACnD,OAAOG;IACT;IACA,OAAOD,QAAAA,YAAe,CAACG,+BAA+B;AACxD;AAGA,IAAIC,sCAAqD;AAClD,MAAMC,+BAA+B;IAC1C,MAAMC,oCAAoCX,OAAO,OAAO,CAAC,MAAM,CAC7D;IAEF,IAAIS,qCACF,OAAOA;IACT,IAAIR,eAAeC,YAAY;QAC7B,MAAMC,SAAS,MAAMC,MAAMO;QAC3BF,sCAAsC,MAAMN,OAAO,IAAI;QACvD,OAAOM;IACT;IACA,OAAOJ,QAAAA,YAAe,CAACM,mCAAmC;AAC5D"}