// ==UserScript== // @name Zibzab's GameDox/Rom Upload Helper // @namespace http://tampermonkey.net/ // @version 1.6 // @description try to take over the world :) // @author BestGrapeLeaves // @match https://gazellegames.net/upload.php?groupid=* // @match https://gazellegames.net/torrents.php?id=* // @icon https://i.imgur.com/UFOk0Iu.png // @grant GM_xmlhttpRequest // @connect datomatic.no-intro.org // @license MIT // @downloadURL none // ==/UserScript== // Code is a spaghetti mess, don't read it. Do something else with your time. (function () { "use strict"; const PARENS_TAGS_REGEX = /\(.*?\)/g; const NO_INTRO_TAGS_REGEX = /\((Unl|Proto|Sample|Aftermarket|Homebrew)\)|\(Rev \d+\)|\(v[\d\.]+\)|\(Beta(?: \d+)?\)/; const GAME_DOX_INSERT = `[align=center] pdf pages [/align] `; const genRomInsert = ( url = "xxx", filename = "xxx" ) => `[align=center]${filename} matches [url=${url}]No-Intro checksum[/url] Compressed with [url=https://sourceforge.net/projects/trrntzip/]torrentzip.[/url][/align] `; const regionToLanguage = { USA: "English", Europe: "English", Japan: "Japanese", World: "English", "USA, Europe": "English", Other: "English", Korea: "Korean", Taiwan: "Chinese", }; const twoLetterLanguageCodeToGGn = { en: "English", de: "German", fr: "French", cz: "Czech", zh: "Chinese", it: "Italian", ja: "Japanese", ko: "Korean", pl: "Polish", pt: "Portuguese", ru: "Russian", es: "Spanish", }; const parseLanguage = (region, possiblyLanguages) => { if (possiblyLanguages === undefined) { return regionToLanguage[region] || "Other"; } const twoLetterCodes = possiblyLanguages .split(",") .map((l) => l.trim().toLowerCase()); const isLanguages = twoLetterCodes.every((l) => l.length === 2); if (!isLanguages || twoLetterCodes.length === 0) { return regionToLanguage[region] || "Other"; } if (twoLetterCodes.length > 1) { return "Multi-Language"; } return twoLetterLanguageCodeToGGn[twoLetterCodes[0]] || "Other"; }; // Add Copy button, stolen boilerplate shamelessly from trump helper script function insertAddCopyHelpers() { $('a[title="Permalink"]').each(function () { const torrentId = $(this) .attr("href") .replace(/.*?\?torrentid=/, ""); console.log("ac", torrentId); const links = $(`#torrent_${torrentId} #description a`); const noIntroLink = links .filter(function () { return $(this) .attr("href") .startsWith("https://datomatic.no-intro.org/"); }) .first() .attr("href"); if (!noIntroLink) { return; } const editionInfo = $(this) .parents(".group_torrent") .parent() .prev() .find(".group_torrent > td > strong") .text(); // Convert to upload format of edition info const [editionYear, ...rest] = editionInfo.split(" - "); const editionName = rest.join(" - "); const formatedEditionInfo = `${editionName} (${editionYear})`; const groupId = window.location.href.replace(/.*?\?id=/, ""); const params = new URLSearchParams(url.search); params.set("groupid", groupId); params.set("edition", formatedEditionInfo); params.set("no-intro", noIntroLink); const addCopyButton = $( `AC` ); $([" | ", addCopyButton]).insertAfter(this); }); } // No Intro Button function makeNoIntro(filename) { const tags = filename ? filename .match(PARENS_TAGS_REGEX) .filter((p) => NO_INTRO_TAGS_REGEX.test(p)) .join(" ") : ""; // Release type = ROM $("select#miscellaneous").val("ROM").change(); // It is a special edition if (!$("input#remaster").prop("checked")) { $("input#remaster").prop("checked", true); Remaster(); } // Not a scene release $("#ripsrc_home").prop("checked", true); // Update title updateReleaseTitle($("#title").raw().value + " " + tags); // Get url params const params = new URLSearchParams(window.location.search); // Set correct edition (fallback to guessing) const setEdition = (edition) => { try { $("#groupremasters").val(edition).change(); GroupRemaster(); } catch { // group remaster always throws (regardless of the userscript) } }; const editionInfo = params.get("edition"); $("#groupremasters > option").each(function () { const title = $(this).text().toLowerCase(); console.log("checking", title); if (title === editionInfo.toLowerCase()) { setEdition($(this).val()); return false; // This breaks out of the jquery loop } else { if (title.includes("no-intro") || title.includes("nointro")) { setEdition($(this).val()); } } }); // Trigger no-intro link scraper const noIntroLink = params.get("no-intro"); if (noIntroLink) { $("#no-intro-url-input").val(noIntroLink).change(); } } function noIntroUI() { // elements const noIntroContainer = $( `
Loading...
' ).hide(); // structure const td = $("