Just a cps counter

Shows the number of clicks per second

目前为 2022-06-27 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Just a cps counter
  3. // @namespace -
  4. // @version 0.1
  5. // @description Shows the number of clicks per second
  6. // @author Nudo#3310
  7. // @license MIT
  8. // @match *://sploop.io/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=sploop.io
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function anonymous() {
  14. const Cps = {}
  15.  
  16. Cps.log = console.log
  17.  
  18. Cps.count = 0
  19.  
  20. Cps.reduce = function() {
  21. this.count -= 1
  22.  
  23. return this.element.setText(this.count)
  24. }
  25.  
  26. Cps.increase = function() {
  27. this.count += 1
  28.  
  29. return this.element.setText(this.count)
  30. }
  31.  
  32. Cps.sleep = function() {
  33. return new Promise((resolve) => {
  34. setTimeout(resolve, 1000)
  35. })
  36. }
  37.  
  38. Cps.createElement = function() {
  39. this.element = document.createElement("div")
  40.  
  41. this.element.setText = (count) => {
  42. const countNum = parseInt(count)
  43.  
  44. if (countNum < 0) {
  45. count = 0
  46.  
  47. Cps.log("bug...")
  48. }
  49.  
  50. this.element.textContent = `Cps: ${count}`
  51. }
  52.  
  53. this.element.setText(0)
  54.  
  55. this.style = this.element.style
  56.  
  57. this.element.classList.add("text-shadowed-3")
  58.  
  59. this.style.position = "absolute"
  60. this.style.top = "20px"
  61.  
  62. this.style.width = "100%"
  63.  
  64. this.style.textAlign = "center"
  65. this.style.color = "white"
  66. this.style.fontSize = "20px"
  67.  
  68. return document.body.appendChild(this.element)
  69. }
  70.  
  71. Cps.createElement()
  72.  
  73. Cps.update = async function() {
  74. this.increase()
  75. await this.sleep()
  76. this.reduce()
  77. }
  78.  
  79. document.addEventListener("mousedown", () => {
  80. Cps.update()
  81. })
  82.  
  83. Cps.spaceActive = false
  84.  
  85. document.addEventListener("keydown", (event) => {
  86. if (event.code !== "Space" || Cps.spaceActive) {
  87. return void 0
  88. }
  89.  
  90. Cps.update()
  91. Cps.spaceActive = true
  92. })
  93.  
  94. document.addEventListener("keyup", (event) => {
  95. if (event.code !== "Space") {
  96. return void 0
  97. }
  98.  
  99. Cps.spaceActive = false
  100. })
  101. })()