abot iirose

move iirose into console

目前為 2020-09-04 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         abot iirose
// @namespace    http://tampermonkey.net/
// @version      1.0.1
// @description  move iirose into console
// @author       crescawn
// @match        *://iirose.com/messages.html
// @match        *://iirose.com/
// @grant        GM_addValueChangeListener
// @grant        GM_setValue
// @grant        unsafeWindow
// ==/UserScript==

(function() {
    'use strict';

    class ABot {
        constructor() {};
        tui() {
            Probe.init.roomSplashHolder || Init.fullPanel(18),
                Objs.roomSplashHolder.function.enter(),
                void(Temporary.roomSplashInit ? (1 == Temporary.roomSplashInit ? (panelAnimate(50, 0, Temporary.initPanelSwitch[
                1], Objs[Temporary.initPanelSwitch[0]].This, Objs.roomSplashHolder.This), delete Temporary.initPanelSwitch) :
                                                 (panelAnimate(56, Probe.fullPanelNoAnimate = 1), Probe.fullPanelNoAnimate = 0), delete Temporary.roomSplashInit
                                                ) : panelAnimate(56, 1));
        };
        input(e, t) {
            Utils.service.moveinputDo(e, t);
        };
        send(e) {
            const ui = Utils.smallTools.uniqueID();
            socket.send(JSON.stringify({
                m: e,
                mc: inputcolorhex,
                i: ui
            }));
            return ui;
        };
        rcv(e) {
            e = e.split('<').reverse();
            for (let i in e) msg_pub(e[i].split('>'))
        };
        move(e) {
            if(Objs.mapHolder.Assets.roomNameJson[e])
                Objs.mapHolder.function.roomchanger(e);
            else{
                e = this.roomID(e);
                Objs.mapHolder.function.roomchanger((typeof(e)==typeof('')?e:e[0]).split('>')[0]);
            }
        };
        roomID(e) {
            e = e.split('_').reverse();
            for (let i in Objs.mapHolder.Assets.roomNameJson) {
                let t = true;
                let n = Objs.mapHolder.Assets.roomNameJson[i].split('_').reverse();
                for (let j in n) {
                    if (e[j] == n[j]) continue;
                    t = false;
                    break;
                }
                if (t) return i+'>'+Objs.mapHolder.Assets.roomNameJson[i];
            }
            let r = [];
            for (let i in Objs.mapHolder.Assets.roomNameJson) {
                let t = true;
                let n = Objs.mapHolder.Assets.roomNameJson[i].split('_').reverse();
                for (let j in e) {
                    if (n[j].indexOf(e[j]) != -1) continue;
                    t = false;
                    break;
                }
                if (t) r.push(i+'>'+Objs.mapHolder.Assets.roomNameJson[i]);
            }
            return r.length > 0 ? (r.length==1?r[0]:r) : this.roomID('社区');
        }
    }

    function msg_pub(e) {
        //console.log(e);
        let args = [''];
        //args[0] += '%c' + new Date('1599049013' * 1e3).toTimeString().substr(0, 8);
        //args[0] += ' [#' + e[10] + '#] \r\n';
        //args.push('color:gray');
        args[0] += '%c' + e[2] + '\r\n';
        args.push('color:' + ncolor[e[6]]);
        if (e[3][0] == "'") {
            args.push('color:gray');
            switch (e[3][1]) {
                case '0':
                    args[0] += '%c改变了状态: %c' + status[e[3][2]] + ' %c-> %c' + status[e[3][3]];
                    args.push('color:#933d4d');
                    args.push('color:gray');
                    args.push('color:#933d4d');
                    break;
                case '1':
                    args[0] += '%c进入了房间';
                    break;
                case '2':
                    args[0] += '%c移动到了 : %c' + Objs.mapHolder.Assets.roomNameJson[e[3].substr(2)] + '\r\n%c [_' + e[3].substr(2) +
                        '_] ';
                    args.push('color:#50a037');
                    args.push('color:gray');
                    break;
                case '3':
                    args[0] += '%c离开了';
                    break;
                case '5':
                    args[0] += '%c撤回了一条消息';
                    break;
                default:
                    args[0] += '%c' + e[3];
            }
        } else if (e[3].indexOf('m__4') == 0) {
            let m = e[3].substr(4).split('&gt;');
            args[0] += '%c点播' + mediacode[m[0][0]] + '\r\n标题 : %c' + htmlDecode(m[1]) + '%c\r\n作者 : %c' + htmlDecode(m[2]) + '\r\n%c来源 : ' +
                mediacode[m[0]];
            args.push('color:gray');
            args.push('color:black');
            args.push('color:gray');
            args.push('color:black');
            args.push('color:gray');
            //console.log(m);
        } else {
            args[0] += '%c' + htmlDecode(e[3]);
            args.push('color:black');
        }
        arrlog(args, new Date('1599049013' * 1e3).toTimeString().substr(0, 8) + ' [#' + e[10] + '#]');
    }

    function htmlDecode(e) {
        let temp = document.createElement("div");
        temp.innerHTML = e;
        return temp.innerText || temp.textContent;
    }

    function arrlog(a, c) {
        a = JSON.stringify(a);
        eval('\/\/' + c + '\r\n' + 'console.log(' + a.substr(1, a.length - 2) + ')');
    }
    const mediacode = {
        '@': '音乐',
        '@0': '网易云音乐',
        '@1': '虾米音乐',
        '@2': 'QQ音乐',
        '@3': '千千音乐',
        '@4': '酷狗音乐',
        '*': '视频',
        '*0': '爱奇艺',
        '*3': '哔哩哔哩'
    };
    const ncolor = [
        '#7b13f1', '#0755ff', '#e72fea', '#21d63f', '#b94518'
    ];
    const status = {
        'n': '无状态',
        '0': '会话中',
        '1': '忙碌中',
        '2': '离开中',
        '3': '就餐中',
        '4': '通话中',
        '5': '移动中',
        '6': '如厕中',
        '7': '沐浴中',
        '8': '睡觉中',
        '9': '上课中',
        'a': '作业中',
        'b': '游戏中',
        'c': '看剧中',
        'd': '挂机中',
        'e': '自闭中',
        'f': '请撩我'
    };
    function msginit(){
        let ab = new ABot();
        unsafeWindow.abot = ab;

        function rcvstarter() {
            if (Temporary._getcontents) {
                ab.t_getcontents = Temporary._getcontents;
                Temporary._getcontents = function(e, t) {
                    if (!t) {
                        ab.rcv(e);
                    }
                    ab.t_getcontents(e, t);
                }
            } else {
                setTimeout(rcvstarter, 20);
            }
        }
        rcvstarter();
        GM_setValue('abevent',null);
        GM_addValueChangeListener('abevent',(n,o,e,r)=>{
            if(r)GM_setValue('abevent',JSON.stringify(eval(e)));
            else GM_setValue('abevent',null);
        });
    }
    function maininit(){
        let ab = new Object();
        unsafeWindow.abot=ab;
        ab.send=e=>GM_setValue('abevent','abot.send('+JSON.stringify(e)+')');
        ab.move=e=>GM_setValue('abevent','abot.move('+JSON.stringify(e)+')');
        ab.roomID=e=>GM_setValue('abevent','abot.roomID('+JSON.stringify(e)+')');
        ab.input=e=>GM_setValue('abevent','abot.input('+JSON.stringify(e)+')');

        GM_addValueChangeListener('abevent',(n,o,e,r)=>{
            if(r&&e)console.log(JSON.parse(e));
        });
    }
    if(location.pathname == '/')maininit();
    else msginit();
    // Your code here...
})();