Backpack.tf Button

Adds a button to view items on backpack.tf

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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://greasyfork.org/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);
})();