Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any way to improve list efficiency? #6

Open
AnthoPakPak opened this issue Jan 14, 2020 · 13 comments
Open

Any way to improve list efficiency? #6

AnthoPakPak opened this issue Jan 14, 2020 · 13 comments

Comments

@AnthoPakPak
Copy link
Contributor

Hi!

First, thanks a lot for this awesome Alfred workflow, I really enjoy using it! 👌
The only thing I struggle with is the fact that listing the tabs is too slow. I have hundreds of opened tabs and it takes several seconds before showing the tabs list (sometimes up to 10seconds). So unfortunately, I lose a lot of time waiting the loading…

I've looked at the code, but from what I see the logic is nice, and I don't see a straightforward way to improve the efficiency. I guess the slow part is the looping through windows/tabs, but I can't find a better way to do it.

Do you have any advice, idea, which could lead to improved efficiency?

@mschmidtkorth
Copy link

I've had the same issue. Code looks nice, but performance for a heavy tab user is too slow - around 7-10 seconds for me to wait for results, so I am much faster to open Chrome myself and use an extension to search for my tab. As my main intent was opening a specific tab, I've automated this extension via Alfred and osascript.

@AnthoPakPak
Copy link
Contributor Author

@mschmidtkorth Oh yeah, I didn't thought of doing it! I would be really interested to know how you did this! If you don't mind, could you please tell me the extension used, and maybe share the script? Would be awesome!

@mschmidtkorth
Copy link

@AnthoPakPak Sure! The Chrome extension is Tab Ahead, which has a keycombo of Opt+T. The Alfred Workflow (as attached) simply opens Chrome, presses Opt+T, and then pastes "mail.google.com" + Enter to open my Gmail tab. You could send a dynamic string instead if you want to use this as a way to search for tabs. The disadvantage obviously is that you will have no list of tabs in Alfred.

Gmail-Opener.alfredworkflow.zip

@AnthoPakPak
Copy link
Contributor Author

@mschmidtkorth Thanks a lot! I'll take a look at it. Indeed, not having the list in Alfred could be a major drawback… I think one major improvement to chrome-control would have been to cache tabs, I'll see if if I can do something like this someday. Like storing opened tabs in a file every minute, so that Alfred will show them instantly (while still refreshing the list to make sure opened tabs less than a minute ago are still showed).
I was thinking of listening for new Chrome tabs event, but from what I've seen it can only be done with a Chrome extension. And unfortunately, Chrome extensions can't write on disk, so it would not be able to store tabs list… So currently I don't have a better idea than automatic caching every minute 😕

@mschmidtkorth
Copy link

@AnthoPakPak Yes, it is quite cumbersome. One option would be:

  • Use Chromagnon to parse the "Current Tabs" file that chrome stores: git checkout SNSS, python chromagnonTab.py "~/Library/Application Support/Google/Chrome/Default/Current Tabs"
  • Extract the tab Ids/and or URLs and allow Alfred to search through these. Not sure if the Ids match the Ids returned via osascript; maybe the only option is to paste it into the Chrome Extension

@AnthoPakPak
Copy link
Contributor Author

@mschmidtkorth Wow this tool seems awesome! I've managed to get it working, thanks for the instructions! The only issue is that Current Tabs doesn't seem to include all opened tabs… In my case it is missing a lot of tabs. Even the currently focused tab isn't always present in the results. I currently haven't found any other file that could contain reliable tabs information...

@AnthoPakPak
Copy link
Contributor Author

@mschmidtkorth BOOM! After searching hours into Chromagnon and SNSS (and even other ways), I've came back to initial script, to see if I can improve the JXA. And I've ended up finding out a way to improve drastically the performances! I've just made a pull request (#7) with the required changes. The loading is now blazing fast! You should be able to change the code yourself to try it out now. I'm using it for a few hours now and it is sooooo good! 🤙

@mschmidtkorth
Copy link

@AnthoPakPak Nice!! It is MUCH faster now, great! However, for me this has removed the ability to search for URLs instead of tab names (example: Google Mail's tab title changes if someone sends you a chat message, then I can no longer switch). Was this intended?

@AnthoPakPak
Copy link
Contributor Author

@mschmidtkorth Hi! Are you sure? I've noticed this also but when trying the initial version it was the same results (some are missing…). But I also wanted to improve this, I'll take a look!

@mschmidtkorth
Copy link

mschmidtkorth commented Feb 17, 2020

@AnthoPakPak Actually I'm not sure whether this was part of the original implementation. Might just have been wishful thinking :-)

Edit: See attached for a version with fuzzy matching on title and subtitle.
Chrome Control.alfredworkflow.zip

@AnthoPakPak
Copy link
Contributor Author

@mschmidtkorth Funnily enough I'm only seeing your edit now 😅 I had meanwhile made the changes on my side so that the search works in title and subtitle, but I'm glad to found your fuzzy version! I've just integrated the required changes in my workflow and it works perfectly! 👌
So, a bit late to the party, but thanks a lot for sharing this fuzzy version ✌️

@luckman212
Copy link

luckman212 commented Dec 17, 2020

@AnthoPakPak I played around with this and the matching wasn't working great for URLs that start with www because of the way Alfred's anchoring works. I didn't try adding @deanishe 's fuzzy into the mix because honestly that was overkill for my use case.

I forked and uploaded a version that extracts the base URL and breaks it up into words so e.g. searching npm will match on https://www.npmjs.org as well as https://blog.npmjs.org. In case anyone wants to try...

luckman212/chrome-control

@unknownbreaker
Copy link

unknownbreaker commented Aug 26, 2021

Comments

@mschmidtkorth implementation is great. Indexing is super fast, and my tab searches are reliable. Oddly, I think dashes were not working so well in the original version? One of my tab titles had a dash in it, and as soon as I typed the dash, I lost all search results. But this one fixes it.

However, I think the fuzzy search is a bit finicky. I'm not sure why this is my top search result over the second result.
image

Request

This issue alone now has two separate chrome-control solutions floating around. Anyway these can be merged into the original chrome-control? It'll be less confusing and people who don't read GitHub issues will also benefit from these improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants