Backpack.tf Button

Adds a button to view items on backpack.tf

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Backpack.tf Button
// @version      v1
// @description  Adds a button to view items on backpack.tf
// @author       LilLovebird
// @match        https://loadout.tf/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=loadout.tf
// @namespace https://greatest.deepsurf.us/users/1468615
// ==/UserScript==

(function() {
    'use strict';

    Element.prototype._attachShadow = Element.prototype.attachShadow;
    Element.prototype.attachShadow = function () {
        return this._attachShadow( { mode: "open" } );
    };

    setTimeout(function() {
        setInterval(function () {
            document.querySelectorAll("div")[1].shadowRoot.querySelector("div").shadowRoot.querySelector("div").shadowRoot.querySelectorAll("div.item-manager-item-detail").forEach((element) => {
                if (!element.innerHTML.includes("backpack.tf")) {
                    let button = document.createElement("a");
                    button.className = "item-manager-item-detail-backpack-link capitalize";
                    button.href = "https://next.backpack.tf/stats?item=" + element.querySelector("div.item-manager-item-detail-title").textContent;
                    button.target = "_blank";
                    button.textContent = "Backpack.tf";
                    element.insertBefore(button, element.lastElementChild);
                }
            });
        }, 0);
    }, 1000);
})();