brookhong / Surfingkeys

Map your keys for web surfing, expand your browser with javascript and keyboard.
https://chrome.google.com/webstore/detail/surfingkeys/gfbliohnnapiefjpjlpjnehglfpaknnc
MIT License
5.32k stars 477 forks source link

regex for disabling (or just programmatic disabling on the page) #63

Closed WuTheFWasThat closed 8 years ago

WuTheFWasThat commented 8 years ago

I just found this extension and it's great! there's one thing I miss, though, which is being able to specify a domain to disable on, rather than a page.

I think I'd like a function which sets/toggles whether surfingKeys is active. i.e. when called, it disables everything in surfingkeys except the hotkey to re-enable it. It should be more or less whatever Alt-s is mapping to.

ideally i could then write stuff in the configuration like

if (document.domain is in my whitelist of regexes) {
   disableSurfingKeys();
}
brookhong commented 8 years ago

Added it in https://github.com/brookhong/Surfingkeys/commit/ca4220ce4b3e677b02931fccbfd7229aec244e42

Please add setting as below

settings.blacklistPattern = /.*somethingtobeexcluded/i;

To delete the pattern:

settings.blacklistPattern = undefined;
WuTheFWasThat commented 8 years ago

thanks! this is good enough for my problem, which was wildcard subdomains. but i do still think a list/function would be a bit nicer!

HaleTom commented 6 years ago

Is there a smart way to split this regex over multiple lines to blacklist more than one site?

jaekyeom commented 6 years ago

I agree with @HaleTom. We need settings.blacklistPatterns.

HaleTom commented 6 years ago

I'm using:

unmapAllExcept([], /\/todoist.com\//);

This can be used multiple times.

lee-tts commented 6 years ago

It's possible to string together multiple patterns using pipe | as a separator. I figured that out from this gist showing some kind soul's settings:

https://gist.github.com/thameera/8c846c48fd1c9f859cf602931e18a502

Their example:

settings.blacklistPattern = /.*mail.google.com.*|.*inbox.google.com.*|trello.com|duolingo.com|youtube.com|udemy.com/i;

My settings to make Surfingkeys play nice with KeyPass on login pages:

settings.blacklistPattern = /.*zendesk.com\/access.*|.*login.*|.*signin.*/i;

I've also learned that it seems this setting is kept somewhere outside the visible Surfkeys settings and can get messed up if you enter stuff wrong, at which point you'll need to do a settings.blacklistPattern = undefined;, save it in the Surfkeys settings page, set the patterns again, and save again on the Surfingkeys settings page.

Also don't forget to escape / characters (ex. /.*google.com\/flights.*/i;).

kalbasit commented 6 years ago

@lee-tts this works because settings.blacklistPattern is nothing more than a Javascript Regex.

sebastianst commented 6 years ago

Shouldn't we also escape the .s?

lee-tts commented 6 years ago

Good point. It depends how explicit you want to be. There might be some edge cases where using . in place of \. might cause problems but I can't think of any off hand, given the limited scope of web URIs.

HaleTom commented 9 months ago

Note that this has changed to blocklistPattern