User:Mdaniels5757/Easy-permalink.js

// By User:Mdaniels5757, copied and modified from User:DannyS712/Easy-link.js // $(function { var copy_link_config = {	name: 'Easy-permalink.js',	version: 1,	debug: false }; mw.loader.using( 'mediawiki.util', function { $(document).ready( function {     	mw.util.addPortletLink ( 'p-tb', '', 'Easy permalink', 'ca-copy-permalink', 'Copy and format the current link to this revision');    	$('#ca-copy-permalink').on('click', function( e ) { e.preventDefault; copy_link; } );   } ); } ); function copy_link{	section = window.location.hash;	revid = mw.config.get('wgCurRevisionId');	new_url = 'Special:Permalink/' + revid + section + '';	if (copy_link_config.debug) console.log( new_url );	var ignore_this = document.createElement("input");	document.createElement("input");    document.body.appendChild(ignore_this);    ignore_this.setAttribute('value', new_url);    ignore_this.select;    document.execCommand("copy");    document.body.removeChild(ignore_this); } }); //