Search YouTube without interrupting the video, by loading the search results in the related video bar
< 脚本Youtube - Search While Watching Video的反馈
You forgot to remove the .autocomplete-suggestions
created by new window.autoComplete({...}
in createSearchBar()
function loadSearch() { // prevent double searchbar let playlistOrLiveSearchBar = document.querySelector('#suggestions-search.playlist-or-live'); if (playlistOrLiveSearchBar) { playlistOrLiveSearchBar.remove(); let autocomplete_suggestions = document.querySelector('.autocomplete-suggestions'); if(autocomplete_suggestions) autocomplete_suggestions.remove(); } let searchbar = document.getElementById('suggestions-search'); if (!searchbar) { createSearchBar(); } else { searchbar.value = ""; } script.searched = false; cleanupSuggestionRequests(); }
Fixed and fixed
Fixed and fixed
Great.
I think having these few codes would be better.
- in searchSuggestions(...)
, async script is marked as async
and appended to head
instead of body
- in suggestionsCallback(...)
, cleanup the async script after loaded
- in loadSearch()
, remove the unneccessary div.autocomplete
This console.log(term);
shall be only for Debug mode.
- insearchSuggestions(...)
, async script is marked asasync
and appended tohead
instead ofbody
Dynamically inserted script elements are automatically executed as an async function.
I disagree with appending to the head. While it is also correct for me the head element is for scripts that need to block page loading.
- in suggestionsCallback(...)
, cleanup the async script after loaded
I clean them when I search, that's good enough. Removing elements from the dom also costs resources and not immediately cleaning them doesn't do any harm.
- inloadSearch()
, remove the unneccessarydiv.autocomplete
Mhm weird, I fixed that but don't see the changes anymore. Probably had 2 tabs of my script open or something. Fixed
Suggestion of Coding Change:




If the user types too fast, the result would be incorrect. (the searchvalue is 100ms before)
Here are the changes:
Obsolete Coding?
For your copy: