Almis / Addic7ed Autocomplete Search

// ==UserScript==
// @name         Addic7ed Autocomplete Search
// @namespace    https://openuserjs.org/users/Almis
// @version      0.0.1
// @description  Add autocomplete functionality to addic7ed search box.
// @author       Almis
// @encoding     utf-8
// @match        *.addic7ed.com/*
// @grant        none
// @license      MIT License
// ==/UserScript==

(function() {
    'use strict';
    // find quick search dropdown
    var quickSearch = document.getElementById('qsShow');
    // find search box
    var search = document.getElementById('search');
    // create empty datalist
    var datalist = document.createElement('datalist');
    datalist.id = 'shows-data-list';
    // fill datalist with a copy of quick search dropdown options
    for (var i = 0; i < quickSearch.options.length; i++)
    {
        // get current option
        var option = quickSearch.options[i];
        // clone option without text
        var dlOption = option.cloneNode();
        // replace value with text
        dlOption.value = option.text;
        // add the new option to the list
        datalist.appendChild(dlOption);
    }
    // insert the datalist after search box
    search.parentNode.insertBefore(datalist, search.nextSibling);
    // assign the datalist to searchbox
    search.setAttribute('list', 'shows-data-list');
})();