Getting the same thing in the latest Safari.
Post
Replies
Boosts
Views
Activity
The astonishing thing is that people are so stupid they pay lots to use Apple devices in the first place... I guess the answer is to find a Chinese person who doesn't use Apple and then get them to sign up and give you their account.
Ok, not sure what was happening there - I must have been holding it wrong... Turns out that example does work when you add host_permissions, at least when they are specified correctly! :-).
My bad... sorry for the noise!
This is working for me with 16.4.1, at least when I run it with world: "MAIN".
Here is my working (chromium/safari cross-platform) code:
const stuff = await chrome.scripting.executeScript({
target: { tabId: tab.id },
func: (lang) => {
const subs = window.mysubs[lang];
const language = window.mylanguage;
return {
subs,
language,
};
},
args: [myLang],
world: "MAIN",
});
/* safari doesn't return InjectionResults, it returns the values directly;*/
myData = stuff[0]?.result || stuff[0];
Um, so https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/scripting/RegisteredContentScript is wrong? From my testing it doesn't appear to be wrong... Maybe there are cases when it does work for Chrome but doesn't work for Safari? Maybe it only works on iOS (I only tested on the desktop so far...)?
This is finally fixed! https://webkit.org/blog/13966/webkit-features-in-safari-16-4/#safari-web-extensions
And I even tested, and it even works :). I was very much not looking forward to any of these hacks (using "scripts" instead of "service_worker", and no type="module", etc) after starting to migrate my extension from Chrome and it turns out (almost) all of the bugs I was facing have been fixed in 16.4! Note to self - make sure your system is up-to-date before starting in-depth debugging...