1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-15 07:22:28 +02:00

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:
Raymond Hill 2020-05-23 19:48:28 -04:00
parent a018937792
commit 196746386c
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -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; let eventCount = 0;
if ( ev.ctrlKey && ev.key === ' ' ) { let eventTime = 0;
document.body.classList.toggle('godMode');
consumed = true; document.addEventListener('keydown', ev => {
} if ( ev.key !== 'Control' ) {
if ( consumed ) { eventCount = 0;
ev.stopPropagation(); return;
ev.preventDefault(); }
} 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);
/******************************************************************************/ /******************************************************************************/