E/Ex-Hentai Exclude Uploader Button

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

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

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

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