TECHDOG 1-7 Re-numbering

a script to show techdog tracks like 1-1, 2-7, 6-11 on bandcamp

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         TECHDOG 1-7 Re-numbering
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  a script to show techdog tracks like 1-1, 2-7, 6-11 on bandcamp
// @author       CiNoP
// @license      MIT
// @match        https://patriciataxxon.bandcamp.com/album/techdog-1-7
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function renumber() {
        const tracks = document.querySelectorAll('.track_number');
        tracks.forEach((div, index) => {
            const globalNum = index + 1;
            const n = Math.ceil(globalNum / 11);
            const localNum = globalNum - 11 * (n - 1);
            const newText = `${n}-${localNum}.`;
            
            if (div.textContent !== newText) {
                div.textContent = newText;
                
                div.style.whiteSpace = 'nowrap';
                
                const parentCell = div.closest('.track-number-col');
                if (parentCell) {
                    parentCell.style.width = '45px';
                }
            }
        });
    }

    renumber();
    const observer = new MutationObserver(renumber);
    observer.observe(document.body, { childList: true, subtree: true });
})();