While working on mod documentation for the MC player community wiki, I kept running into the same repetitive task: uploading large numbers of item texture images.

The wiki has the MsUpload plugin installed, so batch uploads are possible, but it does not let you choose a license during the process. That is a real problem on a site where the moderation rules explicitly say that leaving the license blank, or filling it in incorrectly, can lead to penalties.

This comes up a lot when editing item and block lists for mods. Those pages often rely on large family-style templates, and the {{ 图标lite }} template is commonly used to display entries in an [icon]text format. If the corresponding image file has not been uploaded yet, a question mark appears before the text. Clicking that question mark takes you straight to the file upload page.

Because I wanted to move through that page faster—and avoid repeatedly typing the file description and license by hand—I put together a small userscript.

It does two simple things automatically:

  • fills in the file description as [[分类:MOD材质]]
  • sets the license field to License CC-BY

On top of that, it adds two keyboard shortcuts:

  • press A to open the file picker
  • press S to submit the upload form

The script is meant to run on this page pattern:

https://wiki.biligame.com/mcplayer/index.php?title=特殊:上传文件*

With that in place, the upload page opens with the description and license already filled out, so the whole process becomes much quicker.

Here is the full script:

// ==UserScript==
// @name MCPlayerWiki上传文件插件
// @namespace https://fang.blog.miri.site/
// @version 0.1
// @description 用这个插件的人要懒死了
// @author Mr_Fang
// @match https://wiki.biligame.com/mcplayer/index.php?title=%E7%89%B9%E6%AE%8A:%E4%B8%8A%E4%BC%A0%E6%96%87%E4%BB%B6*
// @grant none
// ==/UserScript==
(function() {
 $("#wpUploadDescription").text("[[分类:MOD材质]]"); // 自动填充描述
 $("#wpLicense").get(0).value = "License CC-BY"; // 自动填充协议
 $(document).ready(function() {
 $(window).on('keypress', function(e) {
 if (e.keyCode === 97) $('#wpUploadFile').trigger('click'); // A 添加文件
 if (e.keyCode === 115) $('.mw-htmlform-submit').trigger('click'); // S 上传文件
 })
 })
})();

Before writing the full userscript, the core logic was just this:

$("#wpUploadDescription").text("[[分类:MOD材质]]"); // 自动填充描述
$("#wpLicense").get(0).value = "License CC-BY"; // 自动填充协议
$(document).ready(function() {
 $(window).on('keypress', function(e) {
 if (e.keyCode === 97) $('#wpUploadFile').trigger('click'); // A 添加文件
 if (e.keyCode === 115) $('.mw-htmlform-submit').trigger('click'); // S 上传文件
 })
})

It is a very small tool, but for a workflow built around repeatedly jumping from missing icon links to the upload page, it saves a surprising amount of time.