E/Ex-Hentai Exclude Uploader Button

Adds "exclude" button next to uploaders name on gallery page for quickly adding them to Excluded Uploaders list

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name        E/Ex-Hentai Exclude Uploader Button
// @author      vodka
// @namespace   https://greasyfork.org/en/users/1392773
// @version     1.0
// @match       https://e-hentai.org/g/*
// @match       https://exhentai.org/g/*
// @icon        https://e-hentai.org/favicon.ico
// @description Adds "exclude" button next to uploaders name on gallery page for quickly adding them to Excluded Uploaders list
// @run-at      document-end
// @license     WTFPL
// ==/UserScript==

(function() {
    'use strict';

    const baseUrl = location.origin + '/uconfig.php';

    const uploaderLink = document.querySelector('#gdn a:first-child');
    if (!uploaderLink) return;

    const uploader = uploaderLink.textContent.trim();

    const button = document.createElement('button');
    button.textContent = 'Exclude';
    button.style.marginLeft = '5px';
    button.onclick = () => {
        if (confirm('Exclude ' + uploader + '?')) excludeUploader(uploader);
    };

    uploaderLink.parentNode.insertBefore(button, uploaderLink.nextSibling);

    function excludeUploader(uploader) {
        const xhr = new XMLHttpRequest();
        xhr.open('GET', baseUrl, true);
        xhr.onload = () => {
            if (xhr.status !== 200) return alert('Error loading settings');

            const parser = new DOMParser();
            const doc = parser.parseFromString(xhr.responseText, 'text/html');

            const excludedTextarea = doc.querySelector('textarea#xu');
            if (!excludedTextarea) return alert('Excluded Uploaders field not found');

            let current = excludedTextarea.value.trim().split('\n').map(s => s.trim()).filter(Boolean);
            if (!current.includes(uploader)) {
                current.push(uploader);
                excludedTextarea.value = current.join('\n');
            }

            const form = excludedTextarea.closest('form');
            if (!form) return alert('Form not found');

            const formData = new FormData(form);
            formData.append('apply', 'Apply');

            const postXhr = new XMLHttpRequest();
            postXhr.open('POST', baseUrl, true);
            postXhr.onload = () => {
                alert(postXhr.status === 200 ? 'Success' : 'Error');
            };
            postXhr.send(formData);
        };
        xhr.send();
    }
})();