Jump to content

Recommended Posts

Safari Assistant

 

All-in-one workflow for Safari.

 

  • Filter tabs, bookmarks (and bookmarklets), reading list and history.
  • Several built-in actions. Easily add your own via scripts.
  • Assign your favourite actions (or bookmarklets) to alternate actions (i.e. ⌥↩, ^↩ etc.).


Download from GitHub releases. Source code.

 

Built-in tab actions:

  • Close Tab
  • Close Window
  • Close Other Tabs
  • Close Tabs to Left
  • Close Tabs to Right


Built-in URL actions (also work on tabs):

  • Open in Private Window
  • Open in Default Browser
  • Open in Chrome
  • Open in Firefox

 

Usage

 

  • bh [<query>] — Search and open/action bookmarks and recent history.
    • — Open item in browser.
    • ⌘↩ — Show URL actions for selected item.
    • ⌥↩ — Run custom action on selected item.
    • ^↩ — Run custom action on selected item.
    • fn↩ — Run custom action on selected item.
    • ⇧↩ — Run custom action on selected item.
  • bm [<query>] — Search and open/action bookmarks.
    • , ⌘↩, ⌥↩, ^↩, fn↩, ⇧↩ — As above.
  • bml [<query>] — Search and run bookmarklets.
    • — Run bookmarklet in active tab.
  • bmf [<query>] — Search bookmark folders.
    • — Enter folder/open bookmark.
    • ⌘↩ — Open all bookmarks in folder/show URL actions for bookmark.
  • hi [<query>] — Search and open/action history entries.
    • , ⌘↩, ⌥↩, ^↩, fn↩, ⇧↩ — As above.
  • rl [<query>] — Search and open/action Reading List entries.
    • , ⌘↩, ⌥↩, ^↩, fn↩, ⇧↩ — As above.
  • tab [<query>] — Search and activate/action Safari tabs.
    • — Activate the selected tab.
    • ⌘↩, ⌥↩, ^↩, fn↩, ⇧↩ — As above.

 

See the README on GitHub for full usage instructions.

Link to comment
10 hours ago, vitor said:

Done in a flash;

 

Show off :P

 

10 hours ago, vitor said:

haven’t checked for consistency with the other icons

 

There is no consistency anyway. Like I said, I can’t icon. I just pick some mostly random colours, then try to find something vaguely appropriate on my icon generator.

 

Will release a new version with your Jobsian specs later or tomorrow. Thanks very much!

Link to comment
49 minutes ago, deanishe said:

 

What do you mean exactly? Your iPhone/iPad history is already included if you have Safari syncing turned on.

Yes, I found this Workflow can show me the (recent) History of Safari in my iPhone&iPad via inputting some key-word(s) to dig it out

 

Thank you.

Link to comment
  • 3 weeks later...

Since Safari Assist has read only access to things and as @deanishe said, you can't immediately delete a bookmark URL from Alfred itself.

 

I made an Applescript that does it for me. Given a URL, it will search the URL in your bookmarks and then you can delete it from there. I can't find a faster / better way to do this but it is better than nothing.

 

Here is the Applescript. I guess @deanishe won't add this as this script relies on macOS being in English and also it is not one of the most smooth running things out there but it works.

 

-- `menu_click`, by Jacob Rus, September 2006
-- 
-- Accepts a list of form: `{"Finder", "View", "Arrange By", "Date"}`
-- Execute the specified menu item.  In this case, assuming the Finder 
-- is the active application, arranging the frontmost folder by date.

on menu_click(mList)
	local appName, topMenu, r
	
	-- Validate our input
	if mList's length < 3 then error "Menu list is not long enough"
	
	-- Set these variables for clarity and brevity later on
	set {appName, topMenu} to (items 1 through 2 of mList)
	set r to (items 3 through (mList's length) of mList)
	
	-- This overly-long line calls the menu_recurse function with
	-- two arguments: r, and a reference to the top-level menu
	tell application "System Events" to my menu_click_recurse(r, ((process appName)'s ¬
		(menu bar 1)'s (menu bar item topMenu)'s (menu topMenu)))
end menu_click

on menu_click_recurse(mList, parentObject)
	local f, r
	
	-- `f` = first item, `r` = rest of items
	set f to item 1 of mList
	if mList's length > 1 then set r to (items 2 through (mList's length) of mList)
	
	-- either actually click the menu item, or recurse again
	tell application "System Events"
		if mList's length is 1 then
			click parentObject's menu item f
		else
			my menu_click_recurse(r, (parentObject's (menu item f)'s (menu f)))
		end if
	end tell
end menu_click_recurse


on run argv
	set the clipboard to (item 1 of argv)
	tell application "Safari" to activate
	
	tell application "System Events"
		keystroke "t" using command down
		delay 1
	end
	
	menu_click({"Safari", "Bookmarks", "Edit Bookmarks"})
	
	tell application "System Events"
		keystroke "f" using command down
		delay 1
		keystroke "v" using command down
	end tell
end run

 

Edited by nikivi
Link to comment

Oops. I actually checked the log too but it said a similar thing. Going to make an Anki card for this screenshot thing.

 

Strangely though, this started working for me both in bookmarks and current safari tabs. 

 

Also changed the delay to 1 everywhere as it failed on some cases but worked on others, it still fails sometimes, perhaps should push the delay even higher. I don't quite get though why it works sometimes and doesn't work at others. The delay is the same and it should take the same time every time.

