I modified this script to work with the new fictionbook website. I hope this is useful to others.
// ==UserScript==
// @name litres_capture
// @description Capture 'copy-protected HTML' from litres-related online libraries - fictiobook/aldebaran/litportal/fenzin.
// @include http://www.fictionbook.ru/*/read_online.html*
// @include http://www.litportal.ru/genre*/author*/read/*
// @include http://lib.aldebaran.ru/author/*/*/*.html
// @include http://www.fenzin.org/online/*
// ==/UserScript==
function unprotect(text)
{
var pageHtml = null;
if( document.location.hostname == "www.fictionbook.ru" )
{// FictionBook: move havigation bar from text to parent
pageHtml = text.firstChild.firstChild.innerHTML;
}
if( document.location.hostname == "lib.aldebaran.ru" )
{// Aldebaran: move havigation bar from text to parent
var innerDiv = text.firstChild;
text.parentNode.insertBefore(innerDiv.firstChild, text);
innerDiv.removeChild(innerDiv.firstChild);
innerDiv.removeChild(innerDiv.lastChild);
pageHtml = innerDiv.innerHTML;
}
if( !pageHtml ) pageHtml = text.innerHTML;
if( document.location.hostname == "www.fictionbook.ru" )
{// FictionBook uses "
+nbsp" to format text. replace them by
-s - it's more PDA-friendly
pageHtml = pageHtml.replace(new RegExp('
( ){3,}','gi'), '
');
}
pageHtml = pageHtml.replace(new RegExp('[^<]*','gi'), '');
pageHtml = pageHtml.replace(new RegExp('xmlns:xlink="http://www.w3.org/1999/xlink"','gi'), '');
pageHtml = pageHtml.replace(new RegExp('xmlns:fb="http://www.gribuser.ru/xml/fictionbook/2.0"','gi'), '');
pageHtml = pageHtml.replace(new RegExp('','gi'), '');
pageHtml = pageHtml.replace(new RegExp(' ','gi'), ' ');
pageHtml = pageHtml.replace(new RegExp('[ \t][ \t]+','gi'), ' ');
pageHtml = pageHtml.replace(new RegExp('<(h[1-6]|div|p)','gi'), '\n<$1');
pageHtml = pageHtml.replace(new RegExp('[ \t]*align="justify"','gi'), '');
// fictionbook sometimes uses an image of a period instead of an actual period. Why? I don't know why.
pageHtml = pageHtml.replace(new RegExp('
]*>', 'gi'), '.');
pageHtml = '\n' + pageHtml;
//alert(pageHtml);
text.innerHTML = '';
text.firstChild.select();
}
unsafeWindow.wait_for_text = function()
{
var text = document.getElementById("onlineread"); // fictionbook.ru
if( null == text ) text = document.getElementById("chid"); // fenzin.ru/aldebaran.ru
if( null == text ) text = document.getElementById("page_text"); //litportal.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 );