bo9 Posted February 9, 2022 Share Posted February 9, 2022 Is there a way to input settings for my workflow that would allow a search query url to open in a “new browser” window. At this time, I am able to open it in a "new tab", but it would be much better for my result to show up in a new window. Thank you for any help. FYI, I am a newbie, so the layperson replies would be much appreciated. Link to comment
vitor Posted February 9, 2022 Share Posted February 9, 2022 Welcome @bo9, It depends entirely on your browser. You need to ask it specifically to open a new window with the search. Here’s an example which searches Google with Safari. If you need something different, please specify throughly what you want to accomplish and which browser you’re using. Quick note: if it’s Firefox, no luck. Link to comment
bo9 Posted February 10, 2022 Author Share Posted February 10, 2022 Thank you Vítor for the help. I use both Safari and Chrome. So when we complete a search query through the Alfred search bar, say for a YouTube video, open the Alfred bar, then type yt (space) and then the search words, then when I hit enter, it opens the YouTube video search in a new tab, in the same browser window, however I’d like for that search result to open up in a new tab but also in a new browser window. Link to comment
vitor Posted February 10, 2022 Share Posted February 10, 2022 The first thing to understand is that you can’t do this with the default custom searches, you must recreate the ones you want in a Workflow because you’ll need to run code to open the new browser window. 14 hours ago, bo9 said: I’d like for that search result to open up in a new tab but also in a new browser window. So you want it twice with one run? Link to comment
bo9 Posted February 10, 2022 Author Share Posted February 10, 2022 Quote Yes. I have the workflows created and at this time they open the search results with the correct URL, but what do I need to add to the workflow to have them open in a "new browser window" rather just a "new tab" Link to comment
vitor Posted February 10, 2022 Share Posted February 10, 2022 17 hours ago, bo9 said: I use both Safari and Chrome. This makes the code more complex, because in addition to asking the browser to open the window now it also needs to know which browser to do it for. Make a Run Script Action with Language /usr/bin/osascript (JavaScript), and in Script, paste: const frontmost_app_name = Application('System Events').applicationProcesses.where({ frontmost: true }).name()[0] const frontmost_app = Application(frontmost_app_name) frontmost_app.includeStandardAdditions = true const chromium_variants = ['Google Chrome', 'Chromium', 'Opera', 'Vivaldi', 'Brave Browser', 'Microsoft Edge'] const webkit_variants = ['Safari', 'Webkit'] if (chromium_variants.some(app_name => frontmost_app_name.startsWith(app_name))) { frontmost_app.Window().make() } else if (webkit_variants.some(app_name => frontmost_app_name.startsWith(app_name))) { frontmost_app.Document().make() } else { throw new Error('You need a supported browser as your frontmost app') } function run(argv) { frontmost_app.openLocation(argv[0]) } That takes in whatever URL you send from the previous object and opens it in a new tab in the frontmost browser app, whatever that is (again, not Firefox). If you want it to open in a new tab and in a new window, use this instead: function run(argv) { const frontmost_app_name = Application('System Events').applicationProcesses.where({ frontmost: true }).name()[0] const frontmost_app = Application(frontmost_app_name) frontmost_app.includeStandardAdditions = true const chromium_variants = ['Google Chrome', 'Chromium', 'Opera', 'Vivaldi', 'Brave Browser', 'Microsoft Edge'] const webkit_variants = ['Safari', 'Webkit'] if (chromium_variants.some(app_name => frontmost_app_name.startsWith(app_name))) { frontmost_app.openLocation(argv[0]) frontmost_app.Window().make() } else if (webkit_variants.some(app_name => frontmost_app_name.startsWith(app_name))) { frontmost_app.openLocation(argv[0]) frontmost_app.Document().make() } else { throw new Error('You need a supported browser as your frontmost app') } frontmost_app.openLocation(argv[0]) } Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now