torec subfilter

Add a text box above the subtitle list which allow one to filter the list.

  1. // ==UserScript==
  2. // @id torec-subfilter
  3. // @name torec subfilter
  4. // @version 0.2
  5. // @author Rabin
  6. // @description Add a text box above the subtitle list which allow one to filter the list.
  7. // @include http://www.torec.net/sub.asp*
  8. // @require //code.jquery.com/jquery-1.10.2.js
  9. // @run-at document-end
  10. // @namespace https://greasyfork.org/users/706
  11. // ==/UserScript==
  12.  
  13. if(typeof $ == 'undefined'){ var $ = unsafeWindow.jQuery; }
  14.  
  15. $( "div[class='sub_dl']" ).prepend('<input id="subfilter" type="text"/>');
  16.  
  17. // new :<function> to for case insensitive filtering.
  18. $.expr[':'].Contains = function(a,i,m){ return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase())>=0; };
  19.  
  20. $(document).ready(function() {
  21.  
  22. $("#subfilter").change( function () {
  23. var filter = $(this).val() ;
  24. if (filter !== '') {
  25. $("#download_version").children().show();
  26. $("#download_version").find("option:not(:Contains("+filter+"))").hide();
  27. }
  28. else {
  29. $("#download_version").children().show();
  30. }
  31. }).keyup( function () {
  32. // fire the above change event after every letter
  33. $(this).change();
  34. });
  35.  
  36. });
  37.