User:Dimpizzy/scripts/addmissingbutton.js

/* A script to add an Edit button for Visual Editor if the extension is enabled but the button is not showing up. Paste all of this into Mediawiki:Common.js on your wiki.

// Text to be used on button here: label = 'Edit';

// Text for mouse hover: title = 'Edit this page';

// Only run script if not in editor if (!(/veaction=edit/).test(window.location.search)){ // Unhide button if it's just hidden if(document.querySelector("#ca-ve-edit")){ if (document.querySelector("#ca-ve-edit").style.display == 'none'){ document.querySelector("#ca-ve-edit").style.display = 'block'; }   }    // Only run if Edit button does not already exist and Edit source button does exist if((!document.querySelector("#ca-ve-edit") && document.querySelector('#ca-edit'))) { // Edit Source element editSource = document.querySelector("#ca-edit"); // Copy Edit Source element newEdit = editSource.cloneNode(true); // Get current page title pageTitle = document.querySelector('meta[property="og:title"]').content.replace(/\s/g, '_'); // Place correct link and text inside new element newEdit.innerHTML = '' + label + ''; // Change to correct id for new element newEdit.id = 'ca-ve-edit'; // Add new element before Edit Source editSource.before(newEdit); document.querySelector("#ca-ve-edit").style.display = 'inline-block'; } }