Skip to content

Commit

Permalink
wip: 🔕 temporary commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tarampampam committed Apr 29, 2024
1 parent e1613ac commit 316be22
Show file tree
Hide file tree
Showing 3 changed files with 186 additions and 108 deletions.
2 changes: 2 additions & 0 deletions src/entrypoints/content/content.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// ⚠ DO NOT IMPORT ANYTHING EXCEPT TYPES HERE DUE THE `import()` ERRORS ⚠
import type { ContentScriptPayload } from '~/shared/types'

console.log(`%c🕊 RUA: Content script is running`, 'font-weight:bold')

/** Injects and executes the script with the payload. The ID of the script tag is the same as the filename. */
const injectAndExecuteScript = (payload: ContentScriptPayload): void => {
const script = document.createElement('script')
Expand Down
4 changes: 4 additions & 0 deletions src/entrypoints/content/inject.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
// ⚠ DO NOT IMPORT ANYTHING EXCEPT TYPES HERE DUE THE `import()` ERRORS ⚠
import type { ContentScriptPayload } from '~/shared/types'

console.log(`%c👻 RUA: Injected script is running`, 'font-weight:bold')

/** Extracts the payload from the script tag. */
const extractPayload = async (
timeout: number = 2000,
interval: number = 1
): Promise<ContentScriptPayload | undefined> => {
const startedAt = Date.now()

console.log(document.getElementById(__UNIQUE_INJECT_FILENAME__))

return new Promise((resolve: (_: Awaited<ReturnType<typeof extractPayload>>) => void): void => {
const t = setInterval(() => {
// if the timeout is reached, resolve with `undefined`
Expand Down
Loading

0 comments on commit 316be22

Please sign in to comment.