Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pressing and holding Ctrl causes a ui error in 'godmode' #2145

Closed
7 of 8 tasks
shc0743 opened this issue Jun 18, 2022 · 5 comments
Closed
7 of 8 tasks

Pressing and holding Ctrl causes a ui error in 'godmode' #2145

shc0743 opened this issue Jun 18, 2022 · 5 comments
Labels
bug Something isn't working fixed issue has been addressed

Comments

@shc0743
Copy link

shc0743 commented Jun 18, 2022

Prerequisites

I tried to reproduce the issue when...

  • uBO is the only extension
  • uBO with default lists/settings
  • using a new, unmodified browser profile

Description

If I am advanced user (Important!) and I open uBlock popup panel in any page,
then press Ctrl for more than 1 second,
the green allow box will twinkle:
image
image
I tried to find out why this appear,
and (maybe) I found the problem source:

/js/popup-fenix.js , Line 1256

/*******************************************************************************

    Double tap ctrl key: toggle god mode

*/

{
    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');
    });
}

It cause the 'godMode' class toggles very quickly, so the box twinkle.

A specific URL where the issue occurs

everywhere

Steps to Reproduce

  1. Check "I am advanced user" in uBlock settings
  2. Open a webpage
  3. open uBlock origin popup page
  4. Move the mouse to any box
    屏幕截图 2022-06-18 151300
  5. press Ctrl key for more than 1 seconds

Expected behavior

godMode open and a green allow box appear
image

Actual behavior

The green allow box twinkle very quickly.
'godMode' is always toggling.
if I open DevTools, there is a 'godMode' twinkle in body's class:
image
image

uBlock Origin version

1.42.4

Browser name and version

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36

Operating System and version

Windows 10 21H2 19044.1766

@gorhill
Copy link
Member

gorhill commented Jun 18, 2022

Unable to reproduce. It seems your ctrl key may be auto-repeating, I don't think it should.

@shc0743
Copy link
Author

shc0743 commented Jun 19, 2022

Unable to reproduce. It seems your ctrl key may be auto-repeating, I don't think it should.

Yes, this is caused by auto repeating.
Maybe it is hardware related. I tested with my physics keyboard, it repeats and ev.repeat==true .
Open this test url and open DevTools to test data:text/html,<script src="data:text/javascript,document.addEventListener('keydown',function(ev){console.dir(ev)})"></script>Press any key to test
It repeats in my computer
屏幕截图 2022-06-19 133610

But when I test with osk.exe (Windows Screen Keyboard), I can't reproduce.
I think you could add if (ev.repeat) return; and this will be solved.

@gwarser
Copy link

gwarser commented Jun 19, 2022

I can reproduce in VM Win10 in Firefox, Edge, Chrome and Opera - Windows thing?

@gorhill
Copy link
Member

gorhill commented Jun 19, 2022

think you could add if (ev.repeat) return; and this will be solved.

Good idea, will do: https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/repeat.

gorhill added a commit to gorhill/uBlock that referenced this issue Jun 19, 2022
@shc0743 shc0743 changed the title Pressing and holding Ctrl causes an exception in 'godmode' Pressing and holding Ctrl causes a ui error in 'godmode' Jun 20, 2022
@gwarser gwarser closed this as completed Jun 20, 2022
@gwarser gwarser added fixed issue has been addressed bug Something isn't working labels Jun 20, 2022
@krystian3w
Copy link

krystian3w commented Jun 22, 2022

Fix works too on Windows 7.

To check Windows XP then needed is use MyPal 68 if is in good work latest stable and dev builds of uBo.

Vista may need use some of Chromium based 78 - 87 release (MyPal 68 may still works bad on Vista) to check it.

If XP and Vista don't repeat button then this is added in 2009 to Windows 7 or later by e.g. KB update (no planed for XP and Vista).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed issue has been addressed
Projects
None yet
Development

No branches or pull requests

4 participants