Advertisement
Guest User

Manga Loader NSFW fix caffvic

a guest
Dec 12th, 2017
543
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name       Manga Loader NSFW
  3. // @namespace  http://www.fuzetsu.com/MangaLoaderNSFW
  4. // @version    1.0.56.1
  5. // @description  Loads manga chapter into one page in a long strip format, supports switching chapters and works for a variety of sites, minimal script with no dependencies, easy to implement new sites, loads quickly and works on mobile devices through bookmarklet
  6. // @copyright  2016+, fuzetsu
  7. // @noframes
  8. // @grant GM_getValue
  9. // @grant GM_setValue
  10. // @grant GM_deleteValue
  11. // -- NSFW START
  12. // @match *://dynasty-scans.com/chapters/*
  13. // @match *://hentaifr.net/*
  14. // @match *://prismblush.com/comic/*
  15. // @match *://www.hentairules.net/galleries*/picture.php*
  16. // @match *://pururin.us/read/*
  17. // @match *://hitomi.la/reader/*
  18. // @match *://*.doujins.com/*
  19. // @match *://www.8muses.com/comix/picture/*/*/*/*
  20. // @match *://nowshelf.com/watch/*
  21. // @match *://nhentai.net/g/*/*
  22. // @match *://e-hentai.org/s/*/*
  23. // @match *://exhentai.org/s/*/*
  24. // @match *://www.fakku.net/*/*/read*
  25. // @match *://hentaihere.com/m/*/*/*
  26. // @match *://www.hentaihere.com/m/*/*/*
  27. // @match *://*.tsumino.com/Read/View/*
  28. // @match *://www.hentaibox.net/*/*
  29. // @match *://*.hentai-free.org/*
  30. // @match *://*.mangafap.com/image/*
  31. // @match *://*.hentai4manga.com/hentai_manga/*
  32. // @match *://*.heymanga.me/manga/*
  33. // @match *://*.simply-hentai.com/*/page/*
  34. // @match *://*.gameofscanlation.moe/projects/*/*
  35. // @match *://*.luscious.net/c/*/pictures/album/*/id/*
  36. // @match *://*.hentaifox.com/g/*
  37. // @match *://*.hentai2read.com/*/*/*
  38. // @match *://*.hentai.ms/manga/*/*
  39. // -- NSFW END
  40. // -- FOOLSLIDE NSFW START
  41. // @match *://reader.yuriproject.net/read/*
  42. // @match *://ecchi.japanzai.com/read/*
  43. // @match *://h.japanzai.com/read/*
  44. // @match *://reader.japanzai.com/read/*
  45. // @match *://yomanga.co/reader/read/*
  46. // @match *://raws.yomanga.co/read/*
  47. // @match *://hentai.cafe/manga/read/*
  48. // @match *://*.yuri-ism.net/slide/read/*
  49. // -- FOOLSLIDE NSFW END
  50. // @require https://greasyfork.org/scripts/692-manga-loader/code/Manga%20Loader.user.js?29
  51. // ==/UserScript==
  52.  
  53. /**
  54. Sample Implementation:
  55. {
  56.     name: 'something' // name of the implementation
  57.   , match: "^https?://domain.com/.*" // the url to react to for manga loading
  58.   , img: '#image' // css selector to get the page's manga image
  59.   , next: '#next_page' // css selector to get the link to the next page
  60.   , numpages: '#page_select' // css selector to get the number of pages. elements like (select, span, etc)
  61.   , curpage: '#page_select' // css selector to get the current page. usually the same as numPages if it's a select element
  62.   , numchaps: '#chapters' // css selector to get the number of chapters in manga
  63.   , curchap: '#chapters' // css selector to get the number of the current chapter
  64.   , nextchap: '#next_chap' // css selector to get the link to the next chapter
  65.   , prevchap: '#prev_chap' // same as above except for previous
  66.   , wait: 3000 // how many ms to wait before auto loading (to wait for elements to load), or a css selector to keep trying until it returns an elem
  67.   , pages: function(next_url, current_page_number, callback, extract_function) {
  68.     // gets called requesting a certain page number (current_page_number)
  69.     // to continue loading execute callback with img to append as first parameter and next url as second parameter
  70.     // only really needs to be used on sites that have really unusual ways of loading images or depend on javascript
  71.   }
  72.  
  73.   Any of the CSS selectors can be functions instead that return the desired value.
  74. }
  75. */
  76.  
  77. // reusable functions to insert in implementations
  78. var reuse = {
  79.   encodeChinese: function(xhr) {
  80.     xhr.overrideMimeType('text/html;charset=gbk');
  81.   },
  82.   na: function() {
  83.     return 'N/A';
  84.   }
  85. };
  86.  
  87. var exUtil = {
  88.   clearAllTimeouts: function() {
  89.     var id = window.setTimeout(function() {}, 0);
  90.     while (id--) {
  91.       window.clearTimeout(id);
  92.     }
  93.   }
  94. };
  95.  
  96. var nsfwimp = [{
  97.   name: 'geh-and-exh',
  98.   match: "^https?://(e-hentai|exhentai).org/s/.*/.*",
  99.   img: '.sni > a > img, #img',
  100.   next: '.sni > a, #i3 a',
  101.   numpages: 'div.sn > div > span:nth-child(2)',
  102.   curpage: 'div.sn > div > span:nth-child(1)'
  103. }, {
  104.   name: 'fakku',
  105.   match: "^http(s)?://www.fakku.net/.*/.*/read",
  106.   img: '.current-page',
  107.   next: '.current-page',
  108.   numpages: '.drop',
  109.   curpage: '.drop',
  110.   pages: function(url, num, cb, ex) {
  111.     var firstNum = url.lastIndexOf('/'),
  112.         lastDot = url.lastIndexOf('.');
  113.     var c = url.charAt(firstNum);
  114.     while (c && !/[0-9]/.test(c)) {
  115.       c = url.charAt(++firstNum);
  116.     }
  117.     var curPage = parseInt(url.slice(firstNum, lastDot), 10);
  118.     url = url.slice(0, firstNum) + ('00' + (curPage + 1)).slice(-3) + url.slice(lastDot);
  119.     cb(url, url);
  120.   }
  121. }, {
  122.   name: 'nowshelf',
  123.   match: "^https?://nowshelf.com/watch/[0-9]*",
  124.   img: '#image',
  125.   next: '#image',
  126.   numpages: function() {
  127.     return parseInt(getEl('#page').textContent.slice(3), 10);
  128.   },
  129.   curpage: function() {
  130.     return parseInt(getEl('#page > input').value, 10);
  131.   },
  132.   pages: function(url, num, cb, ex) {
  133.     cb(page[num], num);
  134.   }
  135. }, {
  136.   name: 'nhentai',
  137.   match: "^https?://nhentai\\.net\\/g\\/[0-9]+/[0-9]+",
  138.   img: '#image-container > a img',
  139.   next: '#image-container > a',
  140.   numpages: '.num-pages',
  141.   curpage: '.current',
  142.   imgmod: {
  143.     altProp: 'data-cfsrc'
  144.   },
  145. }, {
  146.   name: '8muses',
  147.   match: "^http(s)?://www.8muses.com/comix/picture/[^/]+/[^/]+/[^/]+/.+",
  148.   img: function(ctx) {
  149.     var img = getEl('.photo img.image', ctx);
  150.     return img ? img.src : getEl('#imageDir', ctx).value + getEl('#imageName', ctx).value;
  151.   },
  152.   next: '.photo > a',
  153.   curpage: '#page-select-s',
  154.   numpages: '#page-select-s'
  155. }, {
  156.   name: 'hitomi',
  157.   match: "^http(s)?://hitomi.la/reader/[0-9]+.html",
  158.   img: '#comicImages > img',
  159.   next: '#comicImages > img',
  160.   numpages: function() {
  161.     return W.images.length;
  162.   },
  163.   curpage: function() {
  164.     return parseInt(W.curPanel);
  165.   },
  166.   pages: function(url, num, cb, ex) {
  167.     cb(W.images[num - 1].path, num);
  168.   },
  169.   wait: '#comicImages > img'
  170. }, {
  171.   name: 'doujin-moe',
  172.   _pages: null,
  173.   match: "^https?://doujins\.com/.+",
  174.   img: 'img.picture',
  175.   next: reuse.na,
  176.   numpages: function() {
  177.     if (!this._pages) {
  178.       this._pages = getEls('#gallery djm').map(function(file) {
  179.         return file.getAttribute('file').replace('static2.', 'static.');
  180.       });
  181.     }
  182.     return this._pages.length;
  183.   },
  184.   curpage: function() {
  185.     return parseInt(getEl('.counter').textContent.match(/^[0-9]+/)[0]);
  186.   },
  187.   pages: function(url, num, cb, ex) {
  188.     cb(this._pages[num - 1], num);
  189.   }
  190. }, {
  191.   name: 'pururin',
  192.   match: "https?://pururin\\.us/read/.+",
  193.   img: 'img.image-next',
  194.   next: 'a.image-next',
  195.   numpages: function() {
  196.     return Object.keys(chapters).length;
  197.   },
  198.   curpage: 'option:checked',
  199.   pages: function(url, num, cb, ex) {
  200.     cb(chapters[num].image, num);
  201.   }
  202. }, {
  203.   name: 'hentai-rules',
  204.   match: "^https?://www\\.hentairules\\.net/galleries[0-9]*/picture\\.php.+",
  205.   img: '#theMainImage',
  206.   next: '#linkNext',
  207.   imgmod: {
  208.     altProp: 'data-src'
  209.   },
  210.   numpages: function(cur) {
  211.     return parseInt(getEl('.imageNumber').textContent.replace(/([0-9]+)\/([0-9]+)/, cur ? '$1' : '$2'));
  212.   },
  213.   curpage: function() {
  214.     return this.numpages(true);
  215.   }
  216. }, {
  217.   name: 'ero-senmanga',
  218.   match: "^https?://ero\\.senmanga\\.com/[^/]*/[^/]*/[0-9]*",
  219.   img: '#picture',
  220.   next: '#omv > table > tbody > tr:nth-child(2) > td > a',
  221.   numpages: 'select[name=page]',
  222.   curpage: 'select[name=page]',
  223.   nextchap: function(prev) {
  224.     var next = extractInfo('select[name=chapter]', {
  225.       type: 'value',
  226.       val: (prev ? -1 : 1)
  227.     });
  228.     if (next) return window.location.href.replace(/\/[^\/]*\/[0-9]+\/?$/, '') + '/' + next + '/1';
  229.   },
  230.   prevchap: function() {
  231.     return this.nextchap(true);
  232.   }
  233. }, {
  234.   name: 'hentaifr',
  235.   match: "^https?://hentaifr\\.net/.+\\.php\\?id=[0-9]+",
  236.   img: function(ctx, next) {
  237.     var img = getEls('img[width]', ctx).filter(function(img) {
  238.       return img.getAttribute('src').indexOf('contenu/doujinshis') !== -1;
  239.     })[0];
  240.     return next ? img : (img ? img.getAttribute('src') : null);
  241.   },
  242.   next: function(ctx) {
  243.     var img = this.img(ctx, true);
  244.     return img ? img.parentNode.getAttribute('href') : null;
  245.   },
  246.   wait: function() {
  247.     return this.img() &&  this.next();
  248.   }
  249. }, {
  250.   name: 'prism-blush',
  251.   match: "^https?://prismblush.com/comic/.+",
  252.   img: '#comic img',
  253.   next: '#comic a'
  254. }, {
  255.   name: 'hentai-here',
  256.   match: "^https?://(www\\.)?hentaihere.com/m/[^/]+/[0-9]+/[0-9]+",
  257.   img: '#arf-reader-img',
  258.   next: reuse.na,
  259.   curpage: function() {
  260.     return parseInt(W.rff_thisIndex);
  261.   },
  262.   numpages: function() {
  263.     return W.rff_imageList.length;
  264.   },
  265.   pages: function(url, num, cb, ex) {
  266.     cb(W.imageCDN + W.rff_imageList[num - 1], num);
  267.   },
  268.   nextchap: function() {
  269.     return W.rff_nextChapter;
  270.   },
  271.   prevchap: function() {
  272.     return W.rff_previousChapter;
  273.   },
  274.   curchap: function() {
  275.     var curchap;
  276.     getEls('ul.dropdown-menu.text-left li').some(function(li, index) {
  277.       if(getEl('a.bg-info', li)) {
  278.         curchap = index + 1;
  279.       }
  280.     });
  281.     return curchap;
  282.   },
  283.   numchaps: 'ul.dropdown-menu.text-left',
  284.   wait: 'ul.dropdown-menu.text-left'
  285. }, {
  286.   name: 'foolslide',
  287.   match: "^https?://(" + [
  288.     'reader.yuriproject.net/read/.+',
  289.     'ecchi.japanzai.com/read/.+',
  290.     'h.japanzai.com/read/.+',
  291.     'reader.japanzai.com/read/.+',
  292.     '(raws\\.)?yomanga.co(/reader)?/read/.+',
  293.     'hentai.cafe/manga/read/.+',
  294.     '(www\\.)?yuri-ism\\.net/slide/read/.'
  295.   ].join('|') + ")",
  296.   img: function() {
  297.     return W.pages[W.current_page].url;
  298.   },
  299.   next: reuse.na,
  300.   numpages: function() {
  301.     return W.pages.length;
  302.   },
  303.   curpage: function() {
  304.     return W.current_page + 1;
  305.   },
  306.   nextchap: function(prev) {
  307.     var desired;
  308.     var dropdown = getEls('ul.dropdown')[1] || getEls('ul.uk-nav')[1];
  309.     if(!dropdown) return;
  310.     getEls('a', dropdown).forEach(function(chap, idx, arr) {
  311.       if(location.href.indexOf(chap.href) === 0) desired = arr[idx + (prev ? 1 : -1)];
  312.     });
  313.     return desired && desired.href;
  314.   },
  315.   prevchap: function() {
  316.     return this.nextchap(true);
  317.   },
  318.   pages: function(url, num, cb, ex) {
  319.     cb(W.pages[num - 1].url, num);
  320.   },
  321.   wait: function() {
  322.     if(W.location.href.indexOf('yomanga') !== -1) {
  323.       // select all possible variable names for data structure
  324.       var matches = [].slice.call(document.body.innerHTML.match(/\w+\s*=\s*\[\{"id"/ig));
  325.       // extract actual variable name from match
  326.       var tokens = matches.map(function(m) {
  327.         var tok = m.match(/^(\w+)\s*=/i);
  328.         return tok && tok[1];
  329.       });
  330.       // determine the variable that holds the largest data structure
  331.       var largest;
  332.       var max = 0;
  333.       tokens.forEach(function(token) {
  334.         var cur = W[token];
  335.         if(cur && cur.length > max && [].every.call(cur, function(pg) { return pg.url.endsWith(pg.filename); })) {
  336.           max = cur.length;
  337.           largest = cur;
  338.         }
  339.       });
  340.       W.pages = largest || 'fail';
  341.     }
  342.     return W.pages;
  343.   }
  344. }, {
  345.   name: 'tsumino',
  346.   match: '^https?://(www\\.)?tsumino.com/Read/View/.+',
  347.   img: '.reader-img',
  348.   next: reuse.na,
  349.   numpages: function(curpage) {
  350.     return W.reader_max_page;
  351.   },
  352.   curpage: function() {
  353.     return W.reader_current_pg;
  354.   },
  355.   pages: function(url, num, cb) {
  356.     var self = this;
  357.     if(!self._pages) {
  358.       ajax({
  359.         method: 'POST',
  360.         url: '/Read/Load',
  361.         data: 'q=' + W.location.href.match(/View\/(\d+)/)[1],
  362.         responseType: 'json',
  363.         beforeSend: function(xhr) {
  364.           xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  365.         },
  366.         onload: function(e) {
  367.           var res = e.target.response;
  368.           if(!res) return log('failed to load tsumino pages, site has probably been updated, report on forums', 'error');
  369.           self._pages = res.reader_page_urls.map(function(page) {
  370.             return W.reader_baseobj_url + '?name=' + encodeURIComponent(page);
  371.           });
  372.           cb(self._pages[num - 1], num);
  373.         }
  374.       });
  375.     } else {
  376.       cb(self._pages[num - 1], num);
  377.     }
  378.   },
  379.   wait: '.reader-img'
  380. }, {
  381.   name: 'dynasty-scans',
  382.   match: "^https?://dynasty-scans.com/chapters/.*",
  383.   img: '#image > img',
  384.   next: reuse.na,
  385.   numpages: function() {
  386.     return W.pages.length;
  387.   },
  388.   curpage: function() {
  389.     return parseInt(getEl('#image > div.pages-list > a.page.active').getAttribute('href').slice(1));
  390.   },
  391.   nextchap: '#next_link',
  392.   prevchap: '#prev_link',
  393.   pages: function(url, num, cb, ex) {
  394.     url = W.pages[num - 1].image;
  395.     cb(url, url);
  396.   }
  397. }, {
  398.   name: 'hentaibox',
  399.   match: 'https?://www\\.hentaibox\\.net/hentai-manga/[^/]+/[0-9]+',
  400.   img: 'td > center > a > img',
  401.   next: 'td > center > a',
  402.   numpages: function(cur) {
  403.     var sel = getEl('select[name=np2]');
  404.     if(sel) {
  405.       var info = sel.options[0].textContent.match(/Page ([0-9]+) out of ([0-9]+)/i);
  406.       if(info && info.length >= 3) return parseInt(cur ? info[1] : info[2]);
  407.     }
  408.   },
  409.   curpage: function() {
  410.     return this.numpages(true);
  411.   }
  412. }, {
  413.   name: 'hentai-free', // trying to only show button on manga pages, but URL scheme makes it tough.
  414.   match: "^http://hentai-free.org/(?!(?:tag|manga-doujinshi|hentai-video|hentai-wall|tags-map)/|.*\\?).+/$",
  415.   img: function() {
  416.     return W.pages[0];
  417.   },
  418.   next: reuse.na,
  419.   numpages: function() {
  420.     return W.pages.length;
  421.   },
  422.   curpage: function() {
  423.     return 1;
  424.   },
  425.   wait: function() {
  426.     var links = getEls('.gallery-item a, a.bwg_lightbox_0');
  427.     if (links.length > 0) {
  428.       W.pages = links.map(function(el) {
  429.         return el.href.replace(/\?.*$/, '');
  430.       });
  431.       return true;
  432.     }
  433.     return false;
  434.   },
  435.   pages: function(url, num, cb, ex) {
  436.     cb(W.pages[num - 1], num);
  437.   }
  438. }, {
  439.   name: 'mangafap',
  440.   match: "^https?://mangafap\\.com/image/.+",
  441.   img: '#p',
  442.   next: '#lbanner + div > a',
  443.   numpages: 'select.span2',
  444.   curpage: '.pagination li.active a'
  445. }, {
  446.   name: 'hentai4manga',
  447.   match: "^https?://hentai4manga\\.com/hentai_manga/.+/\\d+/$",
  448.   img: '#textboxContent img',
  449.   next: '#textboxContent a',
  450.   numpages: '#sl',
  451.   curpage: '#sl'
  452. }, {
  453.   name: 'heymanga',
  454.   match: "https?://(www\\.)?heymanga\\.me/manga/[^/]+/[0-9.]+/[0-9]+",
  455.   img: '#img-content',
  456.   next: function(context) {
  457.     var num = this.curpage(context) + 1;
  458.     return document.location.href.replace(/([0-9]+)$/, num);
  459.   },
  460.   numpages: function() {
  461.     exUtil.clearAllTimeouts(); // site things mloader is an adblocker because it removes elems and blocks page, this removes the interval that checks for it
  462.     return getEl('#page_list').length - 1;
  463.   },
  464.   curpage: function(context) {
  465.     var match = getEls('#page_list > option[selected]', context);
  466.     return parseInt(match[match.length - 1].value); // dumb site always marks page 1 as "selected" in addition to actual selected page
  467.   },
  468.   nextchap: 'section > .row.text-center > p + a, section > .row.text-center .ti-line-dotted + a',
  469.   prevchap: 'section > .row.text-center .ti-hand-point-left + a',
  470.   wait: '#page_list > option[selected]'
  471. }, {
  472.   name: 'simply-hentai',
  473.   match: "https?://(.+\\.)?simply-hentai\\.com/.+/page/[0-9]+",
  474.   img: function(ctx) {
  475.     return getEl('#image span:nth-of-type(2)', ctx).dataset.src;
  476.   },
  477.   next: '#nextLink',
  478.   numpages: function() {
  479.     return parseInt(getEl('.inner-content .row .m10b.bold').textContent.match(/Page\s*\d+\s*of\s*(\d+)/)[1]);
  480.   },
  481.   curpage: function() {
  482.     return parseInt(getEl('.inner-content .row .m10b.bold').textContent.match(/Page\s*(\d+)/)[1]);
  483.   },
  484.   wait: '#image img'
  485. }, {
  486.   name: 'gameofscanlation',
  487.   match: "https?://gameofscanlation\.moe/projects/.+/.+",
  488.   img: '.chapterPages img:first-of-type',
  489.   next: function() {
  490.     return location.href;
  491.   },
  492.   numpages: function() {
  493.     return getEls('.chapterPages img').length;
  494.   },
  495.   nextchap: '.comicNextPageUrl',
  496.   prevchap: '.comicPreviousPageUrl',
  497.   curchap: 'select[name=chapter_list]',
  498.   numchaps: 'select[name=chapter_list]',
  499.   pages: function(url, num, cb, ex) {
  500.     cb(W.pages[num - 1], location.href + '#' + num);
  501.   },
  502.   wait: function() {
  503.     W.pages = getEls('.chapterPages img').map(function (el) {
  504.       return el.src;
  505.     });
  506.     return W.pages && W.pages.length > 0;
  507.   }
  508. }, {
  509.   name: 'luscious',
  510.   match: "https?://luscious\\.net/c/.+?/pictures/album/.+?/id/.+",
  511.   img: '.icon-download',
  512.   next: '#next',
  513.   curpage: function() {
  514.     return parseInt(getEl('#pj_page_no').value);
  515.   },
  516.   numpages: '#pj_no_pictures'
  517. }, {
  518.   name: 'hentaifox',
  519.   match: "https?://hentaifox\\.com/g/.+",
  520.   img: '.gallery_content img.lazy',
  521.   next: '.gallery_content a.next_nav',
  522.   curpage: function() {
  523.     return parseInt(extractInfo('.pag_info', {type: 'text'}));
  524.   },
  525.   numpages: function() {
  526.     return extractInfo('.pag_info') - 2;
  527.   }
  528. }, {
  529.   name: 'hentai2read',
  530.   match: "https?://hentai2read\\.com/.+",
  531.   img: '#arf-reader',
  532.   next: '#arf-reader',
  533.   curpage: function() {
  534.     return parseInt(ARFfwk.doReader.data.index);
  535.   },
  536.   numpages: function() {
  537.     return ARFfwk.doReader.data['images'].length;
  538.   },
  539.   nextchap: function(){
  540.     return ARFfwk.doReader.data.nextURL;
  541.   },
  542.   prevchap: function(){
  543.     return ARFfwk.doReader.data.previousURL;
  544.   },
  545.   pages: function(url, num, cb, ex) {
  546.     cb(ARFfwk.doReader.getImageUrl(ARFfwk.doReader.data['images'][num - 1]), num);
  547.   }
  548. }, {
  549.   name: 'hentai.ms',
  550.   match: "http://www.hentai.ms/manga/[^/]+/.+",
  551.   img: 'center > a > img',
  552.   next: 'center > a:last-child',
  553.   curpage: function() {
  554.     return parseInt(getEl('center > a').parentNode.textContent.match(/([0-9]+)\//)[1]);
  555.   },
  556.   numpages: function() {
  557.     return parseInt(getEl('center > a').parentNode.textContent.match(/\/([0-9]+)/)[1]);
  558.   }
  559. }];
  560.  
  561. log('loading nsfw implementations...');
  562. MLoaderLoadImps(nsfwimp);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement