// ==UserScript== // @name GGn Unified OST Uploady // @version 1.0 // @author SleepingGiant // @description Uploady for multi-source OSTs on GGn (e.g. VGMdb, bandcamp, etc.) // @namespace https://greasyfork.org/users/1395131 // @match https://gazellegames.net/torrents.php?id=* // @grant none // @downloadURL none // ==/UserScript== (function () { 'use strict'; function ensureVerticalCornerContainer() { let container = document.getElementById('vertical-corner-container'); if (!container) { container = document.createElement('div'); container.id = 'vertical-corner-container'; container.style.position = 'absolute'; // match Multi Reporter script document.body.appendChild(container); const groupDetails = document.getElementById('content'); if (groupDetails) { container.style.left = (groupDetails.offsetLeft + groupDetails.offsetWidth) + 'px'; container.style.top = groupDetails.offsetTop + 'px'; } } return container; } function insertExpandAllButton() { const container = ensureVerticalCornerContainer(); const expandButton = document.createElement('button'); expandButton.textContent = 'Expand All'; expandButton.type = 'button'; expandButton.style.writingMode = 'vertical-lr'; expandButton.style.height = 'unset'; expandButton.style.margin = '4px 0'; expandButton.id = 'expand-all-button'; // so we can reference it later expandButton.onclick = () => { expandAll(); }; container.appendChild(expandButton); } function insertInlineEditionButtons() { const editions = document.querySelectorAll('.edition_info'); editions.forEach(edition => { const btn = document.createElement('button'); btn.textContent = 'Expand Edition'; btn.style.marginLeft = '10px'; btn.type = 'button'; btn.classList.add('expand-edition-button'); btn.onclick = (e) => { e.stopPropagation(); // Don't trigger edition row collapse toggle expandSingleEdition(edition); }; edition.appendChild(btn); }); } function expandAll() { document.querySelectorAll('.edition_info').forEach(edition => { const editionIdMatch = edition.getAttribute('onclick')?.match(/#edition_(\d+)/); if (editionIdMatch) { const tbody = document.getElementById(`edition_${editionIdMatch[1]}`); if (tbody && tbody.style.display === 'none') { edition.click(); } } }); document.querySelectorAll('a[onclick*="torrent_"]').forEach(a => { const targetIdMatch = a.getAttribute('onclick').match(/#torrent_(\d+)/); if (targetIdMatch) { const torrentRow = document.getElementById(`torrent_${targetIdMatch[1]}`); if (torrentRow && torrentRow.classList.contains('hidden')) { a.click(); } } }); document.querySelectorAll('a[onclick^="show_files"]').forEach(a => { const fileId = a.getAttribute('onclick').match(/\d+/)?.[0]; const filesDiv = document.getElementById(`files_${fileId}`); if (filesDiv && filesDiv.classList.contains('hidden')) { a.click(); } }); } function expandSingleEdition(edition) { const editionIdMatch = edition.getAttribute('onclick')?.match(/#edition_(\d+)/); if (editionIdMatch) { const editionId = editionIdMatch[1]; const tbody = document.getElementById(`edition_${editionId}`); if (tbody && tbody.style.display === 'none') { edition.click(); } if (tbody) { tbody.querySelectorAll('a[onclick*="torrent_"]').forEach(a => { const torrentIdMatch = a.getAttribute('onclick').match(/#torrent_(\d+)/); if (torrentIdMatch) { const torrentRow = document.getElementById(`torrent_${torrentIdMatch[1]}`); if (torrentRow && torrentRow.classList.contains('hidden')) { a.click(); } } }); tbody.querySelectorAll('a[onclick^="show_files"]').forEach(a => { const fileId = a.getAttribute('onclick').match(/\d+/)?.[0]; const filesDiv = document.getElementById(`files_${fileId}`); if (filesDiv && filesDiv.classList.contains('hidden')) { a.click(); } }); } } } const loader = setInterval(() => { if (document.getElementById('expand-all-button') || document.querySelector('.expand-edition-button')) { clearInterval(loader); } else { insertExpandAllButton(); insertInlineEditionButtons(); } }, 200); })();