SGDB-Extension/script.js

30 lines
860 B
JavaScript

const url = window.location.href;
const appIDMatch = url.match(/\/app\/(\d+)/);
if(appIDMatch) {
const appID = appIDMatch[1];
const sgdb_button = document.createElement('a');
sgdb_button.href = `https://steamgriddb.com/steam/${appID}`;
sgdb_button.className = "btnv6_blue_hoverfade btn_medium";
const span = document.createElement('span');
span.setAttribute("data-tooltip-text", "View on SteamGridDB");
const icon = document.createElement("img");
icon.className = "ico16";
icon.src = browser.runtime.getURL("icons/sgdb_16.png");
icon.style.backgroundImage = "none";
span.append(icon);
sgdb_button.append(span);
const buttonContainer = document.querySelector(".apphub_OtherSiteInfo");
if(buttonContainer) {
sgdb_button.style.marginRight = "3px";
sgdb_button.style.marginLeft = "3px";
buttonContainer.prepend(sgdb_button);
}
}