I am working on a Safari Extension to obtain the url from the address bar and then send it to a mysql database. This in turn is picked by a website that displays the database content.
The part where I am stuck at is how do I obtain the URL from the address bar from within a Safari Extension ? I am using php to then update the database with the url once I get it. Thanks in advance.
This solved my issue.
var myurl = safari.application.activeBrowserWindow.activeTab.url;
From an extension's global page or a popover, the url
property of a tab object is the closest you can get to the contents of the tab's address bar. For example,
safari.application.activeBrowser.activeTab.url
It's not exactly what you want because it doesn't reflect a value that may have been typed into the address bar but not yet entered.
If you want to intercept the entered URL before Safari navigates to it, you can listen for the beforeNavigate event on the tab, window, or application. See the documentation.