mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-18 17:02:27 +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:
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;
|
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);
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user