Literotica Downloader

Single page HTML download for Literotica with improved readability

La data de 21-03-2021. Vezi ultima versiune.

  1. // ==UserScript==
  2. // @name Literotica Downloader
  3. // @description Single page HTML download for Literotica with improved readability
  4. // @namespace literotica_downloader
  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.5
  8. // @author Improved by a random redditor and @nylonmachete, originally by Patrick Kolodziejczyk
  9. // ==/UserScript==
  10. $(document).ready(function () {
  11. var bodyStyle=' 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;" ';
  12. var chapterStyle=' style="line-height: 1.4em;" ';
  13. // Creating style for a download icon
  14. var iconDonwload = ' style=\'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. // Function used to return content as a file for the user.
  16. function saveTextAsFile(textToWrite, fileNameToSaveAs)
  17. {
  18. var textFileAsBlob = new Blob([textToWrite], {
  19. type: 'text/javascript'
  20. });
  21. var downloadLink = document.createElement('a');
  22. downloadLink.download = fileNameToSaveAs;
  23. downloadLink.innerHTML = 'Download File';
  24. // Firefox requires the link to be added to the DOM
  25. // before it can be clicked.
  26. downloadLink.href = window.URL.createObjectURL(textFileAsBlob);
  27. //downloadLink.onclick = destroyClickedElement;
  28. downloadLink.style.display = 'none';
  29. document.body.appendChild(downloadLink);
  30. downloadLink.click();
  31. }
  32. // Function parsing all pages to get the storie based
  33. function getContentOfStoie(baseURL) {
  34. console.log("Fetching "+baseURL);
  35. var remote;
  36. $.ajax({
  37. url: baseURL,
  38. type: 'GET',
  39. async: false,
  40. crossDomain: true,
  41. success: function (data) {
  42. if ($(data).find('a.l_bJ.l_bL').size()>0) {
  43. console.log($(data).find('a.l_bJ.l_bL').size());
  44. remote = $(data).find('.panel.article.aa_eQ .aa_ht').html() + getContentOfStoie($(data).find('a.l_bJ.l_bL')[0].href);
  45. } else {
  46. remote = $(data).find('.panel.article.aa_eQ .aa_ht').html();
  47. }
  48. }
  49. });
  50. return remote;
  51. }
  52. function getABookForSerieDiv(myDiv) {
  53. var title = $.trim(myDiv.text().split(':') [0]);
  54. var author = $('.contactheader').text();
  55. alert("Starting building file for "+title +" of "+author+".\nPlease wait...");
  56. var book = '<html>\n<head>\n<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">\n';
  57. book += '<title>' + title + '</title>';
  58. book += '<meta content="' + author + '" name="author">';
  59. book += '</head>\n<body '+ bodyStyle +' >';
  60. function addChapter(element, index, array) {
  61. if ($(this).find('a').size() > 0) {
  62. var description = $($(this).find('td') [1]).text();
  63. book += '<h1 class=\'chapter\'' + chapterStyle + '>' + description + '</h1>';
  64. var link = $($(this).find('a') [0]);
  65. book += getContentOfStoie(link.attr('href'));
  66. }
  67. }
  68. myDiv.nextUntil('.ser-ttl,.root-story').each(addChapter);
  69. saveTextAsFile(book, title + '.html');
  70. }
  71. function getABookForStoryDiv(myDiv) {
  72. var title = $.trim($($(myDiv)).text().split('(')[0]);
  73. var author = $('.contactheader').text();
  74. var book = '<html>\n<head>\n<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">\n';
  75. book += '<title>' + title + '</title>';
  76. book += '<meta content="' + author + '" name="author">';
  77. book += '</head>\n<body '+ bodyStyle + '>';
  78. if ($(myDiv).find('a').size() > 0) {
  79. var description = $($(myDiv).find('td') [1]).text();
  80. book += '<h1 class=\'chapter\'' + chapterStyle + '>' + description + '</h1>';
  81. var link = $($(myDiv).find('a') [0]);
  82. book += getContentOfStoie(link.attr('href'));
  83. }
  84.  
  85. saveTextAsFile(book, title + '.html');
  86. }
  87. $('.ser-ttl td:nth-child(1)').prepend('<span '+iconDonwload+'></span>');
  88. $('.ser-ttl td:nth-child(1) span').click(function() {
  89. getABookForSerieDiv($(this).parent().parent());
  90. });
  91. var idIcon =Math.floor(Math.random() * 100);
  92. $('.root-story td:nth-child(1), .sl td:nth-child(1)').prepend('<span '+iconDonwload+' id="'+idIcon+'"></span>');
  93. $('.root-story td:nth-child(1), .sl td:nth-child(1) span').click(function() {
  94. getABookForStoryDiv($(this).parent());
  95. });
  96. });