User:Alien333/dab.js

/* global $, mw */ "use strict"; mw.loader.using(['mediawiki.util'], => {

$( => {  	if (mw.config.get('wgCanonicalNamespace') != '') {  		return;  	}	var simbtn = mw.util.addPortletLink("p-tb", '#', 'Similar', 'similar', "Add a similar at top of page.");	$(simbtn).click(event => { event.preventDefault; similar; }); }); }); function similar  {	if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) < 0) { // if not editing        // going to do something here eventually, using APIs    } else {    	var s = $("#wpTextbox1").val;    	var a = mw.config.get('wgPageName').split("/");    	var dabbpage = a[a.length-1].split("_(")[0].replaceAll("_", " "); $("#wpTextbox1").val("\n" + s); } }