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, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

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