diff --git a/Configuration/ESBuild.ts b/Configuration/ESBuild.ts index 732b45b..d84436e 100644 --- a/Configuration/ESBuild.ts +++ b/Configuration/ESBuild.ts @@ -1,30 +1,31 @@ -import type { PluginBuild, BuildOptions } from "esbuild"; - -import { copy as Copy } from "esbuild-plugin-copy"; -import { rm as Remove } from "fs/promises"; - -const outDir = "Target"; - +/** + * @module ESBuild + * + */ export default { format: "esm", minify: true, - outdir: outDir, + outdir: "Target", bundle: true, platform: "browser", target: ["edge104", "esnext"], plugins: [ { name: "Target", - setup: (Build: PluginBuild) => - Build.onStart(async () => { + setup: ({ onStart, initialOptions: { outdir } }) => + onStart(async () => { try { - await Remove(outDir, { - recursive: true, - }); + outdir + ? await ( + await import("fs/promises") + ).rm(outdir, { + recursive: true, + }) + : {}; } catch (_Error) {} }), }, - Copy({ + (await import("esbuild-plugin-copy")).copy({ resolveFrom: "out", assets: [ { @@ -34,4 +35,6 @@ export default { ], }), ], -} satisfies Type; +} satisfies BuildOptions; + +import type { BuildOptions } from "esbuild"; diff --git a/Source/Script/Fa.ts b/Source/Script/Fa.ts index 5e166a8..eddc633 100644 --- a/Source/Script/Fa.ts +++ b/Source/Script/Fa.ts @@ -1,5 +1,3 @@ -import DOM from "../Library/DOM.js"; - declare global { interface Window { interval: NodeJS.Timer; @@ -16,20 +14,20 @@ const refresh = async () => { window.timeout = setTimeout( async () => ( - await DOM.getElement( + await getElement( '[data-testid="aircraft-panel__header"] button.rounded-md' ) ).forEach((el) => el.click()), 25000 ); - const Focus = await DOM.getElement( + const Focus = await getElement( '[data-testid="most-tracked-flights-widget"] [data-testid="list-wrapper"] > div' ); const Identifier = Math.floor(Math.random() * Focus.length); - (await DOM.getElement('[data-testid="map-controls__zoom-in"]')).forEach( + (await getElement('[data-testid="map-controls__zoom-in"]')).forEach( (el) => setTimeout(() => { el?.click(); @@ -40,7 +38,7 @@ const refresh = async () => { Focus.item(Identifier)?.click(); ( - await DOM.getElement( + await getElement( '.ui-icon.ui-icon-closethick,[data-testid="aircraft__not-live-flight"] [data-testid="base-button"]' ) ).forEach((el) => { @@ -49,7 +47,7 @@ const refresh = async () => { setTimeout(async () => { ( - await DOM.getElement( + await getElement( '[data-testid="aircraft__follow-flight-button"]:not(.text-yellow-500)' ) ) @@ -57,16 +55,20 @@ const refresh = async () => { ?.click(); ( - await DOM.getElement( + await getElement( '[data-testid="aircraft-panel__more__hide-not-selected-btn"] [aria-checked="false"]' ) ).forEach((el) => el?.parentElement?.click()); }, 3000); ( - await DOM.getElement(".overlay-views-panel,.section.search-overlay") + await getElement(".overlay-views-panel,.section.search-overlay") ).forEach((el) => el.remove()); }, 30000); }; await refresh(); + +export const { + default: { getElement }, +} = await import("../Library/DOM.js"); diff --git a/Source/Script/Ta.ts b/Source/Script/Ta.ts index c40f2f8..db50675 100644 --- a/Source/Script/Ta.ts +++ b/Source/Script/Ta.ts @@ -1,5 +1,3 @@ -import DOM from "../Library/DOM.js"; - declare global { interface Window { interval: NodeJS.Timer; @@ -12,20 +10,17 @@ const refresh = async () => { window.interval = setInterval(async () => { clearInterval(window.interval); - (await DOM.getElement(".js-column")).forEach(async (el) => { - const focus = await DOM.getElement(".js-stream-item", el); + (await getElement(".js-column")).forEach(async (el) => { + const focus = await getElement(".js-stream-item", el); const length = focus.length; const id = Math.floor(Math.random() * length); if ( - (await DOM.getElement(".btd-content-warning", focus.item(id))) + (await getElement(".btd-content-warning", focus.item(id))) .length === 0 ) { ( - await DOM.getElement( - ".js-stream-item-content", - focus.item(id) - ) + await getElement(".js-stream-item-content", focus.item(id)) ).forEach(async (el) => { el?.click(); }); @@ -33,7 +28,7 @@ const refresh = async () => { setTimeout( async () => { - const focus = await DOM.getElement(".js-column-back"); + const focus = await getElement(".js-column-back"); focus.forEach((el) => { el?.click(); @@ -46,7 +41,7 @@ const refresh = async () => { setTimeout( async () => { - const focus = await DOM.getElement(".column-type-icon"); + const focus = await getElement(".column-type-icon"); focus.forEach((el) => { el?.click(); @@ -62,14 +57,14 @@ const refresh = async () => { setInterval( async () => - (await DOM.getElement(".btd-clear-column-link")).forEach((el) => { + (await getElement(".btd-clear-column-link")).forEach((el) => { el?.click(); }), 55000 ); setInterval(async () => { - const translations = await DOM.getElement(".js-translate-call-to-action"); + const translations = await getElement(".js-translate-call-to-action"); let index = 0; @@ -83,7 +78,7 @@ setInterval(async () => { setTimeout( async () => ( - await DOM.getElement( + await getElement( ".js-tweet-detail.tweet-detail-wrapper .js-tweet-translation-text.tweet-translation-text" ) ).forEach((el) => { @@ -101,3 +96,7 @@ setInterval(async () => { }, 15000); await refresh(); + +export const { + default: { getElement }, +} = await import("../Library/DOM.js"); diff --git a/vite.config.ts b/vite.config.ts index 79c18d8..934d136 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,6 +1,4 @@ -import { defineConfig } from "vite"; - -export default defineConfig({ +export default (await import("vite")).defineConfig({ publicDir: "./Public", clearScreen: false, server: {