Last active
March 12, 2025 19:49
-
-
Save nightpool/e693dd64f0558bc217e2b232501ff5b5 to your computer and use it in GitHub Desktop.
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 Command+Enter for Genius Lyrics | |
// @namespace http://genius.com/nightpool | |
// @version 2025-03-12 | |
// @downloadURL https://gist.github.com/nightpool/e693dd64f0558bc217e2b232501ff5b5/raw/genius_lyrics_shortcut.user.js | |
// @description Adds ⌘Enter and ctrl-Enter shortcuts to the Genius lyrics edit form | |
// @author https://genius.com/nightpool | |
// @match https://genius.com/* | |
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== | |
// @grant none | |
// ==/UserScript== | |
(async function() { | |
'use strict'; | |
const {default: Mousetrap} = await import('https://esm.sh/[email protected]'); | |
Mousetrap.prototype.stopCallback = () => false; | |
Mousetrap.bind(['ctrl+enter', 'command+enter'], (event) => { | |
const lyricsForm = document.querySelector('[class*="LyricsEdit-desktop__Container"]'); | |
if (!lyricsForm) { | |
return; | |
} | |
const textareaCheck = lyricsForm.querySelector('textarea'); | |
if (!textareaCheck) { | |
return; | |
} | |
const saveAndExit = document.evaluate( | |
"//button[text()='Save & Exit']", | |
lyricsForm, | |
null, | |
XPathResult.ANY_UNORDERED_NODE_TYPE, | |
null | |
).singleNodeValue; | |
if (!saveAndExit) { | |
alert("No save button found!"); | |
} | |
saveAndExit.click(); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment