User:TheManishPanwar/VisualEditorEverywhere.js

// mw.hook( 'wikipage.content' ).add( function {    // Disable on namespaces: main, user    if ([0, 2].includes(mw.config.get('wgNamespaceNumber'))) {        return;    }

let articleName = mw.config.get('wgPageName'); articleName = encodeURIComponent(articleName); // fix bug involving & not getting converted to &amp; let buttonIsPresent = $('#ca-ve-edit').length; let pageIsUserScript = articleName.match(/(?:\.js|\.css)$/);

if (buttonIsPresent || pageIsUserScript) { return; }

// Insert Edit tab at top of page

let htmlToInsert; let existingEdit = $('#ca-edit span').text;

if ('Edit' === existingEdit) { htmlToInsert = 'Edit source'; $('#ca-edit').after(htmlToInsert); } else { htmlToInsert = 'Edit'; $('#ca-edit').before(htmlToInsert); }

$('#ca-ve-edit').show;

// Insert [ edit ] by each section $('.mw-editsection').each(function(i) {       if ('Edit' === existingEdit) {            // Add "edit source"            htmlToInsert = ' |    edit source';            $('.mw-editsection').eq(i).children('span:last-of-type').before(htmlToInsert);        } else {            // Add "edit"            htmlToInsert = 'edit    | ';            $('.mw-editsection').eq(i).children('span:first-of-type').after(htmlToInsert);        }    });

$('.mw-editsection-visualeditor, .mw-editsection-divider').show; }); //