brookhong / Surfingkeys

Map your keys for web surfing, expand your browser with javascript and keyboard.

Home Page:https://chrome.google.com/webstore/detail/surfingkeys/gfbliohnnapiefjpjlpjnehglfpaknnc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

WuTheFWasThat opened this issue · comments

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();
}

Added it in ca4220c

Please add setting as below

settings.blacklistPattern = /.*somethingtobeexcluded/i;

To delete the pattern:

settings.blacklistPattern = undefined;

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!

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

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

I'm using:

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

This can be used multiple times.

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;).

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

Shouldn't we also escape the .s?

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.