Last active
January 31, 2024 19:35
-
-
Save JonnyWong16/1ebd38a5f5872408e5b840ed28006dec to your computer and use it in GitHub Desktop.
Open the Plex search page when pressing enter in the search box.
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 Open Plex Serach Page on Enter | |
// @namespace https://app.plex.tv | |
// @version 1.1 | |
// @description Open the Plex search page when pressing enter in the search box. | |
// @author JonnyWong16 | |
// @homepage https://gist.github.com/JonnyWong16/1ebd38a5f5872408e5b840ed28006dec | |
// @downloadURL https://gist.github.com/JonnyWong16/1ebd38a5f5872408e5b840ed28006dec/raw/openPlexSearch.user.js | |
// @updateURL https://gist.github.com/JonnyWong16/1ebd38a5f5872408e5b840ed28006dec/raw/openPlexSearch.user.js | |
// @match https://app.plex.tv/* | |
// @grant none | |
// ==/UserScript== | |
window.addEventListener('load', function() { | |
const searchInput = document.getElementById('downshift-0-input'); | |
searchInput.addEventListener('keydown', (e) => { | |
if (e.key === 'Enter') { | |
e.preventDefault(); | |
window.location = 'https://app.plex.tv/desktop/#!/search?query=' + encodeURIComponent(searchInput.value); | |
searchInput.blur(); | |
} | |
}); | |
}, false); |
Did some troubleshooting. If I paste your code from line 15 to line 22 into the console, everything works fine. If I include line 14 and 23 (i.e. the window.addEventListener stuff), it doesn't work.
If I put the code into Tampermonkey, it doesn't work no matter if I include line 14 and 23 or not.
The Tampermonkey icon in Chrome says it is enabled and that your script is active on the Plex page.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My thanks for writing this!
Trying to get this to work, since the new Plex search is just horrible. But installing this in Tampermonkey doesn't change anything. Looking at the eventlisteners in Chrome developer tools doesn't list this one.
The code looks fine to my untrained Javascript eye, but apparently something is breaking it. Any ides on where to start looking?
Regards
/P