nhentai show comments

nHentai show comment(Comment from Exhentai)

  1. // ==UserScript==
  2. // @name nhentai show comments
  3. // @namespace nhentai_comments
  4. // @supportURL https://github.com/zhuzemin
  5. // @description nHentai show comment(Comment from Exhentai)
  6. // @include https://nhentai.net/g/*
  7. // @include https://en.nyahentai3.com/g/*
  8. // @include https://zh.nyahentai.co/g/*
  9. // @include https://ja.nyahentai.net/g/*
  10. // @include https://zh.nyahentai.pro/g/*
  11. // @version 1.11
  12. // @grant GM_xmlhttpRequest
  13. // @grant GM_registerMenuCommand
  14. // @grant GM_setValue
  15. // @grant GM_getValue
  16. // @run-at document-start
  17. // @author zhuzemin
  18. // @license Mozilla Public License 2.0; http://www.mozilla.org/MPL/2.0/
  19. // @license CC Attribution-ShareAlike 4.0 International; http://creativecommons.org/licenses/by-sa/4.0/
  20. // @connect-src e-hentai.org
  21. // @connect-src exhentai.org
  22. // @connect-src proud-surf-e590.zhuzemin.workers.dev
  23. // ==/UserScript==
  24. var config = {
  25. 'debug': false
  26. }
  27. var debug = config.debug ? console.log.bind(console) : function () {
  28. };
  29.  
  30. class E_hentai{
  31. constructor(keyword) {
  32. this.method = 'GET';
  33. this.url = "https://e-hentai.org/?f_doujinshi=1&f_manga=1&f_artistcg=1&f_gamecg=1&f_western=1&f_non-h=1&f_imageset=1&f_cosplay=1&f_asianporn=1&f_misc=1&f_search="+keyword+"&f_apply=Apply+Filter&advsearch=";
  34. this.headers = {
  35. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  36. 'Accept': 'application/atom+xml,application/xml,text/xml',
  37. 'Referer': window.location.href,
  38. };
  39. this.charset = 'text/plain;charset=utf8';
  40. }
  41. }
  42. class Exhentai{
  43. constructor(keyword) {
  44. this.method = 'GET';
  45. this.url = "https://exhentai.org/?f_doujinshi=1&f_manga=1&f_artistcg=1&f_gamecg=1&f_western=1&f_non-h=1&f_imageset=1&f_cosplay=1&f_asianporn=1&f_misc=1&f_search="+keyword+"&f_apply=Apply+Filter&advsearch=";
  46. this.headers = {
  47. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  48. 'Accept': 'application/atom+xml,application/xml,text/xml',
  49. 'Referer': window.location.href,
  50. };
  51. this.charset = 'text/plain;charset=utf8';
  52. }
  53. }
  54. class CloudFlare{
  55. constructor(keyword) {
  56. this.method = 'GET';
  57. this.url = "https://proud-surf-e590.zhuzemin.workers.dev/ajax/https://exhentai.org/?f_doujinshi=1&f_manga=1&f_artistcg=1&f_gamecg=1&f_western=1&f_non-h=1&f_imageset=1&f_cosplay=1&f_asianporn=1&f_misc=1&f_search="+keyword+"&f_apply=Apply+Filter&advsearch=";
  58. this.headers = {
  59. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  60. 'Accept': 'application/atom+xml,application/xml,text/xml',
  61. 'Referer': window.location.href,
  62. };
  63. this.charset = 'text/plain;charset=utf8';
  64. }
  65. }
  66.  
  67. class Gallery{
  68. constructor(href) {
  69. this.method = 'GET';
  70. this.url = href;
  71. this.headers = {
  72. 'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
  73. 'Accept': 'application/atom+xml,application/xml,text/xml',
  74. 'Referer': window.location.href,
  75. };
  76. this.charset = 'text/plain;charset=utf8';
  77. }
  78. }
  79. var exhentai;
  80. var e_hentai;
  81. var cloudFlareUrl='https://proud-surf-e590.zhuzemin.workers.dev/ajax/';
  82. var init = function () {
  83. //setInterval(function(){
  84. var info = document.querySelector('#info');
  85. var title=info.querySelector("h1").innerText;
  86. exhentai=new Exhentai(title);
  87. e_hentai=new E_hentai(title);
  88. cloudflare=new CloudFlare(title);
  89. debug("init");
  90. request(exhentai,SearchGallery);
  91. //}, 2000)
  92. }
  93.  
  94. function SearchGallery(responseDetails) {
  95. var responseText=responseDetails.responseText;
  96. if(responseText.length<200||responseDetails.finalUrl.includes('.workers.dev')){
  97. request(cloudflare,SearchGallery);
  98. return;
  99. }
  100. else if(responseText.length<200&&responseDetails.finalUrl.includes('.workers.dev')){
  101. request(e_hentai,SearchGallery);
  102. return;
  103.  
  104. }
  105. var href=responseText.match(/(https:\/\/e(-|x)hentai\.org\/g\/[\d\w]*\/[\d\w]*\/)/)[1];
  106. debug("href: "+href);
  107. /*var dom = new DOMParser().parseFromString(responseText, "text/html");
  108. var div = dom.getElementsByClassName('itg')[0];
  109. var href = div.querySelector('a').href;*/
  110. var gallery = new Gallery(cloudFlareUrl+href);
  111. debug("SearchGallery");
  112. request(gallery,GetComments);
  113. }
  114.  
  115. function GetComments(responseDetails) {
  116. var responseText=responseDetails.responseText;
  117. var dom = new DOMParser().parseFromString(responseText, "text/html");
  118. var comments=dom.querySelector("#cdiv");
  119. comments.style.color="#34495e";
  120. var content=document.querySelector("#content");
  121. var related=content.querySelector("#related-container");
  122. debug("GetComments");
  123. content.insertBefore(comments,related);
  124. var link=document.createElement("link");
  125. link.innerHTML=`<link rel="stylesheet" type="text/css" href="https://e-hentai.org/z/0347/g.css">`;
  126. var head=document.querySelector("head");
  127. head.insertBefore(link,null);
  128. }
  129. function request(object,func) {
  130. var retries = 10;
  131. GM_xmlhttpRequest({
  132. method: object.method,
  133. url: object.url,
  134. headers: object.headers,
  135. overrideMimeType: object.charset,
  136. //synchronous: true
  137. onload: function (responseDetails) {
  138. if (responseDetails.status != 200) {
  139. // retry
  140. if (retries--) { // *** Recurse if we still have retries
  141. setTimeout(request(),2000);
  142. return;
  143. }
  144. }
  145. debug(responseDetails);
  146. //Dowork
  147. func(responseDetails);
  148. }
  149. });
  150. }
  151. window.addEventListener('DOMContentLoaded', init);