NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name /r/magicarena tooltips
// @namespace Violentmonkey Scripts
// @match https://www.reddit.com/r/MagicArena/comments/*
// @grant none
// @require https://deckbox.org/assets/external/tooltip.js
// @license MIT
// ==/UserScript==
var regex = /\[\[.*?\]\]/gm;
var comments = document.getElementsByClassName('usertext-body');
for (i=0; i < comments.length; i++) {
if (comments[i].innerHTML.match(regex) == null) { continue; }
if (comments[i].innerHTML.includes("[[cardname]]")) { continue; } // Filter out MTGCardFetcher
comments[i].innerHTML.match(regex).forEach(function(card) {
var cleanName = card.substring(2, card.length - 2); // Removes [[ ]]
var encodeCleanName = encodeURIComponent(cleanName); // Not sure if this is necessary
var url = `<a href="https://deckbox.org/mtg/${encodeCleanName}">${cleanName}</a>`
comments[i].innerHTML = comments[i].innerHTML.replace(card, url)
});
}