mirror of https://github.com/gorhill/uBlock.git
Double-tap ctrl key to toggle god mode in popup panel
After many feedback: - https://github.com/gorhill/uBlock/commit/aec2f81884c5#commitcomment-39385794 This is convenient enough and this still fulfill the idea of not being able to create mindlessly allow_ rules.
This commit is contained in:
parent
a018937792
commit
196746386c
|
@ -1112,23 +1112,31 @@ const toggleHostnameSwitch = async function(ev) {
|
|||
|
||||
/*******************************************************************************
|
||||
|
||||
Ctrl-Space bar: toggle god mode
|
||||
Double tap ctrl key: toggle god mode
|
||||
|
||||
*/
|
||||
|
||||
const keyboardHandler = function(ev) {
|
||||
let consumed = false;
|
||||
if ( ev.ctrlKey && ev.key === ' ' ) {
|
||||
document.body.classList.toggle('godMode');
|
||||
consumed = true;
|
||||
}
|
||||
if ( consumed ) {
|
||||
ev.stopPropagation();
|
||||
ev.preventDefault();
|
||||
}
|
||||
};
|
||||
{
|
||||
let eventCount = 0;
|
||||
let eventTime = 0;
|
||||
|
||||
document.addEventListener('keydown', ev => {
|
||||
if ( ev.key !== 'Control' ) {
|
||||
eventCount = 0;
|
||||
return;
|
||||
}
|
||||
const now = Date.now();
|
||||
if ( (now - eventTime) >= 500 ) {
|
||||
eventCount = 0;
|
||||
}
|
||||
eventCount += 1;
|
||||
eventTime = now;
|
||||
if ( eventCount < 2 ) { return; }
|
||||
eventCount = 0;
|
||||
document.body.classList.toggle('godMode');
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('keydown', keyboardHandler);
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
|
Loading…
Reference in New Issue