Greasy Fork is available in English.
Disable submit unless images use ptpimg.me and album_desc has proper format.
当前为
// ==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);
})();