您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
tab
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.gf.qytechs.cn/scripts/538683/1603882/allie%20test.js
- Tabs.Chat = {
- tabOrder: 900,
- tabLabel: 'Chat',
- tabDisabled: false,
- myDiv: null,
- chatDiv: null,
- inputDiv: null,
- lastMessageCount: 0,
- pollInterval: null,
- init: function(div){
- var t = Tabs.Chat;
- t.myDiv = div;
- t.createMainDiv();
- t.applyCustomStyles();
- t.startPolling();
- t.debug('Chat tab initialized');
- },
- createMainDiv: function(){
- var t = Tabs.Chat;
- var m = '<DIV class=divHeader align=center>'+tx('CHAT')+'</div>';
- m += '<div id="pbChatContent" style="height:450px; max-height:450px; overflow-y:auto;"></div>';
- m += '<div id="pbChatInput" style="margin-top:10px;"></div>';
- t.myDiv.innerHTML = m;
- t.chatDiv = ById('pbChatContent');
- t.inputDiv = ById('pbChatInput');
- t.cloneGameChatInput();
- },
- applyCustomStyles: function(){
- var styleElement = document.createElement('style');
- styleElement.type = 'text/css';
- styleElement.innerHTML = `
- #pbChatContent .chat-message {
- display: flex;
- flex-direction: row-reverse;
- justify-content: flex-start;
- align-items: baseline;
- margin-bottom: 5px;
- text-align: right;
- }
- #pbChatContent .chat-time {
- margin-left: 5px;
- color: #888;
- font-size: 0.8em;
- }
- #pbChatContent .chat-user {
- margin-left: 5px;
- font-weight: bold;
- }
- #pbChatContent .chat-text {
- word-wrap: break-word;
- max-width: 80%;
- }
- `;
- document.head.appendChild(styleElement);
- },
- startPolling: function() {
- var t = Tabs.Chat;
- t.pollInterval = setInterval(function() {
- t.checkForNewMessages();
- }, 1000); // Check every second
- },
- checkForNewMessages: function() {
- var t = Tabs.Chat;
- var gameChatContainer = document.querySelector('#mod_comm_list1');
- if (gameChatContainer) {
- var messages = gameChatContainer.querySelectorAll('.chat-message');
- if (messages.length > t.lastMessageCount) {
- t.debug('New messages detected');
- for (var i = t.lastMessageCount; i < messages.length; i++) {
- var clonedMessage = messages[i].cloneNode(true);
- t.formatChatMessage(clonedMessage);
- t.chatDiv.appendChild(clonedMessage);
- }
- t.lastMessageCount = messages.length;
- t.chatDiv.scrollTop = t.chatDiv.scrollHeight;
- }
- } else {
- t.debug('Game chat container not found');
- }
- },
- cloneGameChatInput: function(){
- var t = Tabs.Chat;
- var gameChatInput = document.querySelector('#mod_comm_input');
- if (gameChatInput) {
- var inputClone = gameChatInput.cloneNode(true);
- t.inputDiv.appendChild(inputClone);
- var chatTextArea = t.inputDiv.querySelector('textarea');
- var sendButton = t.inputDiv.querySelector('button');
- if (chatTextArea && sendButton) {
- chatTextArea.addEventListener('keypress', function(e) {
- if (e.key === 'Enter' && !e.shiftKey) {
- e.preventDefault();
- t.sendChat();
- }
- });
- sendButton.addEventListener('click', function() {
- t.sendChat();
- });
- }
- } else {
- t.debug('Game chat input not found');
- }
- },
- formatChatMessage: function(messageElement) {
- var timeElement = messageElement.querySelector('.chat-time');
- var userElement = messageElement.querySelector('.chat-user');
- var textElement = messageElement.querySelector('.chat-text');
- if (timeElement) timeElement.textContent = '[' + timeElement.textContent + ']';
- if (userElement) userElement.textContent = userElement.textContent + ':';
- // Ensure elements are in the correct order
- if (textElement) messageElement.appendChild(textElement);
- if (userElement) messageElement.appendChild(userElement);
- if (timeElement) messageElement.appendChild(timeElement);
- },
- sendChat: function(){
- var t = Tabs.Chat;
- var chatTextArea = t.inputDiv.querySelector('textarea');
- var gameChatTextArea = document.querySelector('#mod_comm_input textarea');
- var gameSendButton = document.querySelector('#mod_comm_input button');
- if (chatTextArea && gameChatTextArea && gameSendButton) {
- var message = chatTextArea.value.trim();
- if (message !== '') {
- gameChatTextArea.value = message;
- gameSendButton.click();
- chatTextArea.value = '';
- t.debug('Chat message sent: ' + message);
- }
- } else {
- t.debug('Could not find necessary elements to send chat');
- }
- },
- debug: function(message) {
- console.log('Chat Tab Debug: ' + message);
- }
- };
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址