burn / Dailymotion use keyboard on recent searches

// ==UserScript==
// @name         Dailymotion use keyboard on recent searches
// @namespace    https://openuserjs.org/users/burn
// @version      0.1.2
// @copyright    2019, burn (https://openuserjs.org//users/burn)
// @description  Lets you use arrow keys to navigate recent searches dropdown menu
// @author       Burn
// @match        https://www.dailymotion.com/*
// @license      MIT
// @run-at       document-end
// @include      https://www.dailymotion.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    var qS = function(el, scope) {
            scope = (typeof scope == 'object') ? scope : document;
            return scope.querySelector(el) || false;
        },
        qSall = function(els, scope) {
            scope = (typeof scope == 'object') ? scope : document;
            return scope.querySelectorAll(els) || false;
        },
        targetNode = qS('body'),
        observerConfig = {
            attributes: false,
            childList: true,
            subtree: true
        },
        searchEl = false,
        searchElFound = false,
        callback = function(mutationsList, observer) {
            mutationsList.forEach(function(mutation) {
                var entry = {
                    mutation: mutation,
                    el: mutation.target,
                    value: mutation.target.textContent,
                    oldValue: mutation.oldValue
                };
                searchEl = qS("#search", entry.el);
                if (false != searchEl && false == searchElFound) {
                    searchElFound = true;
                    var styleEl = document.createElement("style");
                    styleEl.innerText = ".highlight {background:linear-gradient(262deg,#00d2f3,#0af);color:#FFF;}";
                    targetNode.appendChild(styleEl);
                    searchEl.addEventListener("focus", function() {
                        var suggestions = qS(".RecentSearches__container___RT8SU"),
                            lis = qSall("li", suggestions),
                            currentIdx = 0;
                        if (suggestions == false) return;
                        searchEl.addEventListener("keyup", function(e) {
                            if (e.keyCode == 13) { // enter
                                var selectedLi = qS("li.highlight", suggestions);
                                if (selectedLi != false) selectedLi.click();
                            }
                            if (e.keyCode == 38) { // up
                                currentIdx--;
                                if (currentIdx < 1) currentIdx = lis.length;
                            }
                            if (e.keyCode == 40) { // down
                                currentIdx++;
                                if (currentIdx > lis.length) currentIdx = 1;
                            }
                            if (e.keyCode == 38 || e.keyCode == 40) {
                                lis.forEach(function(elm, idx) {
                                    elm.classList.remove("highlight");
                                });
                                qS("li:nth-child(" + currentIdx + ")", suggestions).classList.add("highlight");
                                currentIdx > 1 && (searchEl.value = qS("li:nth-child(" + currentIdx + ")", suggestions).innerText);
                            }
                        });
                    });
                }
            }) // end forEach
        };
    var observer = new MutationObserver(callback);
    observer.observe(targetNode, observerConfig);
})();