Converting Chrome - Safari extension

Hello,

I am a new developer so sorry if the answer is obvious and I’m somehow missing it.

The current script I have in index.html is this:

    document.getElementById('someID').addEventListener('click', async () => {        chrome.tabs.query({ currentWindow: true, active: true }, (tabs) => {            chrome.tabs.sendMessage(tabs[0].id, { key: 'value' })        })

And the code I have in script.js looks like:

chrome.runtime.onMessage.addListener((message) => {    message.key && script[message.key].run(message.args);});

This works perfectly fine in Chrome, but what commands would I use to do the same thing in Safari?

Any assistance would be greatly appreciated,

Thank you

Answered by Engineer in 701478022

You should be able to use the Safari Web Extension converter (see https://developer.apple.com/documentation/safariservices/safari_web_extensions/converting_a_web_extension_for_safari?language=objc), and this code should all work fine in Safari.

Hope this helps!

Accepted Answer

You should be able to use the Safari Web Extension converter (see https://developer.apple.com/documentation/safariservices/safari_web_extensions/converting_a_web_extension_for_safari?language=objc), and this code should all work fine in Safari.

Hope this helps!

Converting Chrome - Safari extension
 
 
Q