Total-Suspender-webextension
Total-Suspender-webextension copied to clipboard
Regex error in whitelist stop tab suspension
Total Suspender version 3.6.0
I'm not used to JS regex and inputed standard regex in whitelist. Doing so, it seems that the suspension stopped for all sites.
Concrete example: I have https://twitter.com/i/notifications
and https://youtube.com/whatever
open.
My config is:
[setting] suspension -> enabled, suspend after -> 2s.
[whitelist] Whitelist -> On (ho it would be amazing to have "enabled" also here, because it took some time to understand if "on" was the action or the state, and so if I needed to put it to on or off - in insigh, it can't be an action, but it was not obvious)
URL: \regex\https://twitter.com/.*
=> youtube is never discarded ;
Changing to \regex\https://twitter.com/*/g
=> youtube is discarded as expected.
So, I don't know how to signal to the user where is the problem, but at least you should had a link toward what regex are supported (or give example), and make that a bad regex doesn't disable tab unloading everywhere.
Actually, I'm not succeding in making regex works. The export looks like that (and I tried with both .*
and *
) but it seems that once I unput several url, it stops working. I just want to ignore unloading tabs for all the sites:
["\\regex\\https://app.clubhouse.io/*/g","\\regex\\https://issues.rudder.io/.*/g","\\regex\\https://twitter.com/.*/g","\\regex\\https://calendar.google.com/.*/g","\\regex\\https://github.com/.*/g"]
Hello, @fanf !
First of all, thanks for a nice report, I quickly partially reproduced your issue.
You're absolutely correct, I definitely should have added some sort of a link to a guide like this or implemented a regex-validator of sorts. The reason why there is almost zero examples is simply because regexes in TS are hardcore, for typical usecases simple strings are sufficient: just typing
https://calendar.google.com/
will do, though, I'm in no position to decide.
Then, your regexes do not work the desired way, because they are incorrect. Instead of typing \regex\https://twitter.com/.*/g
you should do \regex\/https://twitter.com/.*/g
, note the typical forward slash after \regex\
part. So, with no indication of regex open after \regex\
, parser takes next forward slash and afterwards throws an invalid regular expression flag exception. Nice! It's tricky to reproduce the second part of your issue, that is, make blacklist functionality break completely, I believe this is because of sets and ordering.
I'm going to refactor white-/blacklisting interfaces a bit and add explicit checks in background. New version will be released in a day!
Thank you, it works with the correct regex ;)
just typing https://calendar.google.com/ will do,
Do you mean that by default, whitelisting look for "starts with" not exact match? Indeed, it would be easier, and it is likely to be a very common case (but I really need "starts with", even for calendar, because depending of the view/user the url's ending is not the same).
Thansk for the quick answer, and I think Total Suspender will quickly become a must have.
I would like some advice on how to white/blacklist a tab. There are no specific details supplied with the add on. Thanks
Hello, @dajson !
You can enter either "patterns" or regular expressions.
For "patterns" the logic is simple. Patterns do not start with \regex, any other string will do. If tab's URL contains such a substring, then it will pass the filter. For instance, let's take a pattern github
added to your whitelist. This means, that any tab with URL containing github
like https://github.com
or https://some-proxy.com/browse.php?u=github
will never be suspended.
For the majority of usecases it's enough, to make it more comfortable, you can use tab context menu (right click on the tab), then choose tab suspender -> white-/blacklist URL or domain. URL means the whole URL like https://github.com/k5md/Total-Suspender-webextension/issues/24
, while domain will cut URL to https://github.com
.
However, you may not like the second case, when tab may or may not be suspended depending on the querystring, this is the case where we need regular expressions. Refer to this for the syntax. In this extension, regular expressions have to be prepended with \regex\
. The resulting form is: \regex\/regex_pattern/regex_flags
.