Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send message not working from custom html page. #72

Open
coure2011 opened this issue Apr 9, 2022 · 1 comment
Open

Send message not working from custom html page. #72

coure2011 opened this issue Apr 9, 2022 · 1 comment

Comments

@coure2011
Copy link

coure2011 commented Apr 9, 2022

I have just cloned the latest vitesse-webext project and added the following code, which is sending message correctly.

// src/options/Options.vue
<script setup lang="ts">
import { sendMessage, onMessage } from 'webext-bridge'

import { storageDemo } from '~/logic/storage'

const logIt = async() => {
  console.log('hello there')
  const dd = await sendMessage('get-current-tab', {}, 'background')
  console.log(dd)
}
</script>

It logged both console messages when Log it button is clicked.

Now I have another page which I can access at url: chrome-extension://[id-of-extension]/test/index.html, which contains the same code to send message but its failing silently.

// src/test/Options.vue 
<script setup lang="ts">
import { sendMessage, onMessage } from 'webext-bridge'

import { storageDemo } from '~/logic/storage'

const logIt = async() => {
  console.log('hello there')
  const dd = await sendMessage('get-current-tab', {}, 'background')
  console.log(dd)
}
</script>

the complete code can be found at https://stackblitz.com/edit/vitejs-vite-ngk771?file=src%2Ftest%2FOptions.vue&terminal=dev

@tmkx
Copy link
Collaborator

tmkx commented Mar 12, 2024

can u use the latest template and try again? i can't reproduce it. sorry for that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants