Jump to content
ClintonStrong

Search Safari and Chrome Tabs [Updated Feb 8, 2014]

Recommended Posts

This workflow + 1Password are completely awesome.  1Password has these 1 click bookmarks that will jump to a web page and log you in if it's required. I figured out if I gave 1Password and this workflow the same keyword, that they will give me both results in the Alfred list.

 

I tweaked the workflow a little more. Here's what it does now.

 

  • Changed keyword to "go". Just easier for me to type.
  • Changed 1Password keyword to "go". This combines the output of this workflow and 1Password. Check out the screenshot.
  • "go " shows my shortcut app list that I use all the time. Though after combining this workflow with 1Password, it might not be that useful.
  • "go " + [any text] searches all browser tabs plus 1Password for sites that match [any text]. See the screen shot.
  • [Command]+[Enter] runs an applescript to open alfred and type "go "

I'm finding I hardly have to take my fingers off the keyboard. And instead of bookmarks, I'm loading these URLs into 1Password, whether they need UID/Password or not.

 

Link to the workflow. I feel like I've forked your code, but I don't want to share it under a different name and don't want to share my changes under your name. Feel free to include any of my changes into your wordflow.

 

https://dl.dropboxusercontent.com/u/1192535/Go%20to%20browser%20tab.alfredworkflow

 

 

 

Awesome. And no worries about the name/attribution, I'm all for people making changes and making it their own.

 

 

Any answer on this? Thanks?

 

I couldn't reproduce the issue on my end. The only other thing I can think of is to see if your install of Ruby is working correctly. If you open up Terminal and enter this:
 
/usr/bin/ruby -e 'puts RUBY_VERSION'

Does it display "1.8.7"? I suppose it also couldn't hurt to go into Disk Utility and repair your disk permissions, in case something got messed up there. Sorry again for the trouble, this one just has me perplexed at the moment.

Share this post


Link to post

Thanks for continuing work on through Mavericks. I let the workflow be for a week after I updated and it was driving me nuts when I really needed it. Can't live without it now!

Share this post


Link to post

I've noticed that with a huge number of tabs, it sits at "Retrieving tabs..." for quite a while. It would be great if this could be sped up somehow. Is there a Github repo that I might be able to contribute back to if I find the time to improve things?

 

Great workflow!

Edited by cdeszaq

Share this post


Link to post

Great workflow! Very useful when I have 30 odd Safari tabs open, all with different academic articles... This has saved me from clicking through them all! Big up's! 

Share this post


Link to post

Any chance a modifier key could be added to close the selected tab via alfred?

+1 To this as well. That would make this workflow perfect.

Share this post


Link to post

I purchased the power pack to be able to use this workflow. It's great, although a bit slow when many tabs are open (it may take up to 50' for results to open, and that on a fast computer.

I wonder if it would be possible to show website icons on tabs, instead of the Safari or Chrome icon?

Many thanks!

Share this post


Link to post

I purchased the power pack to be able to use this workflow. It's great, although a bit slow when many tabs are open (it may take up to 50' for results to open, and that on a fast computer.

I wonder if it would be possible to show website icons on tabs, instead of the Safari or Chrome icon?

Many thanks!

 

Thanks. Unfortunately, it doesn't look like there's much I can do to speed it up. Most of the time spent is waiting for a call to AppleScript to complete.
 
It is possible to show favicons for websites, but in most cases they just wouldn't look good. Most favicons are small (16x16), so when you display them in Alfred they would look blurry. Another issue is speed. Both Chrome and Safari store favicon data in an SQLite database, but Chrome locks its database while the app is running. If I wanted to access it, I'd have to copy it to some other location on your drive before I could read it, which could potentially be quite slow. I could probably get the favicon data from Safari fairly quickly, but I'd still need to dynamically generate images for each of the icons and store them someone on your drive. I haven't tested the performance on this yet, so I can't say for sure if it'd create a notable slowdown.

Share this post


Link to post

For some reason I'm having issues ... every time I try and search my tabs no results are being populated from Chrome.  I'm running OS X 10.9 with the most recent version of Chrome and I have 20+ tabs.  I've tried forcing an argument in the script filter so that it doesn't search unless I give it something to search for, but it's just defaulting to the basic search options - searching Google, Amazon, or Wikipedia.  Any thoughts?

 

Thanks for your help in advance!

Share this post


Link to post

For some reason I'm having issues ... every time I try and search my tabs no results are being populated from Chrome.  I'm running OS X 10.9 with the most recent version of Chrome and I have 20+ tabs.  I've tried forcing an argument in the script filter so that it doesn't search unless I give it something to search for, but it's just defaulting to the basic search options - searching Google, Amazon, or Wikipedia.  Any thoughts?

 

Thanks for your help in advance!

 

Hm, would you mind checking if any errors are occurring? For the script filter, change the script to the following:
 
ruby filter.rb "{query}" 2> ~/Desktop/errorlog.txt
Run the workflow in Alfred, and check your desktop for a file called errorlog.txt. Let me know if anything's being logged there.

Share this post


Link to post

It did create an errorlog.txt file.  Looks like it's getting errors ... Thoughts?  Thank you thank you

 

/Users/AP/Dropbox/Alfred Sync/Alfred.alfredpreferences/workflows/user.workflow.00AAD8B0-1E92-422F-AB71-9C25FAEA482F/browser_tabs/applescript_utils.rb:30:in `block in osascript': AppleScript error: 2014-02-19 00:06:55.747 osascript[35947:507] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find: (BrowserTabs::AppleScriptUtils::AppleScriptError)
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osascript: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open3.rb:217:in `popen_run'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open3.rb:99:in `popen3'
from /Users/AP/Dropbox/Alfred Sync/Alfred.alfredpreferences/workflows/user.workflow.00AAD8B0-1E92-422F-AB71-9C25FAEA482F/browser_tabs/applescript_utils.rb:25:in `osascript'
from /Users/AP/Dropbox/Alfred Sync/Alfred.alfredpreferences/workflows/user.workflow.00AAD8B0-1E92-422F-AB71-9C25FAEA482F/browser_tabs/applescript_utils.rb:11:in `run'
from /Users/AP/Dropbox/Alfred Sync/Alfred.alfredpreferences/workflows/user.workflow.00AAD8B0-1E92-422F-AB71-9C25FAEA482F/browser_tabs/commands/command.rb:42:in `run'
from /Users/AP/Dropbox/Alfred Sync/Alfred.alfredpreferences/workflows/user.workflow.00AAD8B0-1E92-422F-AB71-9C25FAEA482F/browser_tabs.rb:51:in `run_command'
from /Users/AP/Dropbox/Alfred Sync/Alfred.alfredpreferences/workflows/user.workflow.00AAD8B0-1E92-422F-AB71-9C25FAEA482F/browser_tabs.rb:24:in `tabs'
from filter.rb:7:in `<main>'

Share this post


Link to post

 

It did create an errorlog.txt file.  Looks like it's getting errors ... Thoughts?  Thank you thank you

 

/Users/AP/Dropbox/Alfred Sync/Alfred.alfredpreferences/workflows/user.workflow.00AAD8B0-1E92-422F-AB71-9C25FAEA482F/browser_tabs/applescript_utils.rb:30:in `block in osascript': AppleScript error: 2014-02-19 00:06:55.747 osascript[35947:507] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types:  dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found.  Did find: (BrowserTabs::AppleScriptUtils::AppleScriptError)
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
osascript: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open3.rb:217:in `popen_run'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open3.rb:99:in `popen3'
from /Users/AP/Dropbox/Alfred Sync/Alfred.alfredpreferences/workflows/user.workflow.00AAD8B0-1E92-422F-AB71-9C25FAEA482F/browser_tabs/applescript_utils.rb:25:in `osascript'
from /Users/AP/Dropbox/Alfred Sync/Alfred.alfredpreferences/workflows/user.workflow.00AAD8B0-1E92-422F-AB71-9C25FAEA482F/browser_tabs/applescript_utils.rb:11:in `run'
from /Users/AP/Dropbox/Alfred Sync/Alfred.alfredpreferences/workflows/user.workflow.00AAD8B0-1E92-422F-AB71-9C25FAEA482F/browser_tabs/commands/command.rb:42:in `run'
from /Users/AP/Dropbox/Alfred Sync/Alfred.alfredpreferences/workflows/user.workflow.00AAD8B0-1E92-422F-AB71-9C25FAEA482F/browser_tabs.rb:51:in `run_command'
from /Users/AP/Dropbox/Alfred Sync/Alfred.alfredpreferences/workflows/user.workflow.00AAD8B0-1E92-422F-AB71-9C25FAEA482F/browser_tabs.rb:24:in `tabs'
from filter.rb:7:in `<main>'

 

 

It looks like that's being caused by an out of date scripting addition. Try updating it and let me know if that fixes it. http://helpx.adobe.com/photoshop/kb/unit-type-conversion-error-applescript.html

 

If all goes well and it works, you can go ahead and remove the debugging code:

ruby filter.rb "{query}"

Share this post


Link to post

I tried the solutions listed on the Adobe "Unit type conversion error" support page but nothing seems to help. Here is the error log:

/Users/[username]/Dropbox/Productivity-tools/Alfred.alfredpreferences/workflows/user.workflow.8C375D70-662E-4FC5-8FD8-9BD0F84E547F/browser_tabs/applescript_utils.rb:30:in `block in osascript': AppleScript error: 2014-05-26 21:35:32.757 osascript[741:507] Error loading /Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPScriptingAdditions:  dlopen(/Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPScriptingAdditions, 262): no suitable image found.  Did find: (BrowserTabs::AppleScriptUtils::AppleScriptError)
	/Library/ScriptingAdditions/QXPScriptingAdditions.osax/Contents/MacOS/QXPScriptingAdditions: mach-o, but wrong architecture
osascript: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/QXPScriptingAdditions.osax" declares no loadable handlers.
	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open3.rb:217:in `popen_run'
	from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/open3.rb:99:in `popen3'
	from /Users/gravicle/Dropbox/Productivity-tools/Alfred.alfredpreferences/workflows/user.workflow.8C375D70-662E-4FC5-8FD8-9BD0F84E547F/browser_tabs/applescript_utils.rb:25:in `osascript'
	from /Users/gravicle/Dropbox/Productivity-tools/Alfred.alfredpreferences/workflows/user.workflow.8C375D70-662E-4FC5-8FD8-9BD0F84E547F/browser_tabs/applescript_utils.rb:11:in `run'
	from /Users/gravicle/Dropbox/Productivity-tools/Alfred.alfredpreferences/workflows/user.workflow.8C375D70-662E-4FC5-8FD8-9BD0F84E547F/browser_tabs/commands/command.rb:42:in `run'
	from /Users/gravicle/Dropbox/Productivity-tools/Alfred.alfredpreferences/workflows/user.workflow.8C375D70-662E-4FC5-8FD8-9BD0F84E547F/browser_tabs.rb:51:in `run_command'
	from /Users/gravicle/Dropbox/Productivity-tools/Alfred.alfredpreferences/workflows/user.workflow.8C375D70-662E-4FC5-8FD8-9BD0F84E547F/browser_tabs.rb:24:in `tabs'
	from filter.rb:7:in `<main>'

Share this post


Link to post

EDIT: the OP helped me and it now works as I want. I will post what I changed because I am sure (uhm, I hope) there are humans like me that does not understand coding well.

 

1) to customize icons, modify the filter.rb file where it says def icon_for_tab

2) to display tabs in safari order "remove :uid => tab.url," from filter.rb

 

This is in my opinion the best workflow for tabs and it works well with the "open safari tab in chrome and viceversa", which is useful if you do not use flash or just need chrome sometimes. Download now!

Edited by exalyon

Share this post


Link to post

hi, this is not working for me at all (Mavericks 10.9.4, Safari 7.0.6). I've been looking for something with this functionality for *ages*, so I'd really like to use it.

 

Any chance this will be updated to run correctly, or that you'll post something with step-by-step instructions explaining *exactly* what needs to be changed for which version(s) of Ruby & whatever else needs patching?  

 

I just paid for a powerpack license to be able to use this workflow, and now I'm not sure if it was worth the money. :( 

Share this post


Link to post

hi, this is not working for me at all (Mavericks 10.9.4, Safari 7.0.6). I've been looking for something with this functionality for *ages*, so I'd really like to use it.

 

Any chance this will be updated to run correctly, or that you'll post something with step-by-step instructions explaining *exactly* what needs to be changed for which version(s) of Ruby & whatever else needs patching?  

 

I just paid for a powerpack license to be able to use this workflow, and now I'm not sure if it was worth the money. :(

 

Sorry about that. Could you turn on error reporting and let me know what errors are being logged? You can get there by selecting the workflow and pressing the bug icon in the top right corner.

 

 

image.png

Share this post


Link to post

Hi again, I think I found a bug: if I open a safari tab in chrome and try to kill the tab in safari from your workflow, both tabs are deleted.

This happens if I copy and paste the link and if I use the open-in-chrome workflow.

 

 

 

 

I just paid for a powerpack license to be able to use this workflow, and now I'm not sure if it was worth the money.  :(

It was probably the best choice after buying a mac : )

Share this post


Link to post

Hi again, I think I found a bug: if I open a safari tab in chrome and try to kill the tab in safari from your workflow, both tabs are deleted.

This happens if I copy and paste the link and if I use the open-in-chrome workflow.

 

Oh, right. That happens because the workflow identifies each tab with a URL, but doesn't associate the browser with it. So if you tell it to close a tab, all it knows is that you want to close a particular URL. Alfred used to only be able to copy the "arg" of a result when you hit cmd+c, so while I could have added the browser to the arg, you'd end up copying URLs like "chrome;http://google.com/". I instead opted to only use the URL of the tab as the arg, which unfortunately means you'll have issues like the one you described.

 

I just looked in to it though, and it seems Alfred v2.3 has a fix for this. I'll try to get it updated later today.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...