Greasy Fork 还支持 简体中文。

Xiaomi Forum Hour Hack

Lorem Ipsum

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Xiaomi Forum Hour Hack
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Lorem Ipsum
// @author       alxdjo
// @match        http://en.miui.com/*
// @grant        none
//@require http://code.jquery.com/jquery-latest.js
// ==/UserScript==

(function() {

    'use strict';
    $(document).ready(function() {
        if(window.location.href =="http://en.miui.com/forum.php"){            
            setTimeout(function() {

                var hrefs = new Array();
                var elements = $("a[class='s xst']");
                elements.each(function() {
                    hrefs.push($(this).attr('href'));
                });
                var randomNumber = rand(0, hrefs.length - 1);
                var href = hrefs[randomNumber];
                window.location = "http://en.miui.com/"+href;

            }, 180000); //three minutes will elapse and then redirect to a random page            
        }
        else
        {
            setTimeout(function() {
                window.location = "http://en.miui.com/forum.php";
            }, 60000); //one minute will elapse and then redirect to a random page
        }
    });
})();


function rand(min, max) {
    var offset = min;
    var range = (max - min) + 1;

    var randomNumber = Math.floor( Math.random() * range) + offset;
    return randomNumber;
}