Skip to content

Instantly share code, notes, and snippets.

@GwyndolynMarchant
Last active May 19, 2024 07:47
Show Gist options
  • Save GwyndolynMarchant/1c0803354bfd36cd1c36357b1f8e143c to your computer and use it in GitHub Desktop.
Save GwyndolynMarchant/1c0803354bfd36cd1c36357b1f8e143c to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Bandcamp Tags → Clipboard (for Mp3tag)
// @namespace http://shadenexus.com/
// @version 0.2
// @description Copy tags from a bandcamp album for pasting into Mp3tag. Click on the tags header.
// @author Gwyndolyn Marchant
// @match https://*.bandcamp.com/*/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=bandcamp.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
const tag_label = document.getElementsByClassName("tags-inline-label")[0];
function getTags() {
function capitalize(sentence) {
let words = []
for (const word of sentence.split(' ')) {
words.push(word[0].toUpperCase() + word.slice(1));
}
return words.join(' ');
}
let tags = [];
for (const e of document.getElementsByClassName("tag")) {
tags.push(capitalize(e.innerText));
}
let tstring = tags.join('\\\\');
console.log(tstring)
navigator.clipboard.writeText(tstring);
tag_label.innerText += "✔";
}
tag_label.addEventListener("click", getTags);
tag_label.innerText += " 📋";
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment