in Education by
I'm getting into user scripting with tampermonkey and can't get through this error, any help would be appreciated. I detect keys fine, space key triggers this function who will repeat itself as long as the key remains in the down position. The console writes the output normally for 30 seconds more or less and then there's a TypeError. As per reputation-restriction, here's a screenshot: User-Script: // ==UserScript== // @name TEST STUFF-------------------- // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @run-at document-start // @include http://* // @include https://* // @grant none // ==/UserScript== ( function() { 'use strict'; window.addEventListener ( "keydown", CaptureKeyPress ); window.addEventListener ( "keyup", CaptureKeyPress ); var Hotkeys = { perform: 32 }; var HotkeyToggle = false; function CaptureKeyPress ( a ) { if ( a.keyCode == Hotkeys.perform ) { a.preventDefault(); a.stopPropagation(); a.cancelBubble = true; a.stopImmediatePropagation(); if ( a.type == "keydown" && !HotkeyToggle ) { console.clear(); HotkeyToggle = true; perform(); } if ( a.type == "keyup" && HotkeyToggle ) { HotkeyToggle = false; } } } function perform() { if(HotkeyToggle == false) // exit { return 0 } //do stuff... console.info("working..."); if(HotkeyToggle == true) // continue after everything completes { setTimeout(() => { perform() }, 280); return 0 } return 1 } } ) (); JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
This is either a TamperMonkey-specific issue, or a new security policy/bug in Chrome itself - I've ran into the same thing and caught it in the debugger, and none of the arguments are null/undefined; setTimeout is not overriden. Edit: A shared trait between the userscript in question and the one that I was debugging is the "recursive" use of setTimeout. I changed it to be a setInterval instead, and that seems to have fixed it in my case.

Related questions

0 votes
    According to ISO C++, dereferencing a null pointer is undefined behaviour. My curiosity is, why? Why ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    During a long compilation with Visual Studio 2005 (version 8.0.50727.762), I sometimes get the following ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 17, 2022 in Education by JackTerrance
0 votes
    During a long compilation with Visual Studio 2005 (version 8.0.50727.762), I sometimes get the following ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    In my unit test I am calling the following: every { connectivityManager.activeNetworkInfo } returns null but ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    You can check to see whether an R object is NULL with the _________ function. (a) is.null() (b) is. ... and Debugging of R Programming Select the correct answer from above options...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    I am retrieving messages from an Outlook account. I am trying to get inline files and attachments from ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
0 votes
    I'm looking to update a site for some friends with a pretty simple request (to change the time on each slide ... and the .php from the template that populates the slideshow:...
asked May 14, 2022 in Education by JackTerrance
0 votes
    __________ is interval represented by a vertical line, with a point in the middle. (a) geom_range (b) ... of R Programming Select the correct answer from above options...
asked Feb 10, 2022 in Education by JackTerrance
0 votes
    I came across this code today AsyncInvoke(OnTimeMessageTimer, (object)null, (ElapsedEventArgs)null); Is there ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    Can someone tell me how to refer a null object in Python? Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    What is Null Object pattern?...
asked Nov 7, 2020 in Education by Editorial Staff
0 votes
    I'm trying to compile GTK+ 3 with ATK 2.2.0 on CentOS, but am getting an error with ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 7, 2022 in Education by JackTerrance
0 votes
    I'm trying to compile GTK+ 3 with ATK 2.2.0 on CentOS, but am getting an error with ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    If the probabilities for A to fail in an examination is 0.2 and that for B is 0.3, then the probability that either A ... C. ≤ .5 D. 0 Select the correct answer from above options...
asked Nov 20, 2021 in Education by JackTerrance
...