Comments (9)
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
from active-win.
Thanks for pointing me in the right direction!
I ended up using node applescript
which works perfectly. I am pasting my apple scripts incase someone else is looking for the same thing.
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`,
}
from active-win.
@uffou Did you solve your your problem ? I also need to detect URL of active window in Windows.
If you have a solution, please share it ?
from active-win.
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...)
from active-win.
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.
from active-win.
This is now available in the latest version: https://github.com/sindresorhus/active-win/releases/tag/v6.1.0
from active-win.
Any solution for getting URL of current browser tab in windows ???
from active-win.
Following up on windows thanks!
from active-win.
Can anyone say how can I get URL for active window in "Windows"?
from active-win.
Related Issues (20)
- Question about Firefox HOT 1
- On windows URL property is not showing HOT 1
- `getOpenWindows` does not return all windows HOT 6
- UnhandledPromiseRejectionWarning: SyntaxError: Unexpected number in JSON at position 10 HOT 8
- `getOpenWindows` does not return fullscreen windows HOT 2
- Error Running Simple Example on Electron Forge HOT 4
- activeWindow.getOpenWindows() z-index HOT 1
- Incorrect Y bounds with second monitor case HOT 2
- active-win not recording .flatpak apps in ubuntu
- Build and release process question HOT 3
- I am getting this error after I Forked repo and installed in my electron app HOT 2
- active-win 8.1.0 reports empty title strings on Adobe products on macOS despite correct permissions HOT 2
- UnhandledPromiseRejectionWarning: SyntaxError: Bad escaped character in JSON at position 12
- getOpenWindows() -> parseMac() -> JSON.parse issues
- I am not able to capture URLs in Firefox browser HOT 1
- Active win package not working in MAC ventura 13.6.2 and fedora 39 with x11.
- Getting UNCAUGHT EXCEPTION while doing npm run build:windows
- crashes on latest version of ubuntu and fedora( linux based systems)
- App keeps askig for accessibilityPermission even if accessibilityPermission: false HOT 8
- Sometimes randomly activeWindow return undefined on Ubuntu 22.04.4 LTS
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from active-win.