Retwitter

Auto follow script for Twitter (Made for secretnoye casino)

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==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();
})();