diff --git a/package-lock.json b/package-lock.json index afc7413f..6d16d0ae 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "scriptcat", - "version": "0.16.3", + "version": "0.16.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "scriptcat", - "version": "0.16.3", + "version": "0.16.5", "license": "GPLv3", "dependencies": { "@arco-design/web-react": "^2.51.1", diff --git a/package.json b/package.json index ba1fe6e9..e78002bb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "scriptcat", - "version": "0.16.4", + "version": "0.16.5", "description": "脚本猫,一个可以执行用户脚本的浏览器扩展,万物皆可脚本化,让你的浏览器可以做更多的事情!", "author": "CodFrm", "license": "GPLv3", diff --git a/src/app/message/content.ts b/src/app/message/content.ts index 5ebd95f3..3d82a196 100644 --- a/src/app/message/content.ts +++ b/src/app/message/content.ts @@ -34,14 +34,11 @@ export default class MessageContent this.nativeSend(data); }); this.relatedTarget = new Map(); - document.addEventListener( + window.addEventListener( (isContent ? "ct" : "fd") + eventId, (event: unknown) => { - if (event instanceof MutationEvent) { - this.relatedTarget.set( - parseInt(event.prevValue, 10), - event.relatedNode - ); + if (event instanceof MouseEvent) { + this.relatedTarget.set(event.clientX, event.relatedTarget); return; } const message = (< @@ -116,15 +113,11 @@ export default class MessageContent delete detail.data.relatedTarget; detail.data.relatedTarget = Math.ceil(Math.random() * 1000000); // 可以使用此种方式交互element - const ev = document.createEvent("MutationEvent"); - ev.initMutationEvent( - (this.isContent ? "fd" : "ct") + this.eventId, - false, - false, - target, - detail.data.relatedTarget.toString() - ); - document.dispatchEvent(ev); + const ev = new MouseEvent((this.isContent ? "fd" : "ct") + this.eventId, { + clientX: detail.data.relatedTarget, + relatedTarget: target, + }); + window.dispatchEvent(ev); } if (typeof cloneInto !== "undefined") { @@ -142,7 +135,7 @@ export default class MessageContent const ev = new CustomEvent((this.isContent ? "fd" : "ct") + this.eventId, { detail, }); - document.dispatchEvent(ev); + window.dispatchEvent(ev); } public send(action: string, data: any) { diff --git a/src/manifest.json b/src/manifest.json index 97fbb96e..5a6dbd1c 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "__MSG_scriptcat__", - "version": "0.16.4", + "version": "0.16.5", "author": "CodFrm", "description": "__MSG_scriptcat_description__", "options_ui": {