fwextensions / QuicKey

Jump between recent tabs in Chrome via keyboard shortcuts or a most recently used (MRU) menu.
https://fwextensions.github.io/QuicKey
214 stars 21 forks source link

[Feature Request] Option To Enable Wildcard Searching Both URL and Title #91

Open megamorphg opened 1 year ago

megamorphg commented 1 year ago

Would really like to have an option to search via both URL and title because my most frequent search is: I want to limit the search results to a specific subdomains with specific title and sometimes write additional strings even after that for more things in the URL (all separated by spaces).

Currently I use Fast Tab Switcher for this functionality and having this feature would totally replace my need to rely on an old legacy add-on for this. ๐Ÿ˜…

fwextensions commented 1 year ago

Sorry for the delay.

I've actually got a branch that supports searching on multiple tokens, separated by spaces. It currently requires all the tokens match on either the title or the URL to get a score. Matching one token on the title and another on the URL would produce a zero score, so it may not exactly match what you're looking for. I was concerned that matching on either title or URL would generate noisy results, but maybe I can try it.

megamorphg commented 1 year ago

Ah so there has to be a partial match on both URL and title? Noisy results would be fine because user could keep typing to filter it down.

fwextensions commented 1 year ago

The rules can be whatever. Right now, all the tokens have to match on a given string (title or URL) to get a score; otherwise it's 0. I've also tried it with allowing one or more token matches to get a non-zero score. The order of the results seems to not be too bad, but you do get a ton of results lower down that you don't see when requiring all the tokens to match.

I can push the branch if you want to try it out.

megamorphg commented 1 year ago

@fwextensions kind of confused if the branch will do what is needed but happy to try it out. Basically I want the URL and title to be searched across (always). Maybe it could be a checkbox in the options?

So if the Title and URL is: FDSA https://asdf.com

And I search for "FDSA asdf"... I'd like the tab to show in the result.

This really helps hone down on specific tabs that share the same tab name or same subdomains.

fwextensions commented 1 year ago

This is the branch I'm working on: https://github.com/fwextensions/QuicKey/tree/feature/2023/spaced-token-search

Usually some part of the domain is also in the title, or the title is in the URL, so I haven't run into many cases where all the tokens didn't match on one or the other strings. But I'd be curious if that's true for your use cases as well.

megamorphg commented 1 year ago

@fwextensions I'm using Firefox, can you advise on how I can make an XPI or something from that fork? Kind of dependent on Releases ๐Ÿ˜…

fwextensions commented 1 year ago

It should run fine in FF now. It's being used by all of 14 people in the store: https://addons.mozilla.org/en-US/firefox/addon/quickey-the-quick-tab-switcher/

You can build that branch by running npm run build, which will output it to the dist directory. Then you can can go to about:debugging in FF to load the temporary add-on from that directory. But it looks like I may need to update this branch to work on FF. I think I'd made those changes awhile back to master but not this branch.

fwextensions commented 1 year ago

Hmm, it looks like I had already rebased on the FF changes, so I'm not sure why it's throwing errors in FF. Need to dig into it.

Seems to be due to chrome.system not being supported in FF. QK now uses that to try to figure out which screen a window is on to better handle scaling. I guess I need to special case FF...

fwextensions commented 1 year ago

Okay, handling FF weirdness and fixing some other things, this branch should work in FF now: https://github.com/fwextensions/QuicKey/tree/feature/2023/spaced-token-search

lmk if you need steps on how to build and load it in FF.

megamorphg commented 1 year ago

lmk if you need steps on how to build and load it in FF.

Yeah, I don't know how to build the XPI.

fwextensions commented 1 year ago

You can download a zip of the built version of that branch from here.

Unzip it somewhere. Then open the URL about:debugging#/runtime/this-firefox in Firefox. Click the Load Temporary Add-on button at the top of the page. Navigate to the unzipped folder and open the manifest.json file in it. That should load this new version of QuicKey. I think it may go away when you close FF, since it's just temporary.

megamorphg commented 1 year ago

@fwextensions Awesome, it works! image Doesn't highlight "issues" in above though for some reason (it should highlight that word in the URL since thats the only place it occurs). Searches fine though.

Have to enable the option of space inserting an actual space for this to work. I did like that ability. Maybe instead of space as a search keyword separator we could have a comma serve as the separator? Nobody needs to search for commas in URL or title anyway. :)

