Hitomi语言设置

将所有语言页面更改为特定语言结果页面。

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name:ko           Hitomi 언어 설정
// @name              Hitomi Language Settings
// @name:ru           Hitomi Настройка языка
// @name:ja           Hitomi言語設定
// @name:zh-TW        Hitomi語言設置
// @name:zh-CN        Hitomi语言设置

// @description:ko    모든 언어 페이지를 특정 언어 결과 페이지로 변경합니다.
// @description       Change all language page to specific language result page.
// @description:ru    Измените все языковые страницы на страницы результатов на определенном языке.
// @description:ja    すべての言語ページを特定の言語結果ページに変更します。
// @description:zh-TW 將所有語言頁面更改爲特定語言結果頁面。
// @description:zh-CN 将所有语言页面更改为特定语言结果页面。

// @namespace         https://ndaesik.tistory.com/
// @version           2023.05.01.05.26
// @author            ndaesik
// @icon              https://t2.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=http://hitomi.la
// @match             https://*.la/*

// @grant             GM.getValue
// @grant             GM.setValue
// @grant             GM_registerMenuCommand
// ==/UserScript==
if (window.location.hostname === 'hitomi.la') {
(async () => {
(await GM.getValue('custom') == undefined) ? GM.setValue('custom', '') : await GM.getValue('custom')
let cst = (await GM.getValue('custom') || '').toLowerCase()
  , set = _ => {GM.setValue('custom', window.prompt('Type your language',)); window.location.reload()}
  , nav = {id:'indonesian',ca:'catalan',cs:'czech',da:'danish',de:'german',et:'estonian',en:'english',es:'spanish',eo:'esperanto',fr:'french',
           hi:'hindi',it:'italian',hu:'hungarian',nl:'dutch',nb:'norwegian',pl:'polish',pt:'portuguese',ro:'romanian',sq:'albanian',sk:'slovak',
           sr:'serbian',fi:'finnish',sv:'swedish',tl:'tagalog',vi:'vietnamese',tr:'turkish',el:'greek',bg:'bulgarian',mn:'mongolian',ru:'russian',
           uk:'ukrainian',he:'hebrew',ar:'arabic',th:'thai',ko:'korean',zh:'chinese',ja:'japanese'}
  , txt = (cst == '') ? nav[window.navigator.language.substring(0,2)] : cst
  , mov = _ => {window.location = window.location.toString().replace(/-all\./, `-${txt}\.`)}
  , tar = document.querySelector('#lang > a')

document.querySelector('#logo > a')?.setAttribute('href', `https://hitomi.la/index-${txt}.html`);
if (document.URL.indexOf(`-${txt}\.`) > -1) {
    window.onpopstate = _ => history.go(-2)
    history.pushState({}, '')
}
if (document.URL.indexOf('-all.html') > -1) mov()
if (tar) {
    tar.href = `https://hitomi.la/index-${txt}.html`
    tar.innerHTML = `${txt}<img src="//ltn.hitomi.la/down-arrow.png">`
    tar.style.cssText = 'padding: 0 10px; width: 150px; display: inline-block'}
GM_registerMenuCommand('Set your language', set)
})()
}