nHentai to E-H Mover

Quickly cross-search any gallery, and move favourites back to E-H/EX.

질문, 리뷰하거나, 이 스크립트를 신고하세요.
  1. // ==UserScript==
  2. // @name nHentai to E-H Mover
  3. // @description Quickly cross-search any gallery, and move favourites back to E-H/EX.
  4. // @author Hen-Tie
  5. // @homepage https://hen-tie.tumblr.com/
  6. // @namespace https://greasyfork.org/en/users/8336
  7. // @include https://nhentai.net/favorites/*
  8. // @include https://nhentai.net/g/*
  9. // @require https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js
  10. // @icon https://i.imgur.com/8bq1S92.jpg
  11. // @version 2.1
  12. // ==/UserScript==
  13. $(function(){
  14. if (/favorites/.test(window.location.pathname)) {
  15. moveFavourites()
  16. } else {
  17. crossSearch()
  18. }
  19.  
  20. function moveFavourites() {
  21. $('.gallery-favorite').each(function() {
  22. var rawTitle = $(this).find('.caption').text();
  23. $(this).find('.remove-button').after(
  24. '<button class="btn btn-primary btn-thin" title="Search on Ex-Hentai">' +
  25. '<a href="' + cleanTitle(rawTitle) + '" style="min-width:1em;">' +
  26. '<i class="fa fa-external-link-alt"></i>' +
  27. '</a>' +
  28. '</button>');
  29. })
  30. }
  31.  
  32. function crossSearch() {
  33. var rawTitle = $('h1').text();
  34. $('#download').before('<a style="min-width:3em;" class="btn btn-primary" title="Search on Ex-Hentai" href="' + cleanTitle(rawTitle) + '"><i class="fa fa-external-link-alt"></i></a>');
  35. }
  36.  
  37. function cleanTitle(str) {
  38. var url = "https://exhentai.org/?f_search=";
  39. str = str.replace(/[\][(){}|~,."'!?+*%:$]/igm,' ') //replace search operators and punctuation/formatting characters
  40. str = str.replace(/ \w{1,2} /igm,' ') //remove 1 or 2 char keywords, too short to search
  41. str = str.replace(/ {2,}/igm,' ') //compress 2+ spaces into just one
  42. str = str.replace(/^ (?=.*$)/igm,'') //remove leading space
  43. var isEng = str.match(/english/gi) //check for language
  44. if (isEng !== null) {
  45. str = str.replace(isEng[0],'') //remove lang
  46. str = isEng[0] + ' ' + str //prepend lang
  47. str = str.replace(/ {2,}/igm,' ') //compress 2+ spaces into just one
  48. }
  49. return str = url + str
  50. }
  51. });