Literotica Downloader BetaFix [DEPRECATED]

Single page HTML download for Literotica with improved readability. [DEPRECATED] Use this instead: https://greasyfork.org/en/scripts/423700-literotica-downloader

  1. // ==UserScript==
  2. // @name Literotica Downloader BetaFix [DEPRECATED]
  3. // @description Single page HTML download for Literotica with improved readability. [DEPRECATED] Use this instead: https://greasyfork.org/en/scripts/423700-literotica-downloader
  4. // @namespace literotica_downloader_beta
  5. // @include https://www.literotica.com/stories/memberpage.php*
  6. // @require https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  7. // @version 2.1.1.fix-DEPRECATED
  8. // @author Improved by a random redditor and fixed for new "beta" site by someone else, originally by Patrick Kolodziejczyk
  9. // @grant GM_addStyle
  10. // ==/UserScript==
  11.  
  12. $(document).ready(function () {
  13. // Creating style for a download icon
  14. 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;}'
  15. );
  16. // Function used to return content as a file for the user.
  17. function saveTextAsFile(textToWrite, fileNameToSaveAs)
  18. {
  19. var textFileAsBlob = new Blob([textToWrite], {
  20. type: 'text/javascript'
  21. });
  22. var downloadLink = document.createElement('a');
  23. downloadLink.download = fileNameToSaveAs;
  24. downloadLink.innerHTML = 'Download File';
  25. /*if (window.webkitURL !== null)
  26. {
  27. // Chrome allows the link to be clicked
  28. // without actually adding it to the DOM.
  29. downloadLink.href = window.webkitURL.createObjectURL(textFileAsBlob);
  30. }
  31. else//*/
  32. {
  33. // Firefox requires the link to be added to the DOM
  34. // before it can be clicked.
  35. downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
  36. //downloadLink.onclick = destroyClickedElement;
  37. downloadLink.style.display = 'none';
  38. document.body.appendChild(downloadLink);
  39. }
  40. downloadLink.click();
  41. }
  42. // Function parsing all pages to get the storie based
  43. function getContentOfStoie(baseURL) {
  44. var remote;
  45. $.ajax({
  46. url: baseURL,
  47. type: 'GET',
  48. async: false,
  49. success: function (data) {
  50. if ($(data).find('.l_bL').size()) {
  51. remote = $(data).find('.aa_ht').html() + getContentOfStoie($(data).find('.l_bL') [0].href);
  52. } else {
  53. remote = $(data).find('.aa_ht').html();
  54. }
  55. }
  56. });
  57. return remote;
  58. }
  59. function getABookForSerieDiv(myDiv) {
  60. var title = $.trim(myDiv.text().split(':') [0]);
  61. var author = $('.contactheader').text();
  62. alert("Starting building file for "+title +" of "+author+".\nPlease wait...");
  63. var book = '<html>\n<head>\n<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">\n';
  64. book += '<title>' + title + '</title>';
  65. book += '<meta content="' + author + '" name="author">';
  66. book += '</head>\n<body style="background-color:#333333; color: #EEEEEE; font-family: Helvetica,Arial,sans-serif; width: 60%; margin: 0 auto; line-height: 1.5em; font-size:2.2em; padding: 50px 0 50px 0;">';
  67. function addChapter(element, index, array) {
  68. if ($(this).find('a').size() > 0) {
  69. var description = $($(this).find('td') [1]).text();
  70. book += '<h1 class=\'chapter\' style="line-height: 1.4em;">' + description + '</h1>';
  71. var link = $($(this).find('a') [0]);
  72. book += getContentOfStoie(link.attr('href'));
  73. }
  74. }
  75. myDiv.nextUntil('.ser-ttl,.root-story').each(addChapter);
  76. saveTextAsFile(book, author + ' - ' + title + '.html');
  77. }
  78. function getABookForStoryDiv(myDiv) {
  79. var title = $.trim($($(myDiv).find('td')[0]).text().split('(')[0]);
  80. var author = $('.contactheader').text();
  81. var book = '<html>\n<head>\n<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">\n';
  82. book += '<title>' + title + '</title>';
  83. book += '<meta content="' + author + '" name="author">';
  84. book += '</head>\n<body style="background-color:#333333; color: #EEEEEE; font-family: Helvetica,Arial,sans-serif; width: 70%; margin: 0 auto; line-height: 1.5em; font-size:2.2em; padding: 50px 0 50px 0;">';
  85. if ($(myDiv).find('a').size() > 0) {
  86. var description = $($(myDiv).find('td') [1]).text();
  87. book += '<h1 class=\'chapter\' style="line-height: 1.4em;">' + description + '</h1>';
  88. var link = $($(myDiv).find('a') [0]);
  89. book += getContentOfStoie(link.attr('href'));
  90. }
  91.  
  92. saveTextAsFile(book, author + ' - ' + title + '.html');
  93. }
  94. $('.ser-ttl td:nth-child(1)').prepend('<span class=\'icon-download\'></span>');
  95. $('.ser-ttl td:nth-child(1)').click(function() {
  96. getABookForSerieDiv($(this).parent());
  97. });
  98. $('.root-story td:nth-child(1), .sl td:nth-child(1)').prepend('<span class=\'icon-download\'></span>');
  99. $('.root-story td:nth-child(1), .sl td:nth-child(1)').click(function() {
  100. getABookForStoryDiv($(this).parent());
  101. });
  102. });