Bandcamp Collapsable Shop

Bundles up all bandcamp purchase options under one collapsable

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         Bandcamp Collapsable Shop
// @namespace    https://github.com/lukalovre/BandcampCollapsableShop
// @version      1.0
// @description  Bundles up all bandcamp purchase options under one collapsable
// @author       Luka Lovre
// @match        https://*.bandcamp.com/*
// @grant       none
// @license MIT
// ==/UserScript==

window.self === window.top && window.siteroot && "https://bandcamp.com" == window.siteroot && (function() {

    let shopButton = document.createElement("button");
    shopButton.textContent = "Shop";
    shopButton.style.width = '50px';
    shopButton.style.height = '20px';
    shopButton.style.fontSize = '12px';
    shopButton.style.float = "right";

    // Default Bandcamp following button colors
    shopButton.style.background = '#619aa9';
    shopButton.style.color = '#fff';

    const hide = element => {
        element.style.display = 'none'
    }

    const show = element => {
        element.style.display = 'block'
    }

    const toggle = element => {
        // if the element is visible, hide it
        if (window.getComputedStyle(element).display !== 'none') {
            hide(element)
            return
        }

        show(element)
    }

    let shopSection = '.tralbumCommands';
    let shopButtonLocationParent = '#name-section h3';
    let shopButtonLocation = '#name-section h3 [itemprop="byArtist"]';

    shopButton.addEventListener("click", function() {
        let element = document.querySelector(shopSection);
        toggle(element);
    });

    document.querySelector(shopSection).style.display = "none";
    document.querySelector(shopButtonLocationParent).insertBefore(shopButton, document.querySelector(shopButtonLocation));
}());