language searcher - nhentai.net

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

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

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