Current URL in Safari Extension

2019-06-16 19:02发布

问题:

safari.application.activeBrowserWindow.activeTab.url is always undefined.

Any idea why this might be?

回答1:

My impression is that this happens when the loaded page is not “allowed” in the Extension Website Access section of the extension’s configuration.

Only the websites you choose have web content injected into them, and only those websites can be manipulated using the tab object’s properties, such as title and url.

Also, it seems that the Whitelist and Blacklist settings are applied “on top of” whatever is allowed by Extension Website Access.

First, access is limited by the Extension Website Access settings, then the whitelist and blacklist are applied.