language searcher - nhentai.net

2023/12/5 下午10:54:48

  1. // ==UserScript==
  2. // @name language searcher - nhentai.net
  3. // @namespace Violentmonkey Scripts
  4. // @match https://nhentai.net/*
  5. // @grant none
  6. // @version 1.1
  7. // @author retiym
  8. // @license MIT
  9. // @description 2023/12/5 下午10:54:48
  10. // ==/UserScript==
  11.  
  12. const language = {
  13. "ch": "chinese",
  14. "en": "english",
  15. "jp": "japanese"
  16. }
  17.  
  18. const title_row = document.getElementsByTagName('h1')[0];
  19.  
  20. const style = document.createElement("style");
  21.  
  22. style.innerHTML = `
  23. .searcher_btn {
  24. width: 40px;
  25. height: 40px;
  26. user-select: none;
  27. background-color: #595959;
  28. border-radius: 4px;
  29. font-size: 20px;
  30. line-height: 40px;
  31. }
  32. `
  33. document.head.appendChild(style)
  34.  
  35. const getSearchTarget = () => {
  36. const url = window.location.pathname.split('/').filter((item) => item);
  37. const [category, name] = url
  38.  
  39. if (category == 'g') return
  40.  
  41. Object.entries(language).map(([key, value]) => {
  42. const destination = `/search/?q=${category}%3A${name}+%26%26+language%3A${value}`
  43. const btn = document.createElement("a")
  44. btn.appendChild(document.createTextNode(key));
  45. btn.classList.add('searcher_btn');
  46. btn.classList.add("tag");
  47. btn.setAttribute("href", destination);
  48.  
  49. title_row.appendChild(btn);
  50. })
  51. }
  52.  
  53. getSearchTarget();