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
// 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
AddCoordsNeeded(); // Call function to add missing coordinates template
});
});
});
// Function to add the missing coordinates template
function AddCoordsNeeded() {
if (document.editform) { // Check if the edit form exists
// Insert the missing coordinates template
document.editform.wpTextbox1.value = "{{coord missing|" + prompt("What is the general location of the missing coordinates?") + "}}" + document.editform.wpTextbox1.value;
document.editform.wpSummary.value = "Added Missing Coordinates Template with [[User:Macaw*/NBE|Not Bad Edits]]"; // Set edit summary
document.editform.submit(); // Submit changes
}
}
}
// 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
AddMissingInfo(); // Call function to add missing information template
});
});
});
// Function to add the missing information template
function AddMissingInfo() {
if (document.editform) { // Check if the edit form exists
const missingInfo = prompt("What information is this page missing?"); // Prompt for missing info
// Insert the missing information template
document.editform.wpTextbox1.value = "{{Missing information|" + missingInfo + "}}" + document.editform.wpTextbox1.value;
document.editform.wpSummary.value = "Added Missing Information Template with [[User:Macaw*/NBE|Not Bad Edits]]"; // Set edit summary
document.editform.submit(); // Submit changes
}
}
}
// 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
AddUnref(); // Call function to add unreferenced template
});
});
});
// Function to tag articles as unreferenced
function AddUnref() {
let date = new Date(); // Get current date
var MonthYearDate = date.toLocaleString('en-US', { year: 'numeric', month: 'long' }); // Format date
if (document.editform) { // Check if the edit form exists
// Insert the unreferenced template
document.editform.wpTextbox1.value = "{{Unreferenced|date=" + MonthYearDate + "}}" + document.editform.wpTextbox1.value;
document.editform.wpSummary.value = "Added Unreferenced Template with [[User:Macaw*/NBE|Not Bad Edits]]"; // Set edit summary
document.editform.submit(); // Submit changes
}
}
}