// ==UserScript== // @name Trade History Button // @namespace http://tampermonkey.net/ // @version 1.1 // @description Adds a button that redirects you to previous trades with the user // @author You // @match https://www.chickensmoothie.com/trades/edittrade.php?* // @icon https://www.google.com/s2/favicons?sz=64&domain=chickensmoothie.com // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; // Get all elements with the class "header" const headers = document.getElementsByClassName("header"); // Ensure there are at least 2 headers if (headers.length < 2) { console.error("Not enough headers found."); return; } // Use header[1] if there are 3 headers, otherwise use header[0] const targetHeader = (headers.length === 3) ? headers[1] : headers[0]; const p = targetHeader.innerText; // Extract the username const x = p.slice(22, -1); // Encode the username to handle special characters like '+' const encodedUsername = encodeURIComponent(x); // Create the trade link const tradeLink = "https://www.chickensmoothie.com/trades/tradingcenter.php?partner=" + encodedUsername; // Create a button var btn = document.createElement("button"); btn.innerHTML = "Trade History"; btn.onclick = () => window.open(tradeLink); // Append the button at the end of the target header targetHeader.appendChild(btn); })();