e621 Deleted Post Source Opener

If an e621 post has "status: deleted", this script opens the first available source URL in a new tab.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         e621 Deleted Post Source Opener
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  If an e621 post has "status: deleted", this script opens the first available source URL in a new tab.
// @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 the available source links.
    const sourceLinkElements = document.querySelectorAll('li.source-links a');

    // 3. If a source is found, open the first one in a new tab.
    if (sourceLinkElements.length > 0) {
        const firstSource = sourceLinkElements[0].href;
        console.log(`e621 Deleted Opener: Found source: ${firstSource}`);

        // A short delay to avoid issues with pop-up blockers.
        setTimeout(() => {
            console.log(`e621 Deleted Opener: Opening ${firstSource} in a new tab.`);
            GM_openInTab(firstSource, { active: true });
        }, 500);
    } else {
        console.log('e621 Deleted Opener: Source links not found.');
    }
})();