Zelluloza Dumper

Отображает текст книги в соседнем окне и в окне чтения с возможностью сохранения.

目前为 2016-04-15 提交的版本。查看 最新版本

// ==UserScript==
// @name         Zelluloza Dumper
// @version      0.1
// @description  Отображает текст книги в соседнем окне и в окне чтения с возможностью сохранения.
// @author       MadDAD
// @include  https://zelluloza.ru/books/*
// @namespace https://greasyfork.org/users/38856
// ==/UserScript==

function unprotect(text) 
{
	var pageHtml = null;
    if( document.location.hostname == "zelluloza.ru" )
    {
        if( document.getElementsByClassName("booklnk4"))
        {
            pageHtml =  "Автор: " + document.getElementsByClassName("txt")[4].text + '\n' ; 
            pageHtml += "Название : \"" + document.getElementsByClassName("booklnk4")[1].childNodes[0].innerHTML + '\"\n';
            pageHtml += "Фрагмент: " + document.getElementsByClassName("taglnk2")[0].text + '\n' ; 
        }
            
        
    var Z = chp[0].split(/\n/);

        for (var j in Z) {
            pageHtml += DS('',Z[j]) + "\n";
        }
    }
    
	text.innerHTML = '<TEXTAREA style="width:100%; height:100%" rows=30>' + pageHtml + '</TEXTAREA>';
	text.firstChild.select();
    
    var newWin = window.open('/', "_blank");

    newWin.onload = function() 
    {
        var body = newWin.document.body;
        body.innerHTML = "<pre>" + pageHtml + "</pre>";
    };

}

unsafeWindow.wait_for_text = function() 
{
	var text = document.getElementById("bookpgm"); // zelluloza.ru
	if( null == text ) {
		alert('No copyable text found!');
		return;
	}
	
	if( text.innerHTML.length > 100 ) {
		var button = document.createElement("BUTTON");
		button.innerHTML = 'Unprotect';
		button.title     = '...and piss off greedy crooks from litres';
		button.addEventListener('click', function(){unprotect(text)}, true);
		text.parentNode.insertBefore(button, text);
	} else
		window.setTimeout("wait_for_text()", 1000 );
}
window.setTimeout("wait_for_text()", 1000 );