User:Macaw*/NBE.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | This user script seems to have a documentation page at User:Macaw*/NBE. |
// NBE or Not Bad Edits was created by Macaw*
// NBE is not a fork, but it uses code from other user scripts because I don’t know how to make Wikipedia bend to my will.
// CONFIGURATION
const enableMissingCoordinates = '1'; // Enable Missing Coordinates Template Injector
const enableUnreferenced = '1'; // Enable Unreferenced Template Injector
const enableMissingInfo = '1'; // Enable Missing Information Template Injector
// Function to create a new edit form
function createEditForm(content) {
const editForm = document.createElement('form');
editForm.method = 'post';
editForm.action = mw.util.getUrl('Special:Edit');
const textarea = document.createElement('textarea');
textarea.name = 'wpTextbox1';
textarea.value = content;
editForm.appendChild(textarea);
const summary = document.createElement('input');
summary.type = 'hidden';
summary.name = 'wpSummary';
summary.value = "Added Template with [[User:Macaw*/NBE|Not Bad Edits]]";
editForm.appendChild(summary);
const submit = document.createElement('input');
submit.type = 'submit';
submit.value = 'Save Changes';
editForm.appendChild(submit);
document.body.appendChild(editForm);
editForm.submit();
}
// Check if the Missing Coordinates feature is enabled
if (enableMissingCoordinates === '1') {
mw.loader.using('mediawiki.util', function () {
mw.hook('wikipage.content').add(function () { // Wait for the page to load
// Add a link to the "Missing Coordinates" functionality
var link = mw.util.addPortletLink('p-cactions', '#', 'Missing Coordinates', 'Missing Coordinates', 'Mark as missing coordinates.');
$(link).click(function (event) {
event.preventDefault(); // Prevent default link action
const location = prompt("What is the general location of the missing coordinates?");
if (location) {
createEditForm("{{coord missing|" + location + "}}\n");
}
});
});
});
}
// Check if the Missing Information feature is enabled
if (enableMissingInfo === '1') {
mw.loader.using('mediawiki.util', function () {
mw.hook('wikipage.content').add(function () { // Wait for the page to load
// Add a link to the "Missing Information" functionality
var link = mw.util.addPortletLink('p-cactions', '#', 'Missing Information', 'Missing Information', 'Mark as missing information.');
$(link).click(function (event) {
event.preventDefault(); // Prevent default link action
const missingInfo = prompt("What information is this page missing?");
if (missingInfo) {
createEditForm("{{Missing information|" + missingInfo + "}}\n");
}
});
});
});
}
// Check if the Unreferenced feature is enabled
if (enableUnreferenced === '1') {
mw.loader.using('mediawiki.util', function () {
mw.hook('wikipage.content').add(function () { // Wait for the page to load
// Add a link to the "Unreferenced" functionality
var link = mw.util.addPortletLink('p-cactions', '#', 'Unreferenced', 'Unreferenced', 'Mark as unreferenced.');
$(link).click(function (event) {
event.preventDefault(); // Prevent default link action
let date = new Date(); // Get current date
var MonthYearDate = date.toLocaleString('en-US', { year: 'numeric', month: 'long' }); // Format date
createEditForm("{{Unreferenced|date=" + MonthYearDate + "}}\n");
});
});
});
}