Bandcamp Collapsable Shop

Bundles up all bandcamp purchase options under one collapsable

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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));
}());