If an e621 post has "status: deleted", this script opens the first available source URL in a new tab.
// ==UserScript==
// @name e621 Deleted Post Source Opener
// @namespace http://tampermonkey.net/
// @version 1.2
// @description If an e621 post has "status: deleted", this script opens the first available source URL in a new tab.
// @author Gemini 3 Flash
// @match https://e621.net/posts/*
// @grant GM_openInTab
// @run-at document-idle
// ==/UserScript==
(function() {
'use strict';
// 1. Check if the post is deleted.
// The most reliable way on the new e621 is to check for the presence of the 'notice-deleted' class
// or an attribute in the #image-container.
const imageContainer = document.querySelector('#image-container');
const deleteNotice = document.querySelector('.notice-deleted');
let isDeleted = false;
if (deleteNotice) {
isDeleted = true;
} else if (imageContainer && imageContainer.getAttribute('data-flags')) {
isDeleted = imageContainer.getAttribute('data-flags').includes('deleted');
}
if (!isDeleted) {
console.log('e621 Deleted Opener: Post is not deleted.');
return;
}
console.log('e621 Deleted Opener: Post is deleted. Searching for source...');
// 2. Look for source links.
// On e621, links are located inside li.source-links.
// We take only those that lead to external sites (excluding the "Source:" text).
const sourceLinks = document.querySelectorAll('li.source-links .source-link a');
if (sourceLinks.length > 0) {
const firstSource = sourceLinks[0].href;
console.log(`e621 Deleted Opener: Source found: ${firstSource}`);
// Small delay to bypass popup 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.');
}
})();