language searcher - nhentai.net

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        language searcher - nhentai.net
// @namespace   Violentmonkey Scripts
// @match       https://nhentai.net/*
// @grant       none
// @version     1.1
// @author      retiym
// @license MIT
// @description 2023/12/5 下午10:54:48
// ==/UserScript==

const language = {
  "ch": "chinese",
  "en": "english",
  "jp": "japanese"
}

const title_row = document.getElementsByTagName('h1')[0];

const style = document.createElement("style");

style.innerHTML = `
  .searcher_btn {
    width: 40px;
    height: 40px;
    user-select: none;
    background-color: #595959;
    border-radius: 4px;
    font-size: 20px;
    line-height: 40px;
  }
`
document.head.appendChild(style)

const getSearchTarget = () => {
  const url = window.location.pathname.split('/').filter((item) => item);
  const [category, name] = url

  if (category == 'g') return

  Object.entries(language).map(([key, value]) => {
    const destination = `/search/?q=${category}%3A${name}+%26%26+language%3A${value}`
    const btn = document.createElement("a")
    btn.appendChild(document.createTextNode(key));
    btn.classList.add('searcher_btn');
    btn.classList.add("tag");
    btn.setAttribute("href", destination);

    title_row.appendChild(btn);
  })
}

getSearchTarget();