YouTube Annotation Ripper

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

目前為 2014-08-08 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         YouTube Annotation Ripper
// @namespace    http://www.diamonddownload.weebly.com
// @version      1.2
// @description  Appends the 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 = "http://i.imgur.com/e4QIe2b.png";
ActiveButtonImage = "http://i.imgur.com/1xqKemW.png";
HoverButtonImage = "http://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;
    }  
};
//--------------------------------------