-
-
Notifications
You must be signed in to change notification settings - Fork 172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get url from browser #20
Comments
That is app specific. On macOS, you could use AppleScript to get. On other systems, I have no idea. https://stackoverflow.com/questions/2483033/get-the-url-of-the-frontmost-tab-from-chrome-on-os-x |
Thanks for pointing me in the right direction! I ended up using node applescript safari and chrome work perfectly. Unfortunately, Firefox does not support AppleScript and the way to obtain the URL is hacky and unusable in production. Also, I still have no clue how to get the URLs on linux and windows. const scripts = {
'itunes': `tell application "iTunes" to get {name, artist, album} of current track`,
'spotify': `tell application "Spotify" to get {name, artist, album} of current track`,
'chrome': `tell application "Google Chrome" to get URL of active tab of front window as string`,
'vivaldi': `tell application "Vivaldi" to return URL of active tab of front window`,
'safari': `tell application "Safari" to return URL of front document as string`,
'firefox': `tell application "Firefox" to activate
tell application "System Events"
keystroke "l" using command down
keystroke "c" using command down
end tell
delay 0.5
return the clipboard`,
} |
@uffou Did you solve your your problem ? I also need to detect URL of active window in Windows. |
There isn't a standard way to get the URL from a browser that works in all operating systems. There are some possible "hacks" and scripts for macOS only. Probably, the best way to solve it, while trying to be as "cross-platform" as possible, would be with a browser extension. That extension could talk to your Electron app via a local Electron (Node.js) server. Or it could talk directly to your backend server. An extension is just JS. And I understand Firefox and Edge were about to support the same extension formats and APIs as Chrome, so you would probably be able to have only one code base. But I'm not aware of how that went. Also, I understand that in Windows you can set a key in the registry that tells Chrome to install an extension the next time it opens, or something similar. I'm not sure how it works for macOS or Ubuntu (although Ubuntu is my main OS...) |
Ok, then i will try to use OCR solution. We can get top side screenshot of active window and try to detect characters from image, i think it will be easiest way to solve my problem. I only need website domain name. |
This is now available in the latest version: https://github.com/sindresorhus/active-win/releases/tag/v6.1.0 |
Any solution for getting URL of current browser tab in windows ??? |
Following up on windows thanks! |
Can anyone say how can I get URL for active window in "Windows"? |
Any way we can get URL from a browser? At the moment it is getting the title of a webpage pretty accurately but I need the URL for my purposes.
The text was updated successfully, but these errors were encountered: