MrOtherGuy / bookmark-batch-updater

A webextension tool to update multiple bookmarks at once
Mozilla Public License 2.0
8 stars 1 forks source link

Make this extension work with any part of the url and for selected bookmarks #1

Open 35609902357 opened 4 years ago

35609902357 commented 4 years ago

This extension is very limited since it can only modify the domain, it would be more useful if it could modify any part of the url, like wildcards. For example, let's say the user https://github.com/MrOtherGuy/ moves all his projects to https://github.com/MrOtherGuy-2/, I want to modify all the projects I bookmarked from https://github.com/MrOtherGuy/* to https://github.com/MrOtherGuy-2/$1. Or maybe I want to switch from https to http for all Tor hidden addresses, so switching from https://*.onion to http://$1.onion. This extension also allows to modify bookmarks on an 'all or nothing' basis, so for example, if I want to modify only some of the scanned bookmarks I cannot exclude those I don't want to edit, this option should be added. This way this extension might become a very nice bookmarks manager.

MrOtherGuy commented 4 years ago

I somewhat agree. Regexp matching is something I have preliminary planned and implementing shouldn't be too hard now that selection between two scanning modes is already supported (instead of just one hardcoded behavior)

I'm not sure about the exclusion after scanning though, it's not a priority at least.

But I'll give them both a bit more thought when I can.

MrOtherGuy commented 4 years ago

So, I added a preliminary support for regexp matching (not published, you need to build it from source or run it via about:debugging) just to test basic functionality.

Only the "search for" uses regexp and you still need to give it a string to replace results with. So the question is - Is the behavior as expected? Could it even work in some different way?

Note that the same regexp that was used for scanning is what will be replaced by the script. So, by using a slightly wrong regexp may create bookmarks with invalid url - which is basically why I did not include regexp functionality in the first place.

35609902357 commented 4 years ago

Apologies for the late reply. I managed to test the new update (although not thoroughly) and it seems everything works as it should as far as RegExp are concerned. Thank you.

35609902357 commented 4 years ago

I tried some RegExp, but it messed up everything. Can you write a small guide in the README.md to explain how RegExp is supposed to work? For example if I want to delete ?disable_polymer=true from all youtube links how would I do? Inserting https://www.youtube.com/*?disable_polymer=true returns 0 results. What is the syntax you chose?

MrOtherGuy commented 4 years ago

The way that is supposed to work is to use ?disablepolymer=true as a filter and leave the replacement input empty, so in effect replace the found matches with empty string.

But it doesn't work. I'm fairly certain that it did work at some point though. I'll need to fix this.

The format you used, youtube.com*?disablepolymer=true doesn't work because you are trying here to limit the search for youtube but the program would go and try to replace the full match including youtube.com with the replacement value. I opted to doing for simplicity and because I could think of any plausible scenario where one would like to remove/modify a specific part of the url but only on specific urls such as ones that are on youtube domain.

35609902357 commented 4 years ago

Redirector has wildcards and they work great. Those would be perfect for managing bookmarks

MrOtherGuy commented 4 years ago

Could you explain how wildcards would make any difference here. You can certainly use regexp like you used as youtube.com*?disablepolymer=true (except I think you'll need to escape the ? with \ probably) but the problem is that this nor wildcards like redirector uses doesn't result in a url that you want. At least, I don't think that it will.

The result you would get if you used empty field as a replacement would be just https://www. because the extension code would replace the full match with a empty string, not just the portion that comes after the wildcard.

Or am I mistaken about how those wildcards work?

35609902357 commented 4 years ago

Let's say example.com changes the way urls are handled, and now https://example.com/user/Thomas has become https://example.com/id/Thomas, so I want to change all the bookmarks to reflect that. It would be useful to have a way to input something like https://example.com/*/* as url pattern and specify $1 as id and not input any value for $2, so the end result would be the desired one. I mentioned Redirector extension because it manages this very efficiently and flexibly (it outputs the result while typing so you can check any mistakes immediately) and because it's free software, so looking at the code may help. That flexibility would be great to have for this extension too