-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Hi there,
I hope this message finds you well. Again, I wanted to express my gratitude for your work on hammerspoon. It has been a valuable resource for me and probably many others.
I am writing to share some of my modifications I believe could be interesting for others. I have updated the Brave methods to be configurable for different browsers.
Here is how it looks like
-- browser.lua
return function(browserName)
local function open()
hs.application.launchOrFocus(browserName)
end
local function jump(url)
local script = ([[(function() {
var browser = Application('%s');
browser.activate();
for (win of browser.windows()) {
var tabIndex =
win.tabs().findIndex(tab => tab.url().match(/%s/));
if (tabIndex != -1) {
win.activeTabIndex = (tabIndex + 1);
win.index = 1;
}
}
})();
]]):format(browserName, url)
-- print(script)
hs.osascript.javascript(script)
end
return { open = open, jump = jump }
end
And this is how it is used:
Chrome = require("browser")("Google Chrome")
Chrome.jump("localhost:3000")Metadata
Metadata
Assignees
Labels
No labels