微博疯狂发垃圾微博

测试学习如何用油猴发微博

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         微博疯狂发垃圾微博
// @namespace    http://tampermonkey.net/
// @version      0.02
// @description  测试学习如何用油猴发微博
// @author       zjsxwc
// @match        https://weibo.com/*
// @grant        none
// @require      http://code.jquery.com/jquery-latest.js
// @icon         https://weibo.com/favicon.ico
// ==/UserScript==

(function () {
	console.log("jquery ready");
    repeatChar = function (char, times) {
        var result = "";
        for (var i = 0; i< times; i++) {
            result += char;
        }
        return result;
    }
    send = function send(){
        var btn1 = $('[action-data="title=有什么新鲜事想告诉大家?"]')[0];
        console.log(btn1);
        if (!btn1) {
            return;
        }
        btn1.click();

        setTimeout(function(){
            var text = $('[node-type="textEl"]')[0];
            console.log(text);
            if (!text) {
                return;
            }

            text.value = repeatChar('我',1800) + Math.random();
            text.dispatchEvent(new Event('focus'));

            setTimeout(function(){
                var btn3 = $('[node-type="submit"]')[0];
                console.log(btn3);
                if (!btn3) {
                    return;
                }
                btn3.click();
                setTimeout(function(){location.reload();},500);
            },300);

        },300);

    }
    setInterval(send,1000);

})();