Greasy Fork is available in English.

tool.user.js

tool.user

Script này sẽ không được không được cài đặt trực tiếp. Nó là một thư viện cho các script khác để bao gồm các chỉ thị meta // @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. }