Robbendebiene / Gesturefy

Navigate, operate, and browse faster with mouse gestures! A customizable Firefox mouse gesture add-on with a variety of different commands.
https://addons.mozilla.org/firefox/addon/gesturefy/
GNU General Public License v3.0
799 stars 74 forks source link

Improve Increase/Decrease URL number gestures #367

Closed Przbl closed 3 years ago

Przbl commented 5 years ago

The Increase/Decrease URL number gestures don't always work because some URLs (e.g. amazon) often contain a lot of numbers and the logic that focuses at the last number occurrence might fail to spot the correct one.

So I'd suggest to add a gesture that when first used in a session presents the url to the user and let him choose what might be the correct number to increase/decrease. The chosen number would be the one to increase/decrease during this session without further prompts.

aafulei commented 5 years ago

Update: corrected typos in the links. Sorry for any misunderstanding that I caused.

I also had problem with Increase/Decrease URL number gestures. But I don't think the logic is simply "focusing at the last number occurrence". In fact, I hope so.

Say a url that ends with /document/2?doc_id=25. Increasing that by 1 would get /document/3?doc_id=25. This is not what I want. I want /document/2?doc_id=26. Full url is here for your reference.

Could the author first make it so that increase /document/2?doc_id=25 by 1 is /document/2?doc_id=26? I think this is natural. Thanks!

Robbendebiene commented 5 years ago

So I'd suggest to add a gesture that when first used in a session presents the url to the user and let him choose what might be the correct number to increase/decrease. The chosen number would be the one to increase/decrease during this session without further prompts.

While this is a good idea in theory, in practice it means a lot of work, which we don't want to or cannot afford for a single command. The only thing I can think of is a custom/user defined reg expression which determines the number that should be increased/decreased.

@aafulei The logic is: increase the last number in the path if any, else increase the last number in the query string

Could the author first make it so that increase /document/2?doc_id=25 by 1 is /document/3?doc_id=26? I think this is natural. Thanks!

So you want to increase both numbers? This is to specific and thus will only be possible once Gesturefy supports custom user scripts.

aafulei commented 5 years ago

Hi @Robbendebiene Thanks for your reply!

I am sorry I made some typos in the links. I have just corrected them. Basically I want to increase only the last number in the link (be it in the path or query string). Sorry for the misunderstanding that I caused.

Thanks, too, for the logic. If that's your design, I'll respect it. Just consider my opinion as a feedback.

Przbl commented 5 years ago

Thanks @Robbendebiene, my suggestion wasn't a new idea, I just thought of it because it was a helpful part of an extension I used in an old Firefox version.

I can't remember the name of that extension but I found the same thing in another deprecated extension.: "URL Flipper" (http://code.kliu.org/urlflipper/).

Maybe you can borrow some code from this.

pgorod commented 5 years ago

As I mentioned in #127 we can probably just reuse All-in-one gestures code. These actions are also there, among dozens of others. 😄

Robbendebiene commented 4 years ago

I know it's been a while, but I would appreciate some feedback if there is still some one interested in this.

Since Gesturefy now supports user scripts I wrote one for this particular problem (It allows you to choose which number should be increased). I also think about integrating it directly into Gesturefy (updating the increase/decreseURL commands) but I'm unsure about the best way to re-identify the number that should be increase.

The user script currently works as follows: Say we have an URL "http://blalba.com/123/test?hu=23". There are 2 number occurrences. Each one gets an index. So 123 -> 0 and 23 -> 1. If we decide to increase the last number we will store the index (1) and from now on always increase the number with the index 1 (which is always the second number)

While this will work for most cases this fails if another number gets added before our chosen number while browsing. For example: "http://blalba.com/123/test?before=9&hu=23" Now we will always increase the number that follows "before=".

The solution seems obvious, why don't we look for the query parameter, in this case "hu"? Because ones chosen number can also occur after a slash (http://blalba.com/123/) or after a hash (http://blalba.com#123) or even in a query parameter value like so "http://blalba.com/test?para=page34".

I hope you get the problem.

If you have any ideas. Please let me know :)

User Script: increaseURLUserScript.txt

Przbl commented 4 years ago

The script is absolutely brilliant and solves the problem for me. Thanks!

If I'll run over a URL that behaves like you described (adding another number while browsing), I will fire up the Firefox Developer Tools (F12), delete the session item "Gesturefy_Inscrease_URL_Number_Index" and run the increase/decrease gesture again. Unless someone finds a script for deleting this session cookie; if so, for convenience I'll put this on a gesture, too 🙂

byzod commented 3 years ago

This is brilliant!

The simply index way works good in most cases, however, may be vastly off in some situation

For example you're visiting some site with hex file index (this is very common): https://exhentai/g/123/67ab/?p=13, you invoke the script and select 13, it takes you to ?p=14 perfectly this time

However the next file you browser have a different file index: https//exhentai/g/123/67a4/?p=1 you invoke the script again but it takes you to /67a5/?p=1 rather than /67a4/?p=2

A better simple way to improve is to record two index x and y, x means the xth slash (/), y means the yth number after the xth slash, this is still not perfect but works on (slightly) more sites. (broken on something like domain.com/123/token=67ab&p=1)


btw I mod @Robbendebiene 's script a little:

changeURLUserScript.txt

New: won't call the popup that you can't do anything but close it, if there's no number to increase New: increase/decrease the number directly if there's only one option Mod: move codes around for easier modification Mod: changed style of the popup a little for easier interaction


Here's another version that record the slash index Like I said it's still far from perfect but works on more sites

changeURLNumberUserScript.txt

New: remember the slash (/) index too, only replaced nth number after the mth slash

Robbendebiene commented 3 years ago

With the release of Gesturefy 3.1.2 the URL Increase/Decrease commands will now always change the right most number (if it's a parameter value or between slashes). In addition to that users can now define a custom regex to alter this behaviour. Read more about it here.

In combination with the user script provided here there are now multiple ways to content the individual needs of users. Therefore I consider this issue as solved.

Happy gestureing everyone!