Greasy Fork is available in English.

tool.user.js

tool.user

이 스크립트는 직접 설치해서 쓰는 게 아닙니다. 다른 스크립트가 메타 명령 // @require https://update.greatest.deepsurf.us/scripts/525123/1528092/tooluserjs.js(으)로 포함하여 쓰는 라이브러리입니다.

질문, 리뷰하거나, 이 스크립트를 신고하세요.
  1. function getRandomNum(min, max) {
  2. if (min >= max) {
  3. throw new Error("Min must be less than max");
  4. }
  5. min = Math.ceil(min);
  6. max = Math.floor(max);
  7. return Math.floor(Math.random() * (max - min + 1)) + min;
  8. }
  9.  
  10. /**
  11. * 模拟用户输入填充input元素
  12. * @param {HTMLInputElement} inputElement - 输入框元素
  13. * @param {string|number} value - 要填充的值
  14. */
  15. function fillFormInput(inputElement, value) {
  16. let index = 0;
  17. value = value.toString();
  18. inputElement.value = "";
  19.  
  20. // 使用文档片段减少DOM操作
  21. const docFragment = document.createDocumentFragment();
  22. const intervalId = setInterval(() => {
  23. if (index < value.length) {
  24. docFragment.textContent += value[index];
  25. inputElement.value = docFragment.textContent;
  26. const inputEvent = new Event("input", { bubbles: true });
  27. inputElement.dispatchEvent(inputEvent);
  28. index++;
  29. } else {
  30. clearInterval(intervalId);
  31. }
  32. }, 100);
  33. }
  34.  
  35. function getRandomCharFrom(str) {
  36. const randomIndex = Math.floor(Math.random() * str.length);
  37. return str.charAt(randomIndex);
  38. }
  39.  
  40. const leftKeyboardChars = "1234567890qwertyuiop[]asdfghjkl;'zxcvbnm,./";
  41.  
  42. function getRandomLeftKeyboardChar() {
  43. return getRandomCharFrom(leftKeyboardChars);
  44. }