Click Counter and Mistake Tracker

For those who use the site for self-learning. It counts how many times you clicked and how many mistakes you made (click on the counter to count mistakes).

  1. // ==UserScript==
  2. // @name Click Counter and Mistake Tracker
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.6
  5. // @description For those who use the site for self-learning. It counts how many times you clicked and how many mistakes you made (click on the counter to count mistakes).
  6. // @author Idhtft
  7. // @match https://randomwordgenerator.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Create a counter display
  16. const counterDisplay = document.createElement('div');
  17. counterDisplay.id = 'clickCounter';
  18. counterDisplay.style.position = 'fixed';
  19. counterDisplay.style.bottom = '10px';
  20. counterDisplay.style.right = '10px';
  21. counterDisplay.style.backgroundColor = 'blue';
  22. counterDisplay.style.color = 'white';
  23. counterDisplay.style.padding = '10px';
  24. counterDisplay.style.border = '1px solid black';
  25. counterDisplay.style.borderRadius = '5px';
  26. counterDisplay.style.cursor = 'pointer'; // Make it clickable
  27. counterDisplay.style.zIndex = '1000';
  28. document.body.appendChild(counterDisplay);
  29.  
  30. // Initialize counters
  31. let clickCount = 0;
  32. let mistakeCount = 0;
  33.  
  34. // Update the counter display
  35. function updateCounter() {
  36. counterDisplay.textContent = `Clicked: ${clickCount} times\nMistakes: ${mistakeCount}`;
  37. }
  38.  
  39. // Attach event listener to the button
  40. const generateButton = document.querySelector('input[type="submit"][value="Generate Random Words"]');
  41. if (generateButton) {
  42. generateButton.addEventListener('click', () => {
  43. clickCount++;
  44. updateCounter();
  45. });
  46. }
  47.  
  48. // Attach event listener to the counter display
  49. counterDisplay.addEventListener('click', () => {
  50. mistakeCount++;
  51. updateCounter();
  52. });
  53.  
  54. // Initialize counter display
  55. updateCounter();
  56. })();