Created
November 27, 2017 12:10
-
-
Save Perlence/315de1088c5fab4917177b5a0ae1fb68 to your computer and use it in GitHub Desktop.
Clear search bar on submit
This file contains hidden or 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
(function () { | |
function initSearchTextRemover () { | |
let searchbar = window.document.getElementById('searchbar'); | |
if (!searchbar) return; | |
patchSearchbar(searchbar); | |
} | |
function patchSearchbar (searchbar) { | |
if (searchbar.__patched__) return; | |
let origDoSearch = searchbar.doSearch; | |
searchbar.doSearch = function () { | |
origDoSearch.apply(searchbar, arguments); | |
searchbar.value = ''; | |
}; | |
searchbar.__patched__ = true; | |
} | |
initSearchTextRemover(); | |
window.addEventListener('aftercustomization', initSearchTextRemover, false); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment