Bandcamp Collapsable Shop

Bundles up all bandcamp purchase options under one collapsable

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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