Like Automator

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

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Like Automator
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  This is a "like" automator (first N posts only).
// @author       biganthonymo
// @match               https://x.com/*
// @match               https://mobile.x.com/*
// @match               https://twitter.com/*
// @match               https://mobile.twitter.com/*
// @icon              data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkxheWVyXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IiB2aWV3Qm94PSIwIDAgMTIyLjg4IDExNC40MiIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgMTIyLjg4IDExNC40MiIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PHN0eWxlIHR5cGU9InRleHQvY3NzIj48IVtDREFUQVsKCS5zdDB7ZmlsbC1ydWxlOmV2ZW5vZGQ7Y2xpcC1ydWxlOmV2ZW5vZGQ7ZmlsbDojRUU0ODU2O30KCS5zdDF7ZmlsbC1ydWxlOmV2ZW5vZGQ7Y2xpcC1ydWxlOmV2ZW5vZGQ7ZmlsbDojRkZGRkZGO30KXV0+PC9zdHlsZT48Zz48cGF0aCBjbGFzcz0ic3QwIiBkPSJNOS4zMiwwaDEwNC4yNGM1LjEzLDAsOS4zMiw0LjIsOS4zMiw5LjMydjczLjYyYzAsNS4xMS00LjIxLDkuMzItOS4zMiw5LjMySDgzLjg0bC0xNi4xNywxOS4wNiBjLTMuNTgsNC4yMy05LjQ1LDQuMDQtMTIuODEsMEwzOS4wNCw5Mi4yNkg5LjMyQzQuMjEsOTIuMjYsMCw4OC4wNywwLDgyLjk0VjkuMzJDMCw0LjE5LDQuMTksMCw5LjMyLDBMOS4zMiwweiIvPjxwYXRoIGNsYXNzPSJzdDEiIGQ9Ik02MS4yLDMwLjQyYzMuNTMtMy42OCw2LTYuMTcsMTEuNDMtNi43OWMxMC4yLTEuMTcsMjAuMjcsOS4yNywxNS4xMiwxOS41NmMtMS45LDMuNzktOC40OSwxMC4xNi0xMy43NiwxNS4xNSBjLTIuMDEsMS45LTMuODMsMy42MS01LjEyLDQuODlsLTcuNjYsNy42bC02LjMzLTYuMDljLTEuOTEtMS44My00LjE2LTMuNzktNi40Ni01Ljg3QzQxLjUsNTIuNjQsMzQuMDUsNDUuMywzMy43NCwzNi43MyBjLTAuMjktOC4wMSw2LjcyLTEzLjE1LDE0LTEzLjA2QzU0LjIsMjMuNzYsNTYuOTIsMjYuMjUsNjEuMiwzMC40Mkw2MS4yLDMwLjQyeiIvPjwvZz48L3N2Zz4=
// @grant        none
// @license MIT

// ==/UserScript==

(function() {
    'use strict';

    // Create the floating button
    const floatButton = document.createElement('button');
    floatButton.innerText = 'Like Automator';
    Object.assign(floatButton.style, {
        position: 'fixed',
        bottom: '20px',
        right: '20px',
        zIndex: '9999',
        padding: '10px',
        backgroundColor: '#007bff',
        color: '#fff',
        border: 'none',
        borderRadius: '5px',
        cursor: 'pointer'
    });

    document.body.appendChild(floatButton);

    // Function to get a random delay between 300ms and 1000ms
    function getRandomDelay() {
        return Math.floor(Math.random() * (1000 - 300 + 1)) + 300;
    }

    // Add click event listener
    floatButton.addEventListener('click', function() {
    // Scroll down to the location of the button (+10 pixels)
    const buttonPosition = floatButton.getBoundingClientRect().top + window.pageYOffset;
    window.scrollTo({
        top: buttonPosition + 10,
        behavior: 'smooth'
    });

    const buttons = document.querySelectorAll('[data-testid="like"]');
    let totalDelay = 0;
    let clickedCount = 0;

    for (let i = 1; i < 50 && i < buttons.length; i++) {
        let delay = getRandomDelay();
        totalDelay += delay;

        setTimeout(function() {
            buttons[i].click();
            clickedCount++;
        }, totalDelay);
    }

    // Output a div at the bottom showing how many were clicked
    setTimeout(function() {
        // Create the div element
        const messageDiv = document.createElement('div');
        messageDiv.textContent = `${clickedCount} buttons were clicked`;
        messageDiv.style.position = 'fixed';
        messageDiv.style.bottom = '10px';
        messageDiv.style.left = '50%';
        messageDiv.style.transform = 'translateX(-50%)';
        messageDiv.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';
        messageDiv.style.color = '#fff';
        messageDiv.style.padding = '10px 20px';
        messageDiv.style.borderRadius = '5px';
        messageDiv.style.fontSize = '16px';
        messageDiv.style.zIndex = '1000';

        // Append the div to the body
        document.body.appendChild(messageDiv);

        // Remove the div after 3 seconds
        setTimeout(function() {
            messageDiv.remove();
        }, 3000);
    }, totalDelay + 500);
});



})();