e621 Deleted Post Source Opener

If an e621 post has "status: deleted", this script opens the source URL in a new tab, prioritizing sources other than Inkbunny.

Verzia zo dňa 18.07.2025. Pozri najnovšiu verziu.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, Greasemonkey alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, % alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, % alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey alebo Userscripts.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie správcu používateľských skriptov.

(Už mám správcu používateľských skriptov, nechajte ma ho nainštalovať!)

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

(Už mám správcu používateľských štýlov, nechajte ma ho nainštalovať!)

// ==UserScript==
// @name         e621 Deleted Post Source Opener
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  If an e621 post has "status: deleted", this script opens the source URL in a new tab, prioritizing sources other than Inkbunny.
// @author       Gemini
// @match        https://e621.net/posts/*
// @grant        GM_openInTab
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';

    // 1. Check if the post is deleted.
    // Search for the list item containing "Status:" and check if it includes the word "Deleted".
    const infoListItems = document.querySelectorAll('#post-information ul li');
    let isDeleted = false;

    infoListItems.forEach(li => {
        const text = li.innerText.trim();
        if (text.startsWith('Status:') && text.includes('Deleted')) {
            isDeleted = true;
        }
    });

    // If the post is not deleted, do nothing.
    if (!isDeleted) {
        console.log('e621 Deleted Opener: Post not deleted.');
        return;
    }

    console.log('e621 Deleted Opener: Post is deleted. Searching for source...');

    // 2. Find all available source links.
    const sourceLinkElements = document.querySelectorAll('li.source-links a');
    if (sourceLinkElements.length === 0) {
        console.log('e621 Deleted Opener: Source links not found.');
        return;
    }

    const allSources = Array.from(sourceLinkElements).map(a => a.href);

    // 3. Prioritize sources that are not Inkbunny.
    let preferredSource = null;
    const nonInkbunnySources = allSources.filter(url => !url.includes('inkbunny.net'));

    if (nonInkbunnySources.length > 0) {
        // Found at least one source that is not Inkbunny.
        preferredSource = nonInkbunnySources[0];
        console.log(`e621 Deleted Opener: Selected a non-Inkbunny source: ${preferredSource}`);
    } else if (allSources.length > 0) {
        // No other sources found, so use the first available link.
        preferredSource = allSources[0];
        console.log(`e621 Deleted Opener: Only an Inkbunny (or other) source was found. Using: ${preferredSource}`);
    }

    // 4. Open the selected source in a new tab.
    if (preferredSource) {
        // A short delay to avoid issues with pop-up blockers.
        setTimeout(() => {
            console.log(`e621 Deleted Opener: Opening ${preferredSource} in a new tab.`);
            GM_openInTab(preferredSource, { active: true });
        }, 500);
    } else {
        console.log('e621 Deleted Opener: Could not determine a source to open.');
    }
})();