JA_UK Posted August 2, 2021 Share Posted August 2, 2021 Hi all, I'm new (8 days in) to Alfred and have been checking out the new Universal Actions feature which has gone live in v.4.5 today. I would like to be able to perform a Google search of the content of a particular website and wondered if it's possible using Alfred...and if so, how? Whilst browing a website I'd like to be able to: 1) Highlight the URL in the address bar of my browser, 2) Use Alfred to extract & store the 'main' URL of the website (ie - nothing after the first slash following the domain name) - call this VARIABLEA, 3) Type the thing that I want Google to search for on the site in question - call this VARIABLEB, 4) Have Alfred formulate a search along the lines of "site:VARIABLEA VARIABLEB", 5) Have Alfred pass that to Google to do the search (presumably in a new browser tab). I know this is possible through Google (when not using Alfred) by typing "site:abc123.com searchquery" in the search box of a browser. I don't know how to start putting this together in Alfred. I imagine it's fairly simple in the grand scheme of things but would very much appreciate some help / guidance to get me started. Thank you! Link to comment
rknightuk Posted August 2, 2021 Share Posted August 2, 2021 Here you go: https://github.com/rknightuk/alfred-workflows/tree/main/workflows/search-this-site Does exactly what you want (I think): 1. Select the URL 2. Choose "Search This Site" 3. Type your query and enter 4. Opens in default browser If you open up the workflow in Alfred you'll see, as you said, that there's actually not a lot to it. I used a bash script I grabbed from elsewhere to extract the domain, then a keyword step to get input, then the "Default web search" step. I haven't tested this much so let me know if there's any issues. JA_UK and deanishe 2 Link to comment
deanishe Posted August 2, 2021 Share Posted August 2, 2021 This workflow can open a site-specific Google search on the domain of the selected URL. In addition to a Universal Action, I've added a Hotkey to trigger the workflow that can grab the URL of your current browser tab, to save you having to select the URL. You should be able to figure out how it all works. rknightuk and JA_UK 2 Link to comment
rknightuk Posted August 2, 2021 Share Posted August 2, 2021 @JA_UKYou should definitely use the version @deanishe made instead of mine. It's a way better example of how to organise an Alfred workflow. They do the same thing, but one is clearly superior. Link to comment
JA_UK Posted August 3, 2021 Author Share Posted August 3, 2021 Thanks very much both @rknightuk and @deanishe for your help and your speedy replies! @deanishe I have been trying your workflow and it works great as a Universal Action once I have selected the URL in the address bar. Just to be a pain I am a user of Firefox, and after choosing a Hotkey it seems as if the workflow is unable to get the URL of the frontmost browser tab. Is there anything I can tweak to enable this to work with Firefox, or is it a non-starter? I'm aware that Firefox lacks some public API's which means it can't do some things with Alfred that other browsers can. Thanks again! JJJJ 1 Link to comment
deanishe Posted August 3, 2021 Share Posted August 3, 2021 8 minutes ago, JA_UK said: Is there anything I can tweak to enable this to work with Firefox, or is it a non-starter? Not as-is because Firefox is stupid. But it could be made to work in a couple of ways if you have my Firefox workflow. Link to comment
JJJJ Posted August 3, 2021 Share Posted August 3, 2021 (edited) 2 hours ago, deanishe said: Not as-is because Firefox is stupid. But it could be made to work in a couple of ways if you have my Firefox workflow. Hi, I have your firefox workflow and would like to know those ways to make this one work with firefox. Edited August 3, 2021 by JJJJ Link to comment
deanishe Posted August 3, 2021 Share Posted August 3, 2021 1 hour ago, JJJJ said: Hi, I have your firefox workflow and would like to know those ways to make this one work with firefox. First download and install the updated version of this workflow (I've added an External Trigger). Then open the Firefox workflow’s script directory (ffass > Open Scripts Directory) and use Script Editor to save this AppleScript in it (call it “Search Site” or similar): on run (argv) set _url to first item of argv tell application id "com.runningwithcrayons.Alfred" to run trigger "search-site" in workflow "net.deanishe.alfred.demo.universal-google" with argument _url end run Now you should have a new "Search Site" action available in the tab actions and bookmark/history search in the Firefox workflow. You can assign it a Hotkey by adding one to the workflow similar to the example ones. Jan Peeters and JJJJ 1 1 Link to comment
JJJJ Posted August 4, 2021 Share Posted August 4, 2021 10 hours ago, deanishe said: First download and install the updated version of this workflow (I've added an External Trigger). Then open the Firefox workflow’s script directory (ffass > Open Scripts Directory) and use Script Editor to save this AppleScript in it (call it “Search Site” or similar): on run (argv) set _url to first item of argv tell application id "com.runningwithcrayons.Alfred" to run trigger "search-site" in workflow "net.deanishe.alfred.demo.universal-google" with argument _url end run Now you should have a new "Search Site" action available in the tab actions and bookmark/history search in the Firefox workflow. You can assign it a Hotkey by adding one to the workflow similar to the example ones. Thanks a lot, works exactly as you described! 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