Like Automator

This is a "like" automator (first N posts only).

目前為 2024-09-25 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Like Automator
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.5
  5. // @description This is a "like" automator (first N posts only).
  6. // @author biganthonymo
  7. // @match https://x.com/*
  8. // @match https://mobile.x.com/*
  9. // @match https://twitter.com/*
  10. // @match https://mobile.twitter.com/*
  11. // @icon data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IiB2aWV3Qm94PSIwIDAgMTIyLjg4IDExNC40MiIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgMTIyLjg4IDExNC40MiIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PHN0eWxlIHR5cGU9InRleHQvY3NzIj48IVtDREFUQVsKCS5zdDB7ZmlsbC1ydWxlOmV2ZW5vZGQ7Y2xpcC1ydWxlOmV2ZW5vZGQ7ZmlsbDojRUU0ODU2O30KCS5zdDF7ZmlsbC1ydWxlOmV2ZW5vZGQ7Y2xpcC1ydWxlOmV2ZW5vZGQ7ZmlsbDojRkZGRkZGO30KXV0+PC9zdHlsZT48Zz48cGF0aCBjbGFzcz0ic3QwIiBkPSJNOS4zMiwwaDEwNC4yNGM1LjEzLDAsOS4zMiw0LjIsOS4zMiw5LjMydjczLjYyYzAsNS4xMS00LjIxLDkuMzItOS4zMiw5LjMySDgzLjg0bC0xNi4xNywxOS4wNiBjLTMuNTgsNC4yMy05LjQ1LDQuMDQtMTIuODEsMEwzOS4wNCw5Mi4yNkg5LjMyQzQuMjEsOTIuMjYsMCw4OC4wNywwLDgyLjk0VjkuMzJDMCw0LjE5LDQuMTksMCw5LjMyLDBMOS4zMiwweiIvPjxwYXRoIGNsYXNzPSJzdDEiIGQ9Ik02MS4yLDMwLjQyYzMuNTMtMy42OCw2LTYuMTcsMTEuNDMtNi43OWMxMC4yLTEuMTcsMjAuMjcsOS4yNywxNS4xMiwxOS41NmMtMS45LDMuNzktOC40OSwxMC4xNi0xMy43NiwxNS4xNSBjLTIuMDEsMS45LTMuODMsMy42MS01LjEyLDQuODlsLTcuNjYsNy42bC02LjMzLTYuMDljLTEuOTEtMS44My00LjE2LTMuNzktNi40Ni01Ljg3QzQxLjUsNTIuNjQsMzQuMDUsNDUuMywzMy43NCwzNi43MyBjLTAuMjktOC4wMSw2LjcyLTEzLjE1LDE0LTEzLjA2QzU0LjIsMjMuNzYsNTYuOTIsMjYuMjUsNjEuMiwzMC40Mkw2MS4yLDMwLjQyeiIvPjwvZz48L3N2Zz4=
  12. // @grant none
  13. // @license MIT
  14.  
  15. // ==/UserScript==
  16.  
  17. (function() {
  18. 'use strict';
  19.  
  20. // Create the floating button
  21. const floatButton = document.createElement('button');
  22. floatButton.innerText = 'Like Automator';
  23. Object.assign(floatButton.style, {
  24. position: 'fixed',
  25. bottom: '20px',
  26. right: '20px',
  27. zIndex: '9999',
  28. padding: '10px',
  29. backgroundColor: '#007bff',
  30. color: '#fff',
  31. border: 'none',
  32. borderRadius: '5px',
  33. cursor: 'pointer'
  34. });
  35.  
  36. document.body.appendChild(floatButton);
  37.  
  38. // Function to get a random delay between 300ms and 1000ms
  39. function getRandomDelay() {
  40. return Math.floor(Math.random() * (1000 - 300 + 1)) + 300;
  41. }
  42.  
  43. // Add click event listener
  44. floatButton.addEventListener('click', function() {
  45. // Scroll down to the location of the button (+10 pixels)
  46. const buttonPosition = floatButton.getBoundingClientRect().top + window.pageYOffset;
  47. window.scrollTo({
  48. top: buttonPosition + 10,
  49. behavior: 'smooth'
  50. });
  51.  
  52. const buttons = document.querySelectorAll('[data-testid="like"]');
  53. let totalDelay = 0;
  54. let clickedCount = 0;
  55.  
  56. for (let i = 1; i < 50 && i < buttons.length; i++) {
  57. let delay = getRandomDelay();
  58. totalDelay += delay;
  59.  
  60. setTimeout(function() {
  61. buttons[i].click();
  62. clickedCount++;
  63. }, totalDelay);
  64. }
  65.  
  66. // Output a div at the bottom showing how many were clicked
  67. setTimeout(function() {
  68. // Create the div element
  69. const messageDiv = document.createElement('div');
  70. messageDiv.textContent = `${clickedCount} buttons were clicked`;
  71. messageDiv.style.position = 'fixed';
  72. messageDiv.style.bottom = '10px';
  73. messageDiv.style.left = '50%';
  74. messageDiv.style.transform = 'translateX(-50%)';
  75. messageDiv.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';
  76. messageDiv.style.color = '#fff';
  77. messageDiv.style.padding = '10px 20px';
  78. messageDiv.style.borderRadius = '5px';
  79. messageDiv.style.fontSize = '16px';
  80. messageDiv.style.zIndex = '1000';
  81.  
  82. // Append the div to the body
  83. document.body.appendChild(messageDiv);
  84.  
  85. // Remove the div after 3 seconds
  86. setTimeout(function() {
  87. messageDiv.remove();
  88. }, 3000);
  89. }, totalDelay + 500);
  90. });
  91.  
  92. })();