Skip to content

Instantly share code, notes, and snippets.

@Sejmou
Last active April 27, 2023 23:36
Show Gist options
  • Save Sejmou/2ebc01850ca072638ffc5be7f190e890 to your computer and use it in GitHub Desktop.
Save Sejmou/2ebc01850ca072638ffc5be7f190e890 to your computer and use it in GitHub Desktop.
Tampermonkey userscript for extracting lyrics from the Genius website
// ==UserScript==
// @name Genius Lyrics Copier
// @namespace genius-lyrics-copier
// @version 1
// @description Adds a button to copy lyrics from Genius website to clipboard
// @match https://genius.com/*
// @grant GM_setClipboard
// @noframes
// ==/UserScript==
(function() {
'use strict';
// Create the button element
const button = document.createElement('button');
button.innerHTML = 'Copy Lyrics';
button.style.position = 'fixed';
button.style.bottom = '10px';
button.style.right = '10px';
button.style.padding = '10px';
button.style.fontSize = '16px';
button.style.border = 'none';
button.style.backgroundColor = '#4CAF50';
button.style.color = 'white';
button.style.cursor = 'pointer';
button.style.zIndex = '99999';
button.id = 'lyric-copy-btn';
// Add the button to the body
document.body.appendChild(button);
// Add a click event listener to the button
button.addEventListener('click', function() {
const lyricsContainer = document.querySelector("[class^='Lyrics__Container']");
if (lyricsContainer) {
const text = lyricsContainer.innerText.trim();
GM_setClipboard(text);
} else {
console.log("No matching container found.");
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment