NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Gwent Opponent Profile Link // @namespace https://openuserjs.org/users/Sunajo // @version 0.1 // @description Creates links from opponent name in your Gwent Match History. // @author Sunajo // @match https://www.playgwent.com/*profile* // @icon https://www.google.com/s2/favicons?domain=playgwent.com // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; console.log("Gwent Opponent Profile Link - RUNNING"); // first check if there is a history list, if not return const history = document.querySelector("#history"); if (!history) { console.log("Gwent Opponent Profile Link - No history found!"); return; } const lang = location.pathname.split("/")[1] || "en"; // create function for links and then run it! const createLinks = function() { console.log("Gwent Opponent Profile Link - CREATING LINKS"); const allMatches = Array.from(document.getElementsByClassName("loss")).concat(Array.from(document.getElementsByClassName("win"))).concat(Array.from(document.getElementsByClassName("draw"))); if (!allMatches) { console.log("Gwent Opponent Profile Link - NO LIST FOUND"); } allMatches.forEach(function(elem) { if (elem.cells) { let opponentCellHtml = elem.cells && elem.cells[3].innerHTML; let opponentCellText = elem.cells && elem.cells[3].innerText; elem.cells[3].innerHTML = opponentCellHtml.replace(opponentCellText, '<a href="/' + lang + '/profile/' + opponentCellText + '">' + opponentCellText + '</a>'); } }); }; createLinks(); // add observer to keep track of when list is updated const observer = new MutationObserver(function(mutations_list) { console.log("Gwent Opponent Profile Link - LIST UPDATED"); createLinks(); }); observer.observe(document.querySelector("#history"), { subtree: false, childList: true }); })();