Insert elements

Insert random elements to space

  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.20250223132042
  7. // @namespace https://gf.qytechs.cn/users/1438939
  8. // ==/UserScript==
  9. // Creating UI for entering the number of clicks
  10. function createClickUI() {
  11. let uiContainer = document.createElement('div');
  12. uiContainer.style.position = 'fixed';
  13. uiContainer.style.top = '10px';
  14. uiContainer.style.left = '10px'; // Changed to the left side
  15. uiContainer.style.background = 'rgba(0, 0, 0, 0.8)';
  16. uiContainer.style.color = 'white';
  17. uiContainer.style.padding = '10px';
  18. uiContainer.style.borderRadius = '8px';
  19. uiContainer.style.zIndex = '9999';
  20. uiContainer.style.fontFamily = 'Arial, sans-serif';
  21. uiContainer.innerHTML = `
  22. <h3 style="margin: 0 0 10px;">Enter the number of clicks:</h3>
  23. <input id="click-input" type="number" min="2" max="1000" style="width: 100%; padding: 5px; font-size: 16px; margin-bottom: 10px; border-radius: 5px; border: none;">
  24. <button id="click-btn" style="width: 100%; padding: 5px; background: #444; color: white; border-radius: 5px; border: none; cursor: pointer;">Start Clicking</button>
  25. `;
  26.  
  27. document.body.appendChild(uiContainer);
  28.  
  29. let clickButton = document.getElementById('click-btn');
  30. clickButton.addEventListener('click', () => {
  31. let inputValue = document.getElementById('click-input').value;
  32. if (inputValue >= 2 && inputValue <= 1000) {
  33. startClicking(parseInt(inputValue));
  34. } else {
  35. alert("Please enter a number between 2 and 1000.");
  36. }
  37. });
  38. }
  39.  
  40. // Function to click a random item in the sidebar
  41. function clickRandomItem() {
  42. let items = document.querySelectorAll('.sidebar-inner .items .item'); // Get the items inside the sidebar-inner
  43. if (items.length === 0) return;
  44.  
  45. let randomIndex = Math.floor(Math.random() * items.length);
  46. items[randomIndex].click();
  47. }
  48.  
  49. // Start clicking the selected number of times
  50. function startClicking(times) {
  51. let counter = 0;
  52.  
  53. let interval = setInterval(() => {
  54. if (counter >= times) {
  55. clearInterval(interval);
  56. } else {
  57. clickRandomItem();
  58. counter++;
  59. }
  60. }, 100); // Click every 100ms
  61. }
  62.  
  63. // Start the script
  64. createClickUI();

QingJ © 2025

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