Edited by nikivi
Link to comment

Here's a log of it running:

 

[2017-11-27 02:23:51][utility.debug] Processing output of 'action.script' with arg ''
[2017-11-27 02:23:51][utility.debug] Processing output of 'utility.filter' with arg ''
[2017-11-27 02:23:51][utility.debug] Processing output of 'utility.filter' with arg ''
[2017-11-27 02:23:51][utility.debug] Processing output of 'utility.filter' with arg ''
[2017-11-27 02:23:51][utility.debug] Processing output of 'utility.filter' with arg ''
[2017-11-27 02:23:51][utility.debug] Processing output of 'utility.filter' with arg ''
[2017-11-27 02:23:54][ERROR: action.script] ?
02:23:51 workflow.go:614: ------- Safari Assistant/0.4.3 (AwGo/0.13) -------
02:23:51 alsf.go:274: URL=https://2io90-11.slack.com/messages/C81UCU11R/, action=Search in Bookmarks
02:23:51 actions.go:338: URL Script `Open in Chrome` from `/Users/nikivi/alfred/Alfred.alfredpreferences/workflows/user.workflow.1F723891-DB61-446E-9EEB-D81C7AE43226/scripts/url/Open in Chrome.sh`
02:23:51 actions.go:338: URL Script `Open in Firefox` from `/Users/nikivi/alfred/Alfred.alfredpreferences/workflows/user.workflow.1F723891-DB61-446E-9EEB-D81C7AE43226/scripts/url/Open in Firefox.sh`
02:23:51 actions.go:338: URL Script `Open in Private Window` from `/Users/nikivi/alfred/Alfred.alfredpreferences/workflows/user.workflow.1F723891-DB61-446E-9EEB-D81C7AE43226/scripts/url/Open in Private Window.js`
02:23:51 actions.go:338: URL Script `Search in Bookmarks` from `/Users/nikivi/Library/Application Support/Alfred 3/Workflow Data/net.deanishe.alfred.safari/scripts/url/Search in Bookmarks.applescript`
02:23:51 actions.go:292: &{/usr/bin/osascript [/usr/bin/osascript /Users/nikivi/Library/Application Support/Alfred 3/Workflow Data/net.deanishe.alfred.safari/scripts/url/Search in Bookmarks.applescript https://2io90-11.slack.com/messages/C81UCU11R/] []  <nil> <nil> <nil> [] <nil> <nil> <nil> <nil> <nil> false [] [] [] [] <nil> <nil>}
02:23:53 update.go:171: 2h23m since last check for update
02:23:53 workflow.go:790: ---------------------- 2.4s ----------------------
[2017-11-27 02:23:54][action.script] Processing output of 'output.notification' with arg ''

 

Link to comment

I fixed it I think. Had to add another delay after menu_call().

 

Here is the full code:

 

-- `menu_click`, by Jacob Rus, September 2006
-- 
-- Accepts a list of form: `{"Finder", "View", "Arrange By", "Date"}`
-- Execute the specified menu item.  In this case, assuming the Finder 
-- is the active application, arranging the frontmost folder by date.

on menu_click(mList)
	local appName, topMenu, r
	
	-- Validate our input
	if mList's length < 3 then error "Menu list is not long enough"
	
	-- Set these variables for clarity and brevity later on
	set {appName, topMenu} to (items 1 through 2 of mList)
	set r to (items 3 through (mList's length) of mList)
	
	-- This overly-long line calls the menu_recurse function with
	-- two arguments: r, and a reference to the top-level menu
	tell application "System Events" to my menu_click_recurse(r, ((process appName)'s ¬
		(menu bar 1)'s (menu bar item topMenu)'s (menu topMenu)))
end menu_click

on menu_click_recurse(mList, parentObject)
	local f, r
	
	-- `f` = first item, `r` = rest of items
	set f to item 1 of mList
	if mList's length > 1 then set r to (items 2 through (mList's length) of mList)
	
	-- either actually click the menu item, or recurse again
	tell application "System Events"
		if mList's length is 1 then
			click parentObject's menu item f
		else
			my menu_click_recurse(r, (parentObject's (menu item f)'s (menu f)))
		end if
	end tell
end menu_click_recurse


on run argv
	set the clipboard to (item 1 of argv)
	tell application "Safari" to activate
	
	tell application "System Events"
		keystroke "t" using command down
		delay 0.5
	end
	
	menu_click({"Safari", "Bookmarks", "Edit Bookmarks"})
	delay 0.5
	
	tell application "System Events"
		keystroke "f" using command down
		delay 0.5
		keystroke "v" using command down
	end tell
end run

 

I can't replicate the previous error I had. If I will get it again, I will post the log. I am open to feedback on this 'script'. It seems to work for my use case. ? 

Edited by nikivi
Link to comment

Regarding the previous error: Are you calling the tab actions external trigger directly, rather than through the workflow?

 

That would explain the error: the calling action sets the URL that was missing. If you’re calling it directly, none of the required variables will be set. 

Link to comment

The tab actions are called through the workflow I believe. I just call the script filters with the shell script below:

osascript -e '
tell application "Alfred 3" to run trigger "safari tabs" in workflow "net.deanishe.alfred.safari" with argument ""
'

 

Edited by nikivi
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...