mirror of
https://github.com/Shik3i/KoalaSync.git
synced 2026-08-30 20:49:22 +00:00
fix: Firefox invite — cloneInto() for CustomEvent detail (XrayWrapper)
This commit is contained in:
+10
-7
@@ -22,12 +22,15 @@ window.addEventListener('KOALASYNC_JOIN_REQUEST', (e) => {
|
|||||||
// 3. Listen for Status Updates from the Extension and relay to Website
|
// 3. Listen for Status Updates from the Extension and relay to Website
|
||||||
chrome.runtime.onMessage.addListener((msg) => {
|
chrome.runtime.onMessage.addListener((msg) => {
|
||||||
if (msg.type === 'JOIN_STATUS') {
|
if (msg.type === 'JOIN_STATUS') {
|
||||||
const event = new CustomEvent('KOALASYNC_STATUS', {
|
const detail = { success: msg.success, message: msg.message };
|
||||||
detail: {
|
// Firefox MV3 content scripts run in an isolated world. When dispatching
|
||||||
success: msg.success,
|
// a CustomEvent with a detail object, Firefox wraps it in an XrayWrapper
|
||||||
message: msg.message
|
// that the page's JavaScript cannot destructure (Permission denied).
|
||||||
}
|
// cloneInto() exposes the object to the page's context correctly.
|
||||||
});
|
// Chrome doesn't have this issue — cloneInto() is undefined there.
|
||||||
window.dispatchEvent(event);
|
const safeDetail = typeof cloneInto === 'function'
|
||||||
|
? cloneInto(detail, document.defaultView)
|
||||||
|
: detail;
|
||||||
|
window.dispatchEvent(new CustomEvent('KOALASYNC_STATUS', { detail: safeDetail }));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "koalasync",
|
"name": "koalasync",
|
||||||
"version": "1.8.7",
|
"version": "1.8.8",
|
||||||
"description": "KoalaSync Build Scripts",
|
"description": "KoalaSync Build Scripts",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user