Retwitter

Auto follow script for Twitter (Made for secretnoye casino)

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Retwitter
// @description  Auto follow script for Twitter (Made for secretnoye casino)
// @version      0.0.2
// @author       Deps
// @match https://twitter.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=twitter.com
// @grant        none
// @namespace https://greasyfork.org/users/791270
// ==/UserScript==

(function() {
  'use strict';

  let enabled = false;
  let followCount = 0;
  let intervalId;
  let quietMode = false;

  const panelHtml = `
    <div style="position: fixed; bottom: 50px; right: 50px; z-index: 9999; background: white; padding: 10px; border-radius: 5px; box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5);">
      <div style="display: flex; justify-content: space-between; align-items: center;">
        <div>
          <span style="font-weight: bold;">Retwitter</span>
          <span>Following: <span id="follow-count">${followCount}</span></span>
        </div>
        <div>
          <label style="display: inline-flex; align-items: center;">
            <input type="checkbox" id="enable-checkbox" ${enabled ? 'checked' : ''} style="margin-right: 5px;">
            <span>Enabled</span>
          </label>
          <button id="close-button" style="border: none; background: none; font-size: 20px; cursor: pointer;">&times;</button>
        </div>
      </div>
    </div>
  `;

  function clickFollowButtons() {
    if (!quietMode) {
      const followButtons = document.querySelectorAll('div[aria-label^="Follow"] span span');
      followButtons.forEach((button) => {
        if (button.textContent === 'Follow') {
          button.click();
          followCount++;
          document.querySelector('#follow-count').textContent = followCount;
          handleFollowLimit();
        }
      });
    } else if (quietMode) {
      const followButtons = document.querySelectorAll('div[aria-label^="Follow"] span span');
      followButtons.forEach((button) => {
        if (button.textContent === 'Follow') {
          button.click();
          handleFollowLimit();
         }
      });
    }
  }

    function toggleScript() {
        enabled = !enabled;
        document.querySelector('#enable-checkbox').checked = enabled;
        if (enabled) {
            intervalId = setInterval(clickFollowButtons, 5000);
            clickFollowButtons()
        } else {
            clearInterval(intervalId);
        }
    }

    function createPanel() {
        const panel = document.createElement('div');
        panel.innerHTML = panelHtml;
        document.body.appendChild(panel);

        document.querySelector('#enable-checkbox').addEventListener('change', toggleScript);
        document.querySelector('#close-button').addEventListener('click', () => {
            panel.style.display = 'none';
        });
    }

    function handleFollowLimit() {
        let consecutiveFailures = 0;
        const checkInterval = setInterval(() => {
            const errorBanner = document.querySelector('div[aria-label^="You are unable to follow more people at this time."] span span');
            if (errorBanner) {
                clearInterval(checkInterval);
                quietMode = true;
                document.querySelector('#follow-count').textContent = followCount + ' (quiet mode)';
                setInterval(clickFollowButtons, 180000);
            } else if (consecutiveFailures >= 3) {
                clearInterval(checkInterval);
                quietMode = true;
                document.querySelector('#follow-count').textContent = followCount + ' (quiet mode)';
                setInterval(clickFollowButtons, 180000);
            }
            else {
                fetch('/i/api/1.1/friendships/create.json', {method: 'POST'})
                    .then(response => {
                    if (!response.ok) {
                        consecutiveFailures++;
                    } else {
                        consecutiveFailures = 0;
                    }
                });
            }
        }, 1000);
    }


    function init() {
        createPanel();
    }

    init();
})();