☰

Literotica Downloader Improved

Single page HTML download for Literotica with improved readability

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

Um dieses Skript zu installieren, müssen Sie eine Erweiterung wie Tampermonkey oder Violentmonkey installieren.

Um dieses Skript zu installieren, müssen Sie eine Erweiterung wie Tampermonkey oder Violentmonkey installieren.

Um dieses Skript zu installieren, müssen Sie eine Erweiterung wie Tampermonkey oder Userscripts installieren.

Um dieses Skript zu installieren, müssen Sie eine Erweiterung wie Tampermonkey installieren.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

Um dieses Design zu installieren, müssen Sie eine Erweiterung wie Stylus installieren.

Um dieses Design zu installieren, müssen Sie eine Erweiterung wie Stylus installieren.

Um dieses Design zu installieren, müssen Sie eine Erweiterung wie Stylus installieren.

Um diesen Stil zu installieren, müssen Sie eine Erweiterung für den Benutzerstil Verwaltung installieren.

Um diesen Stil zu installieren, müssen Sie eine Erweiterung für den Benutzerstil Verwaltung installieren.

Um diesen Stil zu installieren, müssen Sie eine Erweiterung für den Benutzerstil Verwaltung installieren.

(Ich habe bereits einen Benutzerstil Verwaltung, ich möchte ihn installieren!)

// ==UserScript==
// @name        Literotica Downloader Improved
// @description Single page HTML download for Literotica with improved readability
// @namespace   literotica_downloader
// @include     https://www.literotica.com/stories/memberpage.php*
// @require     https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @version     2.1
// @author      Improved by a random redditor, originally by Patrick Kolodziejczyk
// @grant       GM_addStyle
// ==/UserScript==

$(document).ready(function () {
  // Creating style for a download icon
  GM_addStyle('.icon-download {background-image: url("https://marcoceppi.github.io/bootstrap-glyphicons/img/glyphicons-halflings.png");     background-position: -120px -24px;cursor: pointer;cursor: hand;    background-repeat: no-repeat;    display: inline-block;    height: 14px;    line-height: 14px;    vertical-align: text-bottom;    width: 14px;}'
  );
  // Function used to return content as a file for the user.
  function saveTextAsFile(textToWrite, fileNameToSaveAs)
  {
    var textFileAsBlob = new Blob([textToWrite], {
      type: 'text/javascript'
    });
    var downloadLink = document.createElement('a');
    downloadLink.download = fileNameToSaveAs;
    downloadLink.innerHTML = 'Download File';
    if (window.webkitURL !== null)
    {
      // Chrome allows the link to be clicked
      // without actually adding it to the DOM.
      downloadLink.href = window.webkitURL.createObjectURL(textFileAsBlob);
    } 
    else
    {
      // Firefox requires the link to be added to the DOM
      // before it can be clicked.
      downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
      //downloadLink.onclick = destroyClickedElement;
      downloadLink.style.display = 'none';
      document.body.appendChild(downloadLink);
    }
    downloadLink.click();
  }
  // Function parsing all pages to get the storie based
  function getContentOfStoie(baseURL) {
    var remote;
    $.ajax({
      url: baseURL,
      type: 'GET',
      async: false,
      success: function (data) {
        if ($(data).find('.b-pager-next').size()) {
          remote = $(data).find('.b-story-body-x').html() + getContentOfStoie($(data).find('.b-pager-next') [0].href);
        } else {
          remote = $(data).find('.b-story-body-x').html();
        }
      }
    });
    return remote;
  }
  function getABookForSerieDiv(myDiv) {
    var title = $.trim(myDiv.text().split(':') [0]);
    var author = $('.contactheader').text();
    alert("Starting building file for "+title +" of "+author+".\nPlease wait...");
    var book = '<html>\n<head>\n<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">\n';
    book += '<title>' + title + '</title>';
    book += '<meta content="' + author + '" name="author">';
    book += '</head>\n<body style="background-color:#333333; color: #EEEEEE; font-family: Helvetica,Arial,sans-serif; width: 50%; margin: 0 auto; line-height: 1.5em; font-size:2.2em; padding: 50px 0 50px 0;">';
    function addChapter(element, index, array) {
      if ($(this).find('a').size() > 0) {
        var description = $($(this).find('td') [1]).text();
        book += '<h1 class=\'chapter\' style="line-height: 1.4em;">' + description + '</h1>';
        var link = $($(this).find('a') [0]);
        book += getContentOfStoie(link.attr('href'));
      }
    }
    myDiv.nextUntil('.ser-ttl,.root-story').each(addChapter);
    saveTextAsFile(book, title + '.html');
  }
 function getABookForStoryDiv(myDiv) {
    var title = $.trim($($(myDiv).find('td')[0]).text().split('(')[0]);
    var author = $('.contactheader').text();
    var book = '<html>\n<head>\n<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">\n';
    book += '<title>' + title + '</title>';
    book += '<meta content="' + author + '" name="author">';
    book += '</head>\n<body style="background-color:#333333; color: #EEEEEE; font-family: Helvetica,Arial,sans-serif; width: 50%; margin: 0 auto; line-height: 1.5em; font-size:2.2em; padding: 50px 0 50px 0;">';
      if ($(myDiv).find('a').size() > 0) {
        var description = $($(myDiv).find('td') [1]).text();
        book += '<h1 class=\'chapter\' style="line-height: 1.4em;">' + description + '</h1>';
        var link = $($(myDiv).find('a') [0]);
        book += getContentOfStoie(link.attr('href'));
      }

    saveTextAsFile(book, title + '.html');
  }
  $('.ser-ttl td:nth-child(1)').prepend('<span class=\'icon-download\'></span>');
   $('.ser-ttl td:nth-child(1)').click(function()  {
  getABookForSerieDiv($(this).parent());
});
  $('.root-story td:nth-child(1), .sl td:nth-child(1)').prepend('<span class=\'icon-download\'></span>');
$('.root-story td:nth-child(1), .sl td:nth-child(1)').click(function()  {
  getABookForStoryDiv($(this).parent());
});
});