I am trying to get the current url from injected script but it seems impossible because of the permission. From the official document, I got:
Injected scripts cannot access the SafariApplication or SafariExtension classes.
Is there any solution or w/a? Thanks.
Use
window.location.href
to get the URL of the page the script is injected into.Scripts are injected into each iframe as well as the main page, so you might want to use a check like
if (window == window.top)
to if you are only interested in the main page.