YouTube Annotation Ripper

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

当前为 2014-08-09 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         YouTube Annotation Ripper
// @namespace    http://www.diamonddownload.weebly.com
// @version      1.2.5
// @description  Appends each annotation text to a textbox box below the video for easy copying.
// @include      *youtube.*/watch?v=*
// @copyright    2014+, RGSoftware
// @run-at       document-body
// @author       R.F Geraci
// @grant        GM_notification
// @icon64       http://icons.iconarchive.com/icons/simekonelove/modern-web/64/youtube-icon.png
// ==/UserScript==

var apParent, Anno, cDiv,i, txtbox, Interval,
    TextboxWidth, TextboxHeight, TextboxMargin,
    TextboxResize, TextboxBorder, TextboxOutline,
    InitialMsg, TextboxReadOnly, CompletedAnnotationNewClassName,
    MissingHTMLErrorMsg, IdleButtonImage, ToggleButtonParent,
    ToggleButton, ButtonImage, Ton = false, ActiveButtonImage,
    HoverButtonImage, Shown = false;

//=========================CUSTOM SETTINGS==========================================================

Interval = 1000;
TextboxWidth = "839px";
TextboxHeight = "75%";
TextboxMargin = "10px";
TextboxResize = "none";
TextboxBorder = "none";
TextboxOutline = "none";
TextboxReadOnly = "true";
InitialMsg = "̶̶̶̶̶̶̶̶̶═══════════════════════════ Any annotations from the video will show here as it plays ═══════════════════════════";
MissingHTMLErrorMsg = "A YouTube element is missing or has been renamed. 'YouTube Annotation Grabber' code must be updated.";
CompletedAnnotationNewClassName = "inner-done-text";
IdleButtonImage = "https://i.imgur.com/e4QIe2b.png";
ActiveButtonImage = "https://i.imgur.com/1xqKemW.png";
HoverButtonImage = "https://i.imgur.com/VWqFE5l.png";

//===================================================================================================

//--------------------------------------
function CreateElements(){    
    apParent = document.getElementById('watch7-content');
    Anno = document.getElementsByClassName('inner-text');
    cDiv = document.createElement('div');
    cDiv.id = 'cDiv';
    cDiv.setAttribute('style', 'width: 100%; -webkit-transition: height 0.5s; height: 0px; border-bottom: 1px solid #E6E6E6;'); //border-top: 1px solid #E6E6E6; border-bottom: 1px solid #E6E6E6;
    apParent.insertBefore(cDiv, apParent.firstChild);
    
    txtbox = document.createElement('textarea');
    txtbox.id = 'cDivTxtBox';
    txtbox.innerHTML = InitialMsg;
    txtbox.setAttribute('readonly', TextboxReadOnly);
    txtbox.setAttribute('style', 'width: '+ TextboxWidth +';' + 'height: ' + TextboxHeight + ';' + 'margin: ' + TextboxMargin + ';'
                        + 'resize: ' +TextboxResize + ';' + 'border: ' + TextboxBorder + ';' + 'outline: ' + TextboxOutline + ';'); //height:75px
    cDiv.appendChild(txtbox);
    Shown = true;
}
//--------------------------------------
function getAnno(){
    
    for (i=0; i<Anno.length; i++){
        
        if (Anno[i].innerHTML != ""){
            txtbox.value += "\n\n" + Anno[i].innerHTML; 
            Anno[i].className = CompletedAnnotationNewClassName;
        }  
    }
}
//--------------------------------------
function CreateToggle(){
    
    ToggleButtonParent = document.getElementById('watch-like-dislike-buttons');
    ToggleButton = document.createElement('button');
    ToggleButton.id = 'ToggleAnno';
    ToggleButton.type = 'button';
    ToggleButton.innerHTML = '';
    ToggleButton.setAttribute('style', 'outline: none; -webkit-user-select: none;');
    ToggleButton.title = 'Enable/Disable Annotation Ripping';
    ToggleButtonParent.appendChild(ToggleButton);  
    
    ButtonImage = document.createElement('img');  
    ButtonImage.setAttribute("style", "width: 25px; position: relative; top: 8px; -webkit-user-select: none;");
    ButtonImage.alt = 'Toggle Annotation Ripping';
    ButtonImage.src = IdleButtonImage;
    ToggleButton.appendChild(ButtonImage);   
}
//--------------------------------------
function Tmsg(message, title){
    GM_notification(message, title);   
}
//--------------------------------------
if (document.getElementById('watch7-content') == undefined){
    Tmsg(MissingHTMLErrorMsg, "YouTube Annotation Grabber Error");
}else{  
    CreateToggle();
}
//--------------------------------------
function HideElements(){
    
    cDiv.style.height = "0px";
    //cDiv.style.display = "none";
}
//--------------------------------------
 if (!Shown){
        CreateElements();
     window.setInterval(getAnno, Interval); 
 }

ToggleButton.onclick= function(){
    Ton = !Ton;
    if (Ton){
  //removed the create elements here a added them to load. button is mereley a hider/shower.
         cDiv.style.height = "100px";                         
    }else{
        HideElements();
        ButtonImage.src = IdleButtonImage;
    }
};
//--------------------------------------
ToggleButton.onmousedown= function(){
    ButtonImage.src = ActiveButtonImage;
};
//--------------------------------------
ToggleButton.onmouseover = function(){
    ButtonImage.src = HoverButtonImage;
};
//--------------------------------------
ToggleButton.onmouseout = function(){
    
    if (Ton){
        ButtonImage.src = ActiveButtonImage;
    }else{
        ButtonImage.src = IdleButtonImage;
    }  
};
//--------------------------------------