-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
2,324 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,6 @@ | |
"globals": { | ||
"chrome": "readonly" | ||
}, | ||
"ignorePatterns": ["watch.js", "dist/**"] | ||
"ignorePatterns": ["dist/**"] | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
declare global { | ||
interface Window { | ||
__PIXI_APP__: import('pixi.js').Application | undefined; | ||
__PIXI_STAGE__: import('pixi.js').Container | undefined; | ||
__PIXI_RENDERER__: import('pixi.js').Renderer | undefined; | ||
__PIXI__: import('pixi.js'); | ||
} | ||
} | ||
|
||
export {}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,37 @@ | ||
{ | ||
"action": { | ||
"default_popup": "src/popup/index.html", | ||
"default_icon": { | ||
"16": "icon-inactive-16.png", | ||
"32": "icon-inactive-32.png", | ||
"48": "icon-inactive-48.png", | ||
"128": "icon-inactive-128.png" | ||
} | ||
}, | ||
"icons": { | ||
"16": "icon-active-16.png", | ||
"32": "icon-active-32.png", | ||
"48": "icon-active-48.png", | ||
"128": "icon-active-128.png" | ||
}, | ||
"web_accessible_resources": [ | ||
{ | ||
"resources": [ | ||
"contentStyle.css", | ||
"icon-active-128.png", | ||
"icon-inactive-32.png" | ||
], | ||
"matches": ["<all_urls>"] | ||
} | ||
], | ||
"devtools_page": "src/devtools/index.html" | ||
} | ||
|
||
"action": { | ||
"default_popup": "src/popup/index.html", | ||
"default_icon": { | ||
"16": "icon-inactive-16.png", | ||
"32": "icon-inactive-32.png", | ||
"48": "icon-inactive-48.png", | ||
"128": "icon-inactive-128.png" | ||
} | ||
}, | ||
"content_scripts": [ | ||
{ | ||
"matches": ["http://*/*", "https://*/*", "<all_urls>"], | ||
"js": ["src/content/index.ts"], | ||
"css": ["contentStyle.css"], | ||
"run_at": "document_start" | ||
} | ||
], | ||
"background": { | ||
"service_worker": "src/background/index.ts", | ||
"type": "module" | ||
}, | ||
"icons": { | ||
"16": "icon-active-16.png", | ||
"32": "icon-active-32.png", | ||
"48": "icon-active-48.png", | ||
"128": "icon-active-128.png" | ||
}, | ||
"permissions": ["activeTab"], | ||
"devtools_page": "src/devtools/index.html", | ||
"web_accessible_resources": [ | ||
{ | ||
"resources": ["contentStyle.css", "icon-active-128.png", "icon-inactive-32.png"], | ||
"matches": ["<all_urls>"] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1 @@ | ||
// Function to check if a global variable exists | ||
function hasGlobal(varname: string) { | ||
return window[varname as keyof Window] || Array.from(window.frames).some((frame) => frame[varname as keyof Window]); | ||
} | ||
|
||
// Function to detect PixiJS | ||
function detectPixi() { | ||
return hasGlobal('__PIXI_APP__') || hasGlobal('__PIXI_STAGE__') || hasGlobal('__PIXI_RENDERER__') | ||
? 'detected' | ||
: 'disabled'; | ||
} | ||
|
||
let pixiPollingInterval: number | undefined; | ||
|
||
// Function to start polling for PixiJS | ||
function startPixiPolling() { | ||
pixiPollingInterval = window.setInterval(() => { | ||
try { | ||
const pixiDetectionResult = detectPixi(); | ||
|
||
if (pixiDetectionResult === 'detected') { | ||
clearInterval(pixiPollingInterval); | ||
window.postMessage({ type: 'pixi-detected' }, '*'); | ||
} | ||
} catch (error) { | ||
clearInterval(pixiPollingInterval); | ||
} | ||
}, 300); | ||
|
||
return pixiPollingInterval; | ||
} | ||
|
||
startPixiPolling(); | ||
import '@lib/src/detection' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
export enum MessageType { | ||
Inactive = 'inactive', | ||
Active = 'active', | ||
PopupOpened = 'popup-opened', | ||
PixiDetected = 'pixi-detected', | ||
|
||
InjectSettingsChanged = 'inject-settings-changed', | ||
|
||
StateUpdate = 'pixi-state-update', | ||
} | ||
|
||
/** | ||
* Standard message format | ||
* @param method - The message type | ||
* @param data - The message data | ||
* @returns | ||
*/ | ||
export function convertPostMessage(method: MessageType, data: unknown) { | ||
return { method, data: JSON.stringify(data) }; | ||
} | ||
|
||
/** | ||
* Convert the message data to a standard format | ||
* @param a - The original message | ||
*/ | ||
export function convertPostMessageData(a: ReturnType<typeof convertPostMessage>) { | ||
let data: string | object = a.data; | ||
|
||
if (typeof data === 'string') { | ||
try { | ||
data = JSON.parse(data); | ||
} catch (error) { | ||
data = {}; | ||
} | ||
} | ||
return { | ||
method: a.method, | ||
data, | ||
}; | ||
} |
Oops, something went wrong.