User:PhiH2/common.js

mw.loader.using( 'mediawiki.util', function {

// Wait for the page to be parsed $( document ).ready( function {

var redirects = document.getElementsByClassName("mw-redirect"); for (var i = 0; i < redirects.length; i++) { var h = redirects[i].href.split('/'); redirects[i].href = "https://en.wikipedia.org/w/index.php?title=" + h[h.length - 1] + "&redirect=no"; }	var link1 = mw.util.addPortletLink( 'p-views', '#', 'Disable redirect', 'disable', 'Disable redirect'); $( link1 ).click( function ( event ) {		event.preventDefault;		disable;	} );

var link2 = mw.util.addPortletLink( 'p-views', '#', 'Enable redirect', 'enable', 'Enable redirect'); $( link2 ).click( function ( event ) {		event.preventDefault;		enable;	} );

} );

function disable { var promptid = prompt('Wikidata item'); document.editform.wpTextbox1.value = "{" + "{User:PhiH/W|" + promptid + "}}\n" + document.editform.wpTextbox1.value; document.editform.wpSummary.value = 'disable redirect'; document.editform.submit; }

function enable { var f = document.editform.wpTextbox1.value.split('\n'); f = f.splice(1); document.editform.wpTextbox1.value = f.join('\n'); document.editform.wpSummary.value = 'enable redirect'; document.editform.wpMinoredit.checked = true; document.editform.submit; }

} );