It's cool that it searches across "hidden tabs" in separate Panels, so is Sidebery-friendly.

Alt-tab style functionality is awesome too btw! I can see pinning that to a separate window and easily being able to see what are the most recent tabs. Shortcuts work fine too! Looking forward to the production release. :)

fwextensions commented 1 year ago

Thanks for checking out that build!

Doesn't highlight "issues" in above though for some reason (it should highlight that word in the URL since thats the only place it occurs).

Actually, the full title of this page is [Feature Request] Option To Enable Wildcard Searching Both URL and Title ยท Issue #91 ยท fwextensions/QuicKey, so all the search terms in your query match the title, even if the end is clipped. But only two match in the URL, so that counts as a 0 match and nothing is highlighted in that case.

Have to enable the option of space inserting an actual space for this to work. I did like that ability.

"That ability" meaning pressing space to move the selection down the list? I do, too, and I changed the behavior so that if the query is empty, pressing space moves the selection. If a query has been typed, then the first press of the space bar inserts a space, but if there's already a space character at the end of the query, then pressing space moves the selection.

I think I'll make a further change so that if there's no space at the end of the query, pressing the spacebar inserts a space and moves the selection. That way, the option isn't really necessary. You get the same selection behavior as today, but can also insert spaces to search multiple tokens.

It's cool that it searches across "hidden tabs" in separate Panels, so is Sidebery-friendly.

Not sure what you mean by hidden tabs in separate panels. I don't use FF much, so maybe I'm missing features.

I can see pinning that to a separate window and easily being able to see what are the most recent tabs.

What do you mean by pinning it to a separate window? The popup can't be dragged into a window as a tab, though there is the option to hide it as a tab when it closes. I think I may remove the popup features for a FF release, since FF already has proper ctrl-tab handling. The popup is just a workaround to create something similar in Chrome.

megamorphg commented 1 year ago

Actually, the full title of this page is [Feature Request] Option To Enable Wildcard Searching Both URL and Title ยท Issue #91 ยท fwextensions/QuicKey, so all the search terms in your query match the title, even if the end is clipped. But only two match in the URL, so that counts as a 0 match and nothing is highlighted in that case.

But "issues" is not fully present in the title, only the URL. The title has "issue" (singular). So since the 1st word has a match in the Title (and URL) and the 2nd word has a match in the URL, the tab should count as a match.

I think I'll make a further change so that if there's no space at the end of the query, pressing the spacebar inserts a space and moves the selection. That way, the option isn't really necessary. You get the same selection behavior as today, but can also insert spaces to search multiple tokens.

This might be a problem when there is a result after the 1st keyword and the user is trying to narrow down the search list to a specific tab within that list. Pressing space after the 1st keyword in that case will just activate the 1st tab in that case.

Not sure what you mean by hidden tabs in separate panels. I don't use FF much, so maybe I'm missing features.

Was referring to Sidebery, a "beta" add-on that has a tree-style tab view that has significantly improved managing thousands of tabs for me.

What do you mean by pinning it to a separate window? The popup can't be dragged into a window as a tab, though there is the option to hide it as a tab when it closes. I think I may remove the popup features for a FF release, since FF already has proper ctrl-tab handling. The popup is just a workaround to create something similar in Chrome.

Ah I meant pinning it to a separate monitor. You're right, Firefox users do need it less thanks to the MRU tabbing. However, the pop-up has to be triggered unlike the popup feature you have which can stay in the background while one is browsing. Kind of cool to visually see how many tabs one is flipping between and also what is in one's MRU list currently.

fwextensions commented 1 year ago

But "issues" is not fully present in the title, only the URL. The title has "issue" (singular).

There's an s in fwextensions, though, which is why it matches. If I had a different username, that query wouldn't match either the title or the URL, so this tab wouldn't show up, since all of the tokens have to match one or both strings.

I can do another build where not all of the tokens have to match to get a non-zero score. Tracking whether all of the tokens are matched across both strings is a little tricky.

This might be a problem when there is a result after the 1st keyword and the user is trying to narrow down the search list to a specific tab within that list. Pressing space after the 1st keyword in that case will just activate the 1st tab in that case.

The first match is selected by default whenever the query changes, so you can just hit enter to activate it. Hitting space would select the second item, but not activate it, unless you pressed enter. If you kept typing another token, the selection would switch back to the first match. So you'd probably only notice if you were intending to move the selection via the spacebar.

megamorphg commented 1 year ago

There's an s in fwextensions, though, which is why it matches. If I had a different username, that query wouldn't match either the title or the URL, so this tab wouldn't show up, since all of the tokens have to match one or both strings.

I can do another build where not all of the tokens have to match to get a non-zero score. Tracking whether all of the tokens are matched across both strings is a little tricky.

The s in fwextensions? So it's matching every character? I didn't notice that's how it was working. I think it would be best to try to match the whole set of characters separated by spaces (similar to search engines).

Searching across two strings would definitely be tricky. I don't know how you've coded this already in JS but one approach I was imagining is concatenating the Title and URL into a single string and storing it in a dictionary of all the tabs (for searching). And then any searches can easily search in that dictionary for the keyword to have 100% match per space separated word (not characters). The highlighting functionality would be tricky with this though.

fwextensions commented 1 year ago

It matches all the chars in each token in order, but they don't have to be an exact substring. More compact matches get higher scores, as do matches against capitals or the beginnings of words. So you can type gh to match GitHub.

You can see how the scoring matches up to other libraries here: https://fwextensions.github.io/quick-score-demo/

Just concatenating the title and URL doesn't really work, as matches earlier in the string score higher, so you wouldn't want the beginning of the URL to appear in the middle of the concatenated string. But handling it in some way is definitely doable.

fwextensions commented 1 year ago

I've uploaded a new version of the extension here: https://drive.google.com/file/d/1mST7Osr2vKN9RDbpttEx02eJY5iv2qBc/view?usp=share_link

It now lets the query match across the title or the URL. As long as each token is matched somewhere, it will get a non-zero score, which is different than how it's currently working (as discussed above).

I also changed the space behavior so the first press both inserts a space and moves the selection down. If you keep typing, the selection will jump back to the top.

Let me know if you see much difference with the previous version. It does seem to generate a much longer tail of mediocre matches, but the best ones should still be at the top.

megamorphg commented 1 year ago

@fwextensions ah yes it now highlights perfectly fine. 2023-04-03-1637-50

At first I didn't like how quick score matches characters rather than keywords but I think it scores higher based on continuity so it will be great (putting mediocre matches lower down). Also hoping it performs well since I only tested on a browser with 100 tabs. I look forward to trying it in my main browser with 1000+ tabs. ๐Ÿ˜…

fwextensions commented 1 year ago

Yes, more compact matches score higher than sparse ones, as do matches that start earlier in the string or are at the beginnings of words.

I've got ~1100 tabs open and it performs fine. You can also try typing /h to search the last 2000 pages from the history, in order to test searching across a large list.

megamorphg commented 1 year ago

Awesome, it works fine with my large history. Is there an upper limit of the database it searches through tab-wise and history-wise?

Only issue I noticed is:

Also it would be great to include an option to include bookmarks and history in the search (and have an icon next to it similar to the one you have for tabs that are in other windows). I can submit this as a separate request.

fwextensions commented 1 year ago

The history is limited to 2000 items, just so it doesn't become overwhelming. There's no limit to the number of tabs. It will search across all open ones.

If space is pressed too quickly in between keywords

This is when typing a space at the end of the query, not adding to the middle of a query? You're saying you press the space bar but no space is added? Does the selection move at all?

I'm not able to reproduce the issue with fast typing, at least in Chrome. I'll try FF, too.

megamorphg commented 1 year ago

I'm not able to reproduce the issue with fast typing, at least in Chrome. I'll try FF, too.

I'm not able to re-replicate. Maybe it was while my CPU was under high load at the same time and typing fast with the space had the issue because after pressing space the selection was moving to the next row at the same time and the next characters did not register in that split second while it was moving. Anyway it probably won't be an issue except for the slowest of computer.

megamorphg commented 1 year ago

@fwextensions will you push this to the main release? I think what you had is more than ready for release and would help me get rid of another add-on :)

megamorphg commented 1 year ago

@fwextensions can you please push this to the main release for FF? My other add-on is deprecated and no longer working in the latest release of FF. I really need an alternative to easily search for right tab (among thousands) with a wildcard.