xiaoxiaoflood / firefox-scripts

userChromeJS / autoconfig.js and extensions
Mozilla Public License 2.0
954 stars 83 forks source link

chrome/redirector.uc.js bug #145

Closed 0rt closed 2 years ago

0rt commented 2 years ago
 [
    //Remove unnecesary ? and &
    /(?:(\?)(?:&+(?!$|&)))|(?:&(?=&))|(?:(?:\??&+|\?)$)/g,
    '$1'
  ]

This rule will redirect bing.com search result to wrong page. I got search result like: https://www.bing.com/ck/a?!&&p=23ccaab8597a7dd028d1df710d9e69d54de6f14093cbf4163050769ddef34978JmltdHM9MTY1NDg1NjI1NiZpZ3VpZD0yZmNmMTMxYy0zMGQwLTRiNTYtYjZkNy1mMmNiYmIzNzdiYTQmaW5zaWQ9NTE1OQ&ptn=3&fclid=8c2d56b2-e8a6-11ec-a223-1ac7fdae5f30&u=a1aHR0cHM6Ly93d3cuc3FsaXRlLm9yZy9zcmMvaGVscD9jbWQ9bWVyZ2U&ntb=1

I will redirct to wrong site if the uc.js is enabled

xiaoxiaoflood commented 2 years ago

For some weird reason, those Bing tracker URLs need the && part to work.

As you may know, & in URLs is a separator of parameters. What that rule does is to to remove useless &, like when it's the last char of the URL, when it follows ? or when it's doubled (&&). I do this to clean URLs a bit to enhance the efficiency of Link Status Redux, to better recognize already visited URLs.

Rules in the published Redirector are just examples, my set of rules is different (but I do use that one to remove &) and each user must write the ones they need. Since rules are personal and I don't use Bing, I probably won't bother adding an exception to this Bing excrescence.

Regarding removing parameters - because the mentioned rule is a complement to the "Remove universal parameters" rule - there were always other ways like ClearURLs (extension) and uBlock Origin filters, but starting with Fx 102 they can be removed natively, just enable privacy.query_stripping.enabled and write undesired parameters in privacy.query_stripping.strip_list, separated by space.

0rt commented 2 years ago

Could you please consider adding some console.log message for the redirector? It's not easy for user to tweak those rules even if they know the ABC of javascript, at least which rule is applied would help a lot.

xiaoxiaoflood commented 2 years ago

Sorry, I don't want to be rude but the script is meant for users who understand it (JavaScript & Fx internals), there's no user friendliness and there won't be - userChromeJS scripts are usually like that, full extensions are the ones with UI and ease of use. Also it doesn't seem appropriate to include logs. You can write console.logs anywhere, but again you need to know where it's useful for you and what exactly you want to debug.

I suggest you to use Redirector. If you just want to strip parameters, my previous comment offers alternatives.

xiaoxiaoflood commented 2 years ago

You may want to append console.log(redirectUrl); right after this line: https://github.com/xiaoxiaoflood/firefox-scripts/blob/77f56676dc6686af15827f9d51c1e4d3e0989c2a/chrome/redirector.uc.js#L121

That's all I can do.