Last active
December 17, 2025 17:28
-
-
Save ALERTua/caf678f694584be6e3e7071a54c3186b to your computer and use it in GitHub Desktop.
Rearranges elements in the trackInfoInner div on Bandcamp pages so the player comes first
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Bandcamp Element Rearranger | |
| // @namespace http://tampermonkey.net/ | |
| // @version 1.0 | |
| // @description Rearranges elements in the trackInfoInner div on Bandcamp pages so the player comes first | |
| // @homepage https://gist.github.com/ALERTua/caf678f694584be6e3e7071a54c3186b | |
| // @downloadURL https://gist.githubusercontent.com/ALERTua/caf678f694584be6e3e7071a54c3186b/raw | |
| // @updateURL https://gist.githubusercontent.com/ALERTua/caf678f694584be6e3e7071a54c3186b/raw | |
| // @author https://github.com/ALERTua | |
| // @match *://*.bandcamp.com/* | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| // Run the rearrangement function with the requested pattern | |
| function onLoad() { | |
| // Wait 1 second for other scripts | |
| setTimeout(function() { | |
| // Find the trackInfoInner element | |
| const trackInfoInner = document.getElementById('trackInfoInner'); | |
| if (!trackInfoInner) { | |
| console.log('trackInfoInner element not found'); | |
| return; | |
| } | |
| // Find and move elements in reverse order of your desired sequence | |
| // This ensures they end up in the correct order at position 0 | |
| // 4. Find and move tralbum-about (will be 4th in final order) | |
| const aboutElement = trackInfoInner.querySelector('div.tralbumData.tralbum-about'); | |
| if (aboutElement) { | |
| trackInfoInner.removeChild(aboutElement); | |
| trackInfoInner.insertBefore(aboutElement, trackInfoInner.firstChild); | |
| } | |
| // 3. Find and move tralbum-credits (will be 3rd in final order) | |
| const creditsElement = trackInfoInner.querySelector('div.tralbumData.tralbum-credits'); | |
| if (creditsElement) { | |
| trackInfoInner.removeChild(creditsElement); | |
| trackInfoInner.insertBefore(creditsElement, trackInfoInner.firstChild); | |
| } | |
| // 2. Find and move track_table (will be 2nd in final order) | |
| const trackTableElement = trackInfoInner.querySelector('table.track_list.track_table#track_table'); | |
| if (trackTableElement) { | |
| trackInfoInner.removeChild(trackTableElement); | |
| trackInfoInner.insertBefore(trackTableElement, trackInfoInner.firstChild); | |
| } | |
| // 1. Find and move inline_player (will be 1st in final order) | |
| const inlinePlayerElement = trackInfoInner.querySelector('div.inline_player'); | |
| if (inlinePlayerElement) { | |
| trackInfoInner.removeChild(inlinePlayerElement); | |
| trackInfoInner.insertBefore(inlinePlayerElement, trackInfoInner.firstChild); | |
| } | |
| console.log('Bandcamp elements rearranged successfully'); | |
| }, 1000); | |
| } | |
| if (document.readyState == 'complete') { | |
| onLoad(); | |
| } else { | |
| window.addEventListener("load", onLoad); | |
| } | |
| // Also run when DOM changes (for single page apps) | |
| const observer = new MutationObserver(function(mutations) { | |
| mutations.forEach(function(mutation) { | |
| if (mutation.addedNodes && mutation.addedNodes.length > 0) { | |
| // Check if any of the added nodes is our target container | |
| for (let i = 0; i < mutation.addedNodes.length; i++) { | |
| const node = mutation.addedNodes[i]; | |
| if (node.id === 'trackInfoInner' || node.querySelector('#trackInfoInner')) { | |
| setTimeout(onLoad, 500); | |
| break; | |
| } | |
| } | |
| } | |
| }); | |
| }); | |
| // Start observing the document with the configured parameters | |
| observer.observe(document.body, { | |
| childList: true, | |
| subtree: true | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment