language searcher - nhentai.net

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

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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();