Insert elements

Insert random elements to space

目前為 2025-02-23 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Insert elements
  3. // @description Insert random elements to space
  4. // @match https://neal.fun/infinite-craft/
  5. // @license MIT
  6. // @version 0.0.1.20250223131321
  7. // @namespace https://gf.qytechs.cn/users/1438939
  8. // ==/UserScript==
  9.  
  10. // Creating UI for selecting the number of clicks
  11. function createClickUI() {
  12. let uiContainer = document.createElement('div');
  13. uiContainer.style.position = 'fixed';
  14. uiContainer.style.top = '10px';
  15. uiContainer.style.right = '10px';
  16. uiContainer.style.background = 'rgba(0, 0, 0, 0.8)';
  17. uiContainer.style.color = 'white';
  18. uiContainer.style.padding = '10px';
  19. uiContainer.style.borderRadius = '8px';
  20. uiContainer.style.zIndex = '9999';
  21. uiContainer.style.fontFamily = 'Arial, sans-serif';
  22. uiContainer.innerHTML = `<h3 style="margin: 0 0 10px;">How many times would you like to click?</h3><div id="click-options"></div>`;
  23.  
  24. document.body.appendChild(uiContainer);
  25.  
  26. let clickOptions = document.getElementById('click-options');
  27. let values = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024];
  28.  
  29. values.forEach(value => {
  30. let btn = document.createElement('button');
  31. btn.innerText = value;
  32. btn.style.display = 'block';
  33. btn.style.width = '100%';
  34. btn.style.marginBottom = '5px';
  35. btn.style.padding = '5px';
  36. btn.style.background = '#444';
  37. btn.style.color = 'white';
  38. btn.style.border = 'none';
  39. btn.style.borderRadius = '5px';
  40. btn.style.cursor = 'pointer';
  41.  
  42. btn.addEventListener('click', () => {
  43. startClicking(value);
  44. });
  45.  
  46. clickOptions.appendChild(btn);
  47. });
  48. }
  49.  
  50. // Function to click a random item
  51. function clickRandomItem() {
  52. let items = document.querySelectorAll('.sidebar .item'); // Get the items list on the right
  53. if (items.length === 0) return;
  54.  
  55. let randomIndex = Math.floor(Math.random() * items.length);
  56. items[randomIndex].click();
  57. }
  58.  
  59. // Start clicking the selected number of times
  60. function startClicking(times) {
  61. let counter = 0;
  62.  
  63. let interval = setInterval(() => {
  64. if (counter >= times) {
  65. clearInterval(interval);
  66. } else {
  67. clickRandomItem();
  68. counter++;
  69. }
  70. }, 100); // Click every 100ms
  71. }
  72.  
  73. // Start the script
  74. createClickUI();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址