Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* This script hides all language options except the searched ones on the Dailymotion video details editing page. This is necessary because the language selector is no conventional HTML-based selector but an inferior JavaScript-based alternative by "ant.design", which lacks searching by typing. Since one can not select a language by typing its name on the keyboard, one would have to inconveniently scroll through the 183 items-long list to find the language.
- This script can be used as a template for other sites that use the terrible ant.design selector.
- Instructions: Paste this script into a user script manager web browser extension such as "GreaseMonkey", "Custom Style Script", or "TamperMonkey", and add javascript:ant_select(); as a bookmarklet. If you wish to pre-select a language, put it inside the parenthesis, for example javascript:ant_select("German"); .
- */
- function ant_select(search_input) {
- if (!search_input) search_input = prompt("Search language:");
- if (!search_input) return false; // if field left blank or cancelled
- var search_language = search_input.toLowerCase(); // case-insensitive
- var ant_list_container = document.getElementsByClassName("ant-select-dropdown-menu")[0];
- var ant_list = ant_list_container.getElementsByTagName("li");
- // creating container that shows the entered search term
- if (! document.getElementsByTagName("ant_search_term")[0] ) {
- ant_list_container.insertBefore(
- document.createElement("ant_search_term"),ant_list[0]
- );
- }
- document.getElementsByTagName("ant_search_term")[0].innerHTML='Search results for "'+search_input+'"';
- // filtering out non-matches
- for (var count=0; count < ant_list.length; count++) {
- if (ant_list[count].innerHTML.toLowerCase().search(search_language) < 0 ) {
- ant_list[count].style.display="none";
- } else {
- ant_list[count].style.display="block";
- }
- }
- }
- /* originally written for use on Dailymotion; feel free to adapt to any other site that uses the garbage by ant.design */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement