Last active
January 9, 2025 17:34
-
-
Save hjdarnel/a4d5f24dc7917dc85a407a24386c99b1 to your computer and use it in GitHub Desktop.
Add hotkeys to Letterboxd's film detail page, like W for toggle watchlist
This file contains 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 Letterboxd Search Hotkey | |
// @namespace hjdarnel | |
// @version 0.0.3 | |
// @description Press / anywhere on Letterboxd to search, W to toggle watchlist status | |
// @author Henry Darnell https://github.com/hjdarnel | |
// @match https://letterboxd.com/film/* | |
// @downloadURL https://gist.github.com/hjdarnel/a4d5f24dc7917dc85a407a24386c99b1/raw/letterboxd-film-hotkeys.user.js | |
// @updateURL https://gist.github.com/hjdarnel/a4d5f24dc7917dc85a407a24386c99b1/raw/letterboxd-film-hotkeys.user.js | |
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== | |
// @grant none | |
// ==/UserScript== | |
'use strict'; | |
const sleep = (ms) => new Promise(res => setTimeout(res, ms)); | |
document.addEventListener('keyup', async (event) => { | |
switch (event.code) { | |
case 'KeyW': { | |
const removeEl = document.querySelector('a.remove-from-watchlist'); | |
const addEl = document.querySelector('a.add-to-watchlist'); | |
if (removeEl && !removeEl.parentElement.classList.contains('hidden')) { | |
removeEl.click() | |
} else if (addEl && !addEl.parentElement.classList.contains('hidden')) { | |
addEl.click() | |
} | |
break; | |
} | |
}; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment