Twitter Unfollower

Automatic Twitter unfollower tool. Last Update: 11-22-2014

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Twitter Unfollower
// @version      0.5
// @description  Automatic Twitter unfollower tool. Last Update: 11-22-2014
// @author       [email protected]
// @namespace    https://greasyfork.org/en/users/6473-ekin
// @match        https://twitter.com/following
// @grant        none
// ==/UserScript==

window.onload = function () {
    
    var config = {
        loadingTime: 1000,
        intervalTime: 2000,
        debug: true
    };
    
    $(".UserActions-editButton").before('<button type="button" id="unfollowBtn" class="edit-button btn"><span class="button-text unfollow-text">Start Unfollowing</span></button> ');
    
    function unfollowAll() {
        log("Clicked unfollow buttons.");
        $(".user-actions").each(function() {
            if (/not-following/i.test($(this).attr("class")) == false) {
                $(this).children(".follow-button").trigger("click");
            }
        });
    }
    
    function unfollowInit() {
        setInterval(function() {
            if ($(window).scrollTop() + $(window).height() == $(document).height() == false) {
                unfollowAll();
                setTimeout(function() {
                    log("Go scroll bottom.");
                    $("html, body").animate({ scrollTop: $(document).height() }, 500);
                }, config.loadingTime);
            }
        }, config.intervalTime);
    }
    
    $("#unfollowBtn").click(function() {
        log("Clicked start button.");
        unfollowInit();
    });
    
    function log(text) {
        delete console.log;
        if (config.debug) {
            console.log(Date() + ": " + text + "\n"); 
        }
    }
    
    log("Twitter Unfollower is ready.");
    
};