I currently have this code. This opens the YT search in a new tab when you click the middle-mouse button:
(function() {
'use strict';
var searchIcon = document.getElementById("search-icon-legacy");
if (searchIcon) {
searchIcon.addEventListener("mousedown", function(event) {
event.preventDefault();
var searchInput = document.getElementsByClassName("ytd-searchbox")[3].value.trim();
if (event.which === 2 && searchInput) {
window.open("https://www.youtube.com/results?search_query=" + encodeURIComponent(searchInput), "_blank");
}
});
}
})();
Picture
I’m now trying to focus the search suggestions by middle-clicking them, but I’m struggling because I don’t know how to bring them into focus like the search button, which is an element.
New contributor
Julius Esen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.