You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that in the previous resolution of related issues, only the .css file injection path was changed, but not the GM.addStyle API, which has been using tabs.insertCSS() until now.
But since allFrames, frameId is not supported by Safari, in fact we just inject it into the top frame instead of the corresponding sub-frame.
Methods using the <style> element may be blocked by CSP, and in fact there may still be no way to inject into sub-frame in this case.
The best solution at the moment is probably:
If it is top frame, use the tabs.insertCSS() to inject
If it is sub frame, use the <style> element to inject it
If blocked by CSP, fails and logs in console
The .css file and GM.addStyle API should share the same injection path, but the .css feature will be deprecated (#711) in favor of GM.addStyle in the future.
The text was updated successfully, but these errors were encountered:
ACTCD
changed the title
GM.addStyle not injecting into iframesGM.addStyle not injecting into sub-iframes
Nov 16, 2024
According to my testing, cssOrigin, allFrames actually work in the latest Safari (but not sure from which version it is supported, and apparently Apple hasn't updated their documentation).
Where allFrames is supported, we may have a workaround to support injecting sub-frames.
That is, add a random class-name to the root node of sub-frame and append it to the user-style.
In this way, even if we inject the user-style into allFrames, only the corresponding sub-frame will take effect.
Adding a class-name to an element is not subject to CSP rules, so in principle this should be able to inject a specific sub-frame without being affected by the site's CSP rules.
It seems that in the previous resolution of related issues, only the
.css
file injection path was changed, but not theGM.addStyle
API, which has been usingtabs.insertCSS()
until now.But since
allFrames
,frameId
is not supported by Safari, in fact we just inject it into thetop frame
instead of the correspondingsub-frame
.Methods using the
<style>
element may be blocked byCSP
, and in fact there may still be no way to inject intosub-frame
in this case.The best solution at the moment is probably:
If it is
top frame
, use thetabs.insertCSS()
to injectIf it is
sub frame
, use the<style>
element to inject itThe
.css
file andGM.addStyle
API should share the same injection path, but the.css
feature will be deprecated (#711) in favor ofGM.addStyle
in the future.The text was updated successfully, but these errors were encountered: