ZhChat增强脚本

增强功能:自动颜色,显示侧边栏识别码

目前为 2023-01-28 提交的版本。查看 最新版本

// ==UserScript==
// @name         ZhChat增强脚本
// @namespace    http://tampermonkey.net/
// @version      1.14.514
// @description  增强功能:自动颜色,显示侧边栏识别码
// @author       UbisoComes (GreenDebug)
// @match        https://chat.zhangsoft.cf/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=zhangsoft.cf
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {


    var _send=send;
    var isAutoColor=true;
    var randomHeads=[
    Get('head')
    ];
     function Get(key) {
	try {
		return window.localStorage[key]
	} catch (e) { }
}
    var isAutoHead=true;
    function color() {
            return `#${Math.floor(Math.random()*0xffffff).toString(16).padEnd(6,"0")}`;

        }
 function autocolor(){
  _send({cmd:"chat",text:`/color ${color()}`});
   }
    function AutoHead(){
        var arr=randomHeads;
        var index = Math.floor((Math.random()*arr.length));
        Get('head')=arr[index];
    }
    function doing(){
        if(isAutoColor){
        autocolor();
        }
    }

send=function(d){
    doing();
   _send(d);
}
userAdd=function(nick, trip) {
    var user = document.createElement('a');
    user.textContent = nick;

    user.onclick = function (e) {
        userInvite(nick)
    }

    var userLi = document.createElement('li');
    userLi.appendChild(user);

    if (trip) {
        let tripEl = document.createElement('span')
        tripEl.textContent = ' ' + trip
        tripEl.classList.add('trip')
        userLi.appendChild(tripEl)
    }
    $('#users').appendChild(userLi);
    onlineUsers.push(nick);
}
    var oset=function (args) {
        var nicks = args.nicks;
        var users=args.users;
        usersClear();

        nicks.forEach(function (user) {
            var trip="";
            users.forEach(function(u){
            if(u.nick==user){
                trip=u.trip;
            }
            });
            userAdd(user,trip);
        });

        pushMessage({ nick: '*', text: "在线的用户:" + nicks.join(", ") })
    };
var osetadd=function (args) {
        var nick = args.nick;

        userAdd(nick, args.trip);

        if ($('#joined-left').checked) {
            var joinNotice = nick + " 加入了聊天室"
            if (args.client){
                joinNotice += '\nTA正在使用 ' + args.client
            }
            if (args.auth){
                joinNotice += '\n系统认证:' + args.auth
            }
            pushMessage({ nick: '→', text: joinNotice, trip: args.trip || '' },'info');    //仿Discord
        }
    };
COMMANDS['onlineSet']=oset;
COMMANDS['onlineAdd']=osetadd;
    // Your code here...
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址