Jump to content

User:Macaw*/NBE.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Macaw* (talk | contribs) at 13:56, 2 May 2025 (fix bugs). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// NBE or Not Bad Edits was created by Macaw*

// CONFIGURATION: Enable features by setting to '1' or '0'
const enableMissingCoordinates = '1'; 
const enableUnreferenced = '1'; 
const enableMissingInfo = '1'; 

NBE = {}; // Initialize NBE object

NBE.addPortlet = function() {
    let navigation = mw.config.get('skin') === 'vector' || mw.config.get('skin') === 'vector-2022' ? '#right-navigation' : '#page-tools .sidebar-inner';
    let id = 'p-nbe';
    let text = 'NBE';
    let nextnodeid = 'p-cactions';

    const root = document.querySelector(navigation);
    if (!root) return;

    if (!document.getElementById(id)) {
        mw.util.addPortlet(id, text, '#' + nextnodeid);
    }
};

NBE.addPortletLink = function(task, text, id, tooltip) {
    const portletId = NBE.addPortlet();
    mw.util.addPortletLink(portletId, task, text, id, tooltip);
};

if (enableMissingCoordinates === '1') {
    NBE.addPortletLink('#', 'Missing Coordinates', 'missing-coordinates', 'Mark as missing coordinates.');
}

if (enableMissingInfo === '1') {
    NBE.addPortletLink('#', 'Missing Information', 'missing-information', 'Mark as missing information.');
}

if (enableUnreferenced === '1') {
    NBE.addPortletLink('#', 'Unreferenced', 'unreferenced', 'Mark as unreferenced.');
}

NBE.addPortlet();