make youtube caption selectable

Use this script if you want be able to select youtube captions/subtitles! source: https://stackoverflow.com/questions/40165879/how-make-youtube-subtitles-selectable

  1. // ==UserScript==
  2. // @name make youtube caption selectable
  3. // @namespace none
  4. // @version 0.3
  5. // @description Use this script if you want be able to select youtube captions/subtitles! source: https://stackoverflow.com/questions/40165879/how-make-youtube-subtitles-selectable
  6. // @author ilya, edr1412
  7. // @match https://www.youtube.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. !function() {
  13. setInterval(make_subtitles_selectable, 750);
  14. function make_subtitles_selectable(){
  15. elem=document.querySelector("div.caption-window");
  16. if(elem!=null){
  17. elem.addEventListener("mousedown", function (event) {
  18. event.stopPropagation();
  19. }, true);
  20. elem.setAttribute("draggable", "false");
  21. elem.style.userSelect="text";
  22. /* For Safari */
  23. elem.style.WebkitUserSelect="text";
  24. elem.style.cursor="text";
  25. elem.setAttribute("selectable", "true");
  26. }
  27. elem=document.querySelector("span.ytp-caption-segment:not([selectable='true']");
  28. if(elem!=null){
  29. elem.style.userSelect="text";
  30. /* For Safari */
  31. elem.style.WebkitUserSelect="text";
  32. elem.style.cursor="text";
  33. elem.setAttribute("selectable", "true");
  34. }
  35. elem=document.querySelector("#caption-window-1:not([selectable='true']");
  36. if(elem!=null){
  37. elem.addEventListener("mousedown", function (event) {
  38. event.stopPropagation();
  39. }, true);
  40. elem.setAttribute("selectable", "true");
  41. elem.setAttribute("draggable", "false");
  42. }
  43. }
  44. }()