Greasy Fork

Greasy Fork is available in English.

GGn PTPImg Enforcer

Disable submit unless images use ptpimg.me and album_desc has proper format.

当前为 2025-04-28 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         GGn PTPImg Enforcer
// @namespace    http://greasyfork.icu/users/1395131
// @version      2.0.1
// @author       SleepingGiant
// @description  Disable submit unless images use ptpimg.me and album_desc has proper format.
// @require      https://update.greasyfork.icu/scripts/533781/1578387/GGn%20Upload%20Blocker%20Manager.js
// @include      https://gazellegames.net/upload.php*
// @match        https://gazellegames.net/torrents.php?action=editgroup*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    const COVER_SEL = 'input[name="image"]';
    const SCREENSHOTS_SEL = '#image_block input[name="screens[]"]';
    const REASON_TEXT = 'All images must be hosted on ptpimg.me.';

    function isValidImageURL(url) {
        return url.includes('ptpimg.me');
    }

    function allURLsValid() {
        const cover = document.querySelector(COVER_SEL);
        if (!cover || !isValidImageURL(cover.value.trim())) return false;

        for (let inp of document.querySelectorAll(SCREENSHOTS_SEL)) {
            if (!isValidImageURL(inp.value.trim())) return false;
        }
        return true;
    }

    function refresh(mgr) {
        if (!allURLsValid()) {
            mgr.addReason(REASON_TEXT);
        } else {
            mgr.removeReason(REASON_TEXT);
        }
    }

    const finder = setInterval(() => {
        if (document.readyState !== 'complete') return;

        const submitBtn = document.querySelector('#post, input[type="submit"][value="Submit"]');
        if (!submitBtn) return;

        const mgr = new UploadBlockerManager(submitBtn);
        mgr.attachOverrideCheckbox();

        clearInterval(finder);

        setInterval(() => refresh(mgr), 500);
    }, 500);
})();