您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
tab
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.gf.qytechs.cn/scripts/538683/1603824/allie%20test.js
- // Add this to your existing tabs
- Tabs.Chat = {
- tabOrder: 900,
- tabLabel: 'Chat',
- tabDisabled: false,
- myDiv: null,
- timer: null,
- chatMessages: [],
- lastFetchTime: 0,
- init: function(div){
- var t = Tabs.Chat;
- t.myDiv = div;
- t.createMainDiv();
- t.startFetchingChat();
- },
- createMainDiv: function(){
- var t = Tabs.Chat;
- var m = '<DIV class=divHeader align=center>'+tx('CHAT')+'</div>';
- m += '<div id="ChatContent" style="height:450px; max-height:450px; overflow-y:auto;">';
- m += '<table width="100%">';
- m += '<tr><td><INPUT id=btChatEnabled type=checkbox '+ (Options.ChatOptions.Enabled?' CHECKED':'') +'> '+tx('Enable Chat')+'</td>';
- m += '<td>'+tx('Refresh Interval')+': <INPUT id=btChatInterval type=text size=3 value="'+ Options.ChatOptions.Interval +'"> '+tx('seconds')+'</td></tr>';
- m += '</table>';
- m += '<div id="ChatMessages"></div>';
- m += '</div>';
- // Add chat input and send button
- m += '<div id="ChatInputArea" style="margin-top:10px;">';
- m += '<input type="text" id="ChatInput" style="width:80%;" placeholder="Type your message here...">';
- m += '<button id="ChatSendButton" style="width:18%; margin-left:2%;">Send</button>';
- m += '</div>';
- t.myDiv.innerHTML = m;
- ById('btChatEnabled').addEventListener('change', function(){
- Options.ChatOptions.Enabled = this.checked;
- saveOptions();
- t.toggleChat();
- }, false);
- ById('btChatInterval').addEventListener('change', function(){
- Options.ChatOptions.Interval = parseInt(this.value);
- saveOptions();
- t.restartTimer();
- }, false);
- // Add event listener for send button
- ById('ChatSendButton').addEventListener('click', t.sendChat, false);
- // Add event listener for Enter key in input field
- ById('ChatInput').addEventListener('keypress', function(e) {
- if (e.key === 'Enter') {
- t.sendChat();
- }
- }, false);
- t.toggleChat();
- },
- toggleChat: function(){
- var t = Tabs.Chat;
- if(Options.ChatOptions.Enabled){
- t.startFetchingChat();
- } else {
- t.stopFetchingChat();
- }
- },
- startFetchingChat: function(){
- var t = Tabs.Chat;
- if(t.timer == null){
- t.timer = setInterval(t.fetchChat, Options.ChatOptions.Interval * 1000);
- t.fetchChat(); // Fetch immediately
- }
- },
- stopFetchingChat: function(){
- var t = Tabs.Chat;
- if(t.timer != null){
- clearInterval(t.timer);
- t.timer = null;
- }
- },
- restartTimer: function(){
- var t = Tabs.Chat;
- t.stopFetchingChat();
- t.startFetchingChat();
- },
- fetchChat: function(){
- var t = Tabs.Chat;
- var url = 'https://rycamelot.com/fb/e2/src/ajax/getChat.php';
- GM_xmlhttpRequest({
- method: 'GET',
- url: url,
- onload: function(response) {
- if (response.status === 200) {
- t.processChat(response.responseText);
- } else {
- console.error('Failed to fetch chat:', response.status, response.statusText);
- }
- },
- onerror: function(error) {
- console.error('Error fetching chat:', error);
- }
- });
- },
- processChat: function(responseText){
- var t = Tabs.Chat;
- var chatData;
- try {
- chatData = JSON.parse(responseText);
- } catch (e) {
- console.error('Error parsing chat data:', e);
- return;
- }
- // Assuming the chat data is an array of messages
- chatData.forEach(function(message) {
- if (message.time > t.lastFetchTime) {
- t.chatMessages.push(message);
- t.lastFetchTime = message.time;
- }
- });
- // Keep only the last 100 messages
- if (t.chatMessages.length > 100) {
- t.chatMessages = t.chatMessages.slice(-100);
- }
- t.displayChat();
- },
- displayChat: function(){
- var t = Tabs.Chat;
- var chatDiv = ById('ChatMessages');
- var html = '';
- t.chatMessages.forEach(function(message) {
- html += '<div class="chatMessage">';
- html += '<span class="chatTime">[' + new Date(message.time * 1000).toLocaleTimeString() + ']</span> ';
- html += '<span class="chatUser">' + message.user + ':</span> ';
- html += '<span class="chatText">' + message.text + '</span>';
- html += '</div>';
- });
- chatDiv.innerHTML = html;
- t.scrollToBottom();
- },
- scrollToBottom: function() {
- var chatDiv = ById('ChatMessages');
- chatDiv.scrollTop = chatDiv.scrollHeight;
- },
- sendChat: function() {
- var t = Tabs.Chat;
- var chatInput = ById('ChatInput');
- var message = chatInput.value.trim();
- if (message === '') return; // Don't send empty messages
- var url = 'https://rycamelot.com/fb/e2/src/ajax/sendChat.php'; // You'll need to confirm the correct URL
- GM_xmlhttpRequest({
- method: 'POST',
- url: url,
- data: 'message=' + encodeURIComponent(message),
- headers: {
- 'Content-Type': 'application/x-www-form-urlencoded'
- },
- onload: function(response) {
- if (response.status === 200) {
- // Message sent successfully
- chatInput.value = ''; // Clear input field
- t.fetchChat(); // Fetch latest messages including the one just sent
- } else {
- console.error('Failed to send chat:', response.status, response.statusText);
- }
- },
- onerror: function(error) {
- console.error('Error sending chat:', error);
- }
- });
- },
- };
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址