User:Williek11/global.js

importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:MassRollback.js',        'u:dev:MediaWiki:Rollback/code.js',        'u:dev:MediaWiki:AnchoredRollback/code.js',        'u:dev:MediaWiki:UsefulDropdown/code.js',		'u:dev:MediaWiki:RemoveTracking.js',    ] });

mw.loader.using([ 'mediawiki.api' ], function {	console.log('Personal JS: ', new mw.Api);	function getSourceEditorContent {    	const cm = $('.CodeMirror').get(0);    	if (cm) {        	// We're using CodeMirror wikitext syntax highlighting        	return cm.CodeMirror.getValue;    	}    	if (window.ve && ve.init) {        	// We're using VisualEditor source mode.        	return ve.init.target.getSurface.getModel.getHtml;    	}    	return $('#wpTextbox1').text;	}	function askIfLeaving  {		new mw.Api.get({ 'action': 'query', 'fromtitle': location.pathname.replace('/wiki/', ''), 'toslots': 'main', 'totext-main': getSourceEditorContent }).done(function (e) { console.log(e); });	}	const cancelButton = $('#mw-editform-cancel')[0];	const cancelHref = cancelButton.children[0];

if (location.search.includes("action=edit")) { cancelHref.href = '#'; cancelButton.click(function {			askIfLeaving;		}); } });

(function{ const doc = document;

const upperNav = doc.createElement("div"); const ul = doc.createElement("ul"); upperNav.className = "upper-container";

$(".main-container")[0].appendChild(upperNav);

upperNav.appendChild(ul);

function addElement (node, id) { const li = doc.createElement("li"); li.id = id; li.appendChild(node); ul.appendChild(li); }

addElement($(".fandom-community-header__top-container")[0].children[2]); addElement($(".global-navigation__bottom")[0].children[1], "user-profile"); addElement($(".notifications")[0], "notifications");

});