User:ParkourBot/common.js

/** * @file		EditProfilesButton * @author		Parkour2906 * @status		Beta * @desc		Appends an edit button to other profile pages. Restricted to content moderators and sysops. $(function {   'use strict';    /** EDITORTYPES     *	Visual source editor = 1      *	VisualEditor = 2     *	Source editor = 4    **/    function getEditor {		const editor = mw.user.options.get("editortype");		if (editor === "1") {        	return ['',         	'VisualEditor'        	];        }        else if (editor === "4") {        	return ['',         	'VisualEditor'        	];        }		else if (editor === "2") {        	return ['', 'Edit source' ];       }        else if (editor === "4") { return ['',        	'VisualEditor</a></li>'        	];        }    }    // Prevents the script from running if you do not have the proper rights OR:    // The edit button already exists in the DOM OR:    // The user has not filled out their profile yet    if (mw.config.get("wgCanonicalNamespace") !== "User" ||        $("#ca-edit").length > 0 ||        $(".mw-parser-output").length === 0) {        return;    } else {        const username = mw.config.get("profileUserName");        const editButtonString = getEditor;        $(".page-header__contribution-buttons").append(' ' +            editButtonString[0] +            '<svg class="wds-icon wds-icon-small">' +            '<use xlink:href="#wds-icons-pencil-small">  ' + ' Edit </a>' + ' <div class="wds-button wds-dropdown__toggle">' + '<svg class="wds-icon wds-icon-tiny wds-dropdown__toggle-chevron">' + '<use xlink:href="#wds-icons-dropdown-tiny"> ' + '<div class="wds-dropdown__content wds-is-not-scrollable wds-is-right-aligned">' + '<ul class="wds-list wds-is-linked">' + editButtonString[1] + 'History</a></li>' + 'Protect</a></li>' + 'Delete</a></li>' + 'Message Wall</a></li></ul>  ');    } });