Plug.dj avatar ramdom

avatar

目前為 2017-05-21 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name       Plug.dj avatar ramdom
// @namespace  plugdj
// @version    1.051
// @description  avatar
// @match      https://plug.dj/*
// ==/UserScript==  
function randomAvatar() {
setTimeout(randomAvatar, 9000);
    // Script created by Unnoen of FiM | https://plug.dj/friendshipismagic
    // You may include this or variations in your own script but credit must be given.
    // <3
    var avatarSuccess,
    avatars;
    function getAvatars() {
        $.ajax({
            url : 'https://plug.dj/_/store/inventory/avatars',
            type : 'GET',
            contentType : 'application/json',
            success : function (data) {
                console.info("[Random Avatar] Got Avatars!");
                avatarSuccess = true;
                avatars = data.data;
            }
        });
    };
    function randomFromArray(array) {
        return array[Math.floor(Math.random() * array.length)];
    };
    function changeAvatar(avid) {
        var dataSend = {
            "id" : avid
        };
        $.ajax({
            url : 'https://plug.dj/_/users/avatar',
            type : 'PUT',
            contentType : 'application/json',
            data : JSON.stringify(dataSend),
            success : function (data) {
                console.info("[Random Avatar] Avatar Changed to " + avid);
            }
        });
    };
    setInterval(function () {
        if (!!avatarSuccess) {
            changeAvatar(randomFromArray(avatars).id);
        };
    }, 600000);
    getAvatars();
};
randomAvatar();