Greasy Fork

Greasy Fork is available in English.

GGn Upload Buttons

try to take over the world :)

当前为 2022-10-07 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         GGn Upload Buttons
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  try to take over the world :)
// @author       BestGrapeLeaves
// @match        https://gazellegames.net/upload.php*
// @icon         https://i.pinimg.com/originals/cf/6f/83/cf6f83ff54e90f10cf2cf5f52c3e0a16.png
// @license      MIT
// ==/UserScript==

// == HELPERS == //
function hook(name, cb) {
    // blah blah eval is bad shhhh
    // accessing from window is not an option due to tampermonkey sandboxing
    const oldFn = eval(name);
    const newFn = () => {
        oldFn();
        cb();
    }

    eval(`${name} = newFn;`);
}

function button(title, cb) {
    const btn = $(`<input type="button" class="ggn-upload-buttons-script-button"/>`);
    btn.val(title);
    btn.click(cb);
    return btn;
}

function itch() {
    $('#miscellaneous').val('DRM Free').change();
    if (!$("#remaster").prop("checked")) {
        $("#remaster").prop("checked", true);
        Remaster();
    }
    $('#remaster_title').val('itch.io');
    $('#remaster_year').val($('#year').val());
}

// == SECTIONS == //
function OSTButtons() {
    console.log('rendost', $('#format'))
    button('FLAC 24', () => {
        $('#format').val('FLAC').change();
        $('#bitrate').val('24bit Lossless').change();
    }).insertAfter('#format');
    button('FLAC', () => {
        $('#format').val('FLAC').change();
        $('#bitrate').val('Lossless').change();
    }).insertAfter('#format');
}

function GamesButtons() {
    const platform = $('#platform').val();

    if (['Windows', 'Mac', 'Linux'].includes(platform)) {
        button('itch.io MLT', () => {
            itch();
            $('#language').val('Multi-Language').change();
        }).insertAfter('#miscellaneous');
        button('itch.io EN', () => {
            itch();
            $('#language').val('English').change();
        }).insertAfter('#miscellaneous');
    }

    if (platform === 'Pen and Paper RPG') {
        $('#miscellaneous').val('E-Book').change();
        $("#format").val("PDF").change();
        $("#digital").click();
        Digital();
        $('#language').val('English').change();
    } else {
        button('Art', () => {
            $('#miscellaneous').val('GameDOX').change();
            $("#gamedox").val("Artwork").change();
            $("#format").val("PDF").change();
            $("#digital").click();
            Digital();
            $('#language').val('English').change();
        }).insertAfter('#miscellaneous');
        button('DLC', () => {
            $('#miscellaneous').val('GameDOX').change();
            $("#gamedox").val("DLC").change();
            $('#language').val('English').change();
        }).insertAfter('#miscellaneous');
    }
}

// == MAIN STUFF == //
function rerender() {
    $('.ggn-upload-buttons-script-button').remove();

    const category = $('#categories').val();
    if (category === "OST") {
        OSTButtons();
    } else if (category === "Games") {
        GamesButtons();
    }
}

(function() {
    'use strict';
    rerender();
    hook('Categories', rerender)
    hook('EmptyGroup', rerender)
    hook('Platform', rerender)
})();