YouTube Annotation Ripper

Appends the each annotation text to a textbox box below the video for easy copying.

目前为 2014-08-06 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name YouTube Annotation Ripper
  3. // @namespace D.D.
  4. // @version 1.0
  5. // @description Appends the each annotation text to a textbox box below the video for easy copying.
  6. // @include *youtube.*/watch?v=*
  7. // @copyright 2014+, RGSoftware
  8. // @run-at document-body
  9. // @author R.F Geraci
  10. // @grant GM_notification
  11. // @icon64 http://icons.iconarchive.com/icons/simekonelove/modern-web/64/youtube-icon.png
  12. // ==/UserScript==
  13.  
  14. var apParent, Anno, cDiv,i, txtbox, Interval,
  15. TextboxWidth, TextboxHeight, TextboxMargin,
  16. TextboxResize, TextboxBorder, TextboxOutline,
  17. InitialMsg, TextboxReadOnly, CompletedAnnotationNewClassName,
  18. MissingHTMLErrorMsg;
  19.  
  20. //=========================CUSTOM SETTINGS==========================================================
  21.  
  22. Interval = 1000;
  23. TextboxWidth = "839px";
  24. TextboxHeight = "75%";
  25. TextboxMargin = "10px";
  26. TextboxResize = "none";
  27. TextboxBorder = "none";
  28. TextboxOutline = "none";
  29. TextboxReadOnly = "true";
  30. InitialMsg = "̶̶̶̶̶̶̶̶̶═══════════════════════════ Any annotations from the video will show here as it plays ═══════════════════════════";
  31. MissingHTMLErrorMsg = "A YouTube element is missing or has been renamed. 'YouTube Annotation Grabber' code must be updated.";
  32. CompletedAnnotationNewClassName = "inner-done-text";
  33.  
  34. //===================================================================================================
  35.  
  36. function CreateElements(){
  37. apParent = document.getElementById('watch7-content');
  38. Anno = document.getElementsByClassName('inner-text');
  39. cDiv = document.createElement('div');
  40. cDiv.id = 'cDiv';
  41. cDiv.setAttribute('style', 'width: 100%; height: 100px; border-bottom: 1px solid #E6E6E6; border-top: 1px solid #E6E6E6;');
  42. apParent.insertBefore(cDiv, apParent.firstChild);
  43. txtbox = document.createElement('textarea');
  44. txtbox.id = 'cDivTxtBox';
  45. txtbox.innerHTML = InitialMsg;
  46. txtbox.setAttribute('readonly', TextboxReadOnly);
  47. txtbox.setAttribute('style', 'width: '+ TextboxWidth +';' + 'height: ' + TextboxHeight + ';' + 'margin: ' + TextboxMargin + ';'
  48. + 'resize: ' +TextboxResize + ';' + 'border: ' + TextboxBorder + ';' + 'outline: ' + TextboxOutline + ';'); //height:75px
  49. cDiv.appendChild(txtbox);
  50. }
  51.  
  52. function getAnno(){
  53. for (i=0; i<Anno.length; i++){
  54. if (Anno[i].innerHTML != ""){
  55. txtbox.value += "\n\n" + Anno[i].innerHTML;
  56. Anno[i].className = CompletedAnnotationNewClassName;
  57. }
  58. }
  59. }
  60.  
  61. function Tmsg(message, title){
  62. GM_notification(message, title);
  63. }
  64.  
  65. if (document.getElementById('watch7-content') == undefined){
  66. Tmsg(MissingHTMLErrorMsg, "YouTube Annotation Grabber Error");
  67. }else{
  68. CreateElements();
  69. window.setInterval(getAnno, Interval);
  70. }