Skip to content

Commit 0c2a2ba

Browse files
committed
Added event.origin to msg passing for improved security + removed redundant env.extensionActive init ↞ [auto-sync from https://github.com/adamlui/ai-web-extensions/tree/main/chatgpt-auto-continue]
1 parent 704728f commit 0c2a2ba

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

chatgpt/chatgpt-auto-continue/chatgpt-auto-continue.user.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@
219219
// @description:zu ⚡ Terus menghasilkan imibuzo eminingi ye-ChatGPT ngokwesizulu
220220
// @author Adam Lui
221221
// @namespace https://github.com/adamlui
222-
// @version 2025.2.28.1
222+
// @version 2025.2.28.2
223223
// @license MIT
224224
// @icon https://assets.chatgptautocontinue.com/images/icons/continue-symbol/circled/with-robot/icon48.png?v=8b39fb4
225225
// @icon64 https://assets.chatgptautocontinue.com/images/icons/continue-symbol/circled/with-robot/icon64.png?v=8b39fb4
@@ -498,11 +498,13 @@
498498
// Run MAIN routine
499499

500500
// Init EXTENSION ACTIVE state
501-
env.extensionActive = false
502-
postMessage({ action: 'getExtensionInfo', source: `${app.slug}.user.js` })
501+
postMessage({ action: 'getExtensionInfo', source: `${app.slug}.user.js` }, location.origin)
503502
addEventListener('message', handleMsgResp)
504503
function handleMsgResp(resp) {
505-
const sender = resp.data.source ; env.extensionActive = sender.includes(app.slug) && /extension/i.test(sender) }
504+
if (resp.origin != location.origin) return
505+
const sender = resp.data.source
506+
env.extensionActive = sender.includes(app.slug) && /extension/i.test(sender)
507+
}
506508
await new Promise(resolve => setTimeout(resolve, 100)) // wait for extension response
507509
removeEventListener('message', handleMsgResp)
508510

0 commit comments

Comments
 (0)