您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds an 'Open Chat' button on trade pages that works with Chat 3.0 and Torn PDA
当前为
// ==UserScript== // @name Torn Trade Page Chat Button // @namespace https://www.torn.com/ // @version 1.1 // @description Adds an 'Open Chat' button on trade pages that works with Chat 3.0 and Torn PDA // @author KillerCleat [2842410] // @match https://www.torn.com/trade.php* // @match https://www.torn.com/pda.php* // @grant none // @license MIT // @locale en-US // ==/UserScript== /** * Notes & Requirements: * – Author: KillerCleat [2842410] * – Description: Injects an 'Open Chat' button into the Trade Log header on PC and PDA trade pages. * – Works with Torn Chat 3.0 (PC) and PDA chat interface. */ (function() { 'use strict'; /** Utility: Run callback when DOM is ready */ function onReady(fn) { if (document.readyState !== 'loading') { fn(); } else { document.addEventListener('DOMContentLoaded', fn); } } onReady(function() { // Determine if we're on PC trade or PDA trade page const isTradePC = location.pathname.includes('trade.php'); const isTradePDA = location.pathname.includes('pda.php') && /[?&](trade|Trade)/.test(location.search); if (!isTradePC && !isTradePDA) return; // Find header with 'Trade Log' const headings = document.querySelectorAll('div[role="heading"][aria-level="5"]'); let header = null; headings.forEach(h => { if (h.textContent.trim().startsWith('Trade Log')) { header = h; } }); if (!header) return; // Extract the trade partner's user ID const userLink = document.querySelector('a[href*="user.php?ID="]'); if (!userLink) return; const href = userLink.getAttribute('href'); const params = new URLSearchParams(href.split('?')[1]); const userId = params.get('ID'); if (!userId) return; // Create the 'Open Chat' button const btn = document.createElement('span'); btn.className = 'tt-open-chat'; btn.textContent = 'Open Chat'; btn.style.cursor = 'pointer'; btn.style.marginLeft = '10px'; btn.addEventListener('click', function() { let chatUrl; if (isTradePDA) { chatUrl = '/pda.php?chat=' + userId; } else { chatUrl = '/chat.php?user2=' + userId; } window.open(chatUrl, '_blank', 'width=400,height=600'); }); // Insert button, avoiding duplicates let container = header.querySelector('div'); if (!container) { container = document.createElement('div'); header.appendChild(container); } if (!container.querySelector('.tt-open-chat')) { container.appendChild(btn); } }); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址