Sleazy Fork is available in English.

e-hentai to nhentai

A button in e-hentai, for search Gallery in nhentai

  1. // ==UserScript==
  2. // @name e-hentai to nhentai
  3. // @name:zh-CN e-hentai to nhentai
  4. // @name:zh-TW e-hentai to nhentai
  5. // @name:ja e-hentai to nhentai
  6. // @namespace e-hentai_to_nhentai
  7. // @supportURL https://github.com/zhuzemin
  8. // @description A button in e-hentai, for search Gallery in nhentai
  9. // @description:ja A button in e-hentai, for search Gallery in nhentai
  10. // @description:zh-TW A button in e-hentai, for search Gallery in nhentai
  11. // @description:zh-CN A button in e-hentai, for search Gallery in nhentai
  12. // @include https://exhentai.org/g/*/*
  13. // @include https://e-hentai.org/g/*/*
  14. // @version 1.11
  15. // @run-at document-start
  16. // @grant GM_registerMenuCommand
  17. // @grant GM_setValue
  18. // @grant GM_getValue
  19. // @author zhuzemin
  20. // @license Mozilla Public License 2.0; http://www.mozilla.org/MPL/2.0/
  21. // @license CC Attribution-ShareAlike 4.0 International; http://creativecommons.org/licenses/by-sa/4.0/
  22. // ==/UserScript==
  23. var config = {
  24. 'debug': false
  25. }
  26. var debug = config.debug ? console.log.bind(console) : function () {
  27. };
  28.  
  29. // prepare UserPrefs
  30. setUserPref(
  31. 'nhentaiSite',
  32. 'https://en.nyahentai3.com',
  33. 'Witch site you want use',
  34. `working with:
  35. https://nhentai.net / https://en.nyahentai3.com /
  36. https://zh.nyahentai4.com / https://zh.nyahentai.pro / https://zh.nyahentai.co /
  37. https://ja.nyahentai.org / https://ja.nyahentai.net`,
  38. ','
  39. );
  40. var nyahentaiSite;
  41.  
  42. function SearchNyahentai() {
  43. var title=document.title.replace(/( - ExHentai\.org)|( - E-Hentai Galleries)|[^\w\d\[\]]/g," ");
  44. window.open(nyahentaiSite+"/search/q_"+encodeURI(title));
  45. }
  46.  
  47. function CreateButton(text,func){
  48. var btn=document.createElement("button");
  49. btn.type="button";
  50. btn.onclick="";
  51. btn.innerHTML=text;
  52. btn.addEventListener('click',func);
  53. var gd2=document.querySelector("#gd2");
  54. gd2.insertBefore(btn, null);
  55. }
  56.  
  57. var init = function () {
  58. nyahentaiSite=GM_getValue('nhentaiSite')||'https://en.nyahentai3.com';
  59. CreateButton('Search in nhentai',function () {
  60. SearchNyahentai();
  61. });
  62.  
  63. }
  64. window.addEventListener('DOMContentLoaded', init);
  65. function setUserPref(varName, defaultVal, menuText, promtText, sep){
  66. GM_registerMenuCommand(menuText, function() {
  67. var val = prompt(promtText, GM_getValue(varName, defaultVal));
  68. if (val === null) { return; } // end execution if clicked CANCEL
  69. // prepare string of variables separated by the separator
  70. if (sep && val){
  71. var pat1 = new RegExp('\\s*' + sep + '+\\s*', 'g'); // trim space/s around separator & trim repeated separator
  72. var pat2 = new RegExp('(?:^' + sep + '+|' + sep + '+$)', 'g'); // trim starting & trailing separator
  73. //val = val.replace(pat1, sep).replace(pat2, '');
  74. }
  75. //val = val.replace(/\s{2,}/g, ' ').trim(); // remove multiple spaces and trim
  76. GM_setValue(varName, val);
  77. // Apply changes (immediately if there are no existing highlights, or upon reload to clear the old ones)
  78. //if(!document.body.querySelector(".THmo")) THmo_doHighlight(document.body);
  79. //else location.reload();
  80. });
  81. }