User:BMacZero/VerifyLicense.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
Documentation for this user script can be added at User:BMacZero/VerifyLicense. |
// <nowiki>
/*
Helper script for verifying a suggested license template. Called via a special link in the template {{User:BMacZero/VerifyLicense}}.
Author: [[User:BMacZero]] (March 2019)
Derived from [[MediaWiki:Catcheck.js]] by [[User:Lupo]]
License: GPL
*/
/*jshint curly:false*/
/*global mw:false, $:false*/
$(function() {
'use strict';
if (mw.config.get('wgNamespaceNumber') !== 6 || mw.config.get('wgAction') !== 'edit') {
return;
}
window.LicenseCheck =
{
run : function ()
{
var text = document.getElementById ('wpTextbox1');
if (!text) return;
// Remove "User:BMacZero/VerifyLicense" template
text.value = (text.value || "").replace (/\{\{User:BMacZero\/VerifyLicense[^\}\{]*\}\}\n*/g, "");
// Set edit summary
var summary = document.getElementById ('wpSummary');
if (!summary) return;
var val = summary.value || "";
summary.value = val + (val ? ' ' : "") +
"License has been checked - [[:Commons:WikiProject Public Domain/PD-Art review|You can help!]]";
}
};
window.LicenseCheck.run();
});
// </nowiki>