Skip to content

Instantly share code, notes, and snippets.

@JonnyWong16
Last active January 31, 2024 19:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonnyWong16/1ebd38a5f5872408e5b840ed28006dec to your computer and use it in GitHub Desktop.
Save JonnyWong16/1ebd38a5f5872408e5b840ed28006dec to your computer and use it in GitHub Desktop.
Open the Plex search page when pressing enter in the search box.
// ==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);
@pallemannen
Copy link

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

@pallemannen
Copy link

pallemannen commented Feb 23, 2022

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