User:Andrewds1021/global.js

/* check for Internet Explorer if found: load CSS corrections

if (["MSIE", "Trident/7."].some(function (arg) { return (navigator.userAgent.indexOf(arg) >= 0); })) {   importArticles({        type: "style",        article: "u:w:User:Andrewds1021/IE11.css"    }); }

/* check for "Edit with form" in edit button dropdown if found: check main button for either classic editor or VisualEditor if found: move main button action to top of dropdown move form edit to main button

$(function {    var list_link = document.getElementById("ca-formedit");    if (!list_link) {        return;    }    var list_line = list_link.parentElement;    var list = list_line.parentElement;    var edit_link = list.parentElement.parentElement.previousElementSibling;    var ll_temp = "";    switch (edit_link.id) {        case "ca-viewsource":            ll_temp = list_link.innerHTML;            list_link.innerHTML = edit_link.lastElementChild.innerHTML;            edit_link.lastElementChild.innerHTML = ll_temp;            break;        case "ca-edit":            list_link.accessKey = edit_link.accessKey;            edit_link.removeAttribute("accesskey");            list_link.innerHTML = "Classic editor";            break;        case "ca-ve-edit":            list_link.accessKey = edit_link.accessKey;            edit_link.removeAttribute("accesskey");            list_link.innerHTML = "VisualEditor"; break; default: return; }   ll_temp = list_link.id; list_link.id = edit_link.id; edit_link.id = ll_temp; ll_temp = list_link.getAttribute("data-tracking"); list_link.setAttribute("data-tracking", edit_link.getAttribute("data-tracking")+"-dropdown"); edit_link.setAttribute("data-tracking", ll_temp.replace("-dropdown", "")); ll_temp = list_link.getAttribute("href"); list_link.setAttribute("href", edit_link.getAttribute("href")); edit_link.setAttribute("href", ll_temp); list.insertBefore(list_line, list.firstElementChild); });

/* check for "Create" in main edit button if found: check for both source editor and VisualEditor if found: add "Create with form" as 2nd in dropdown else: add "Create with form" to top of dropdown /* $(function {    var edit_buttons = $(".page-header__contribution-buttons .wds-button-group")[0];    var has_ce_link = document.getElementById("ca-edit");    var has_ve_link = document.getElementById("ca-ve-edit");    if (!edit_buttons || (edit_buttons.firstElementChild.lastElementChild.innerHTML != "Create")) {        return;    }    var list = edit_buttons.lastElementChild.lastElementChild.firstElementChild;    var list_item = document.createElement("li");    var list_link = document.createElement("a");    var link_text = document.createTextNode("Create with form");    list_link.id = "ca-form-create";    list_link.setAttribute("data-tracking", "ca-form-create-dropdown");    list_link.setAttribute("href", "/wiki/Special:FormStart?tfl_formstart_pagename="+location.pathname.substr(6));    list_link.appendChild(link_text);    list_item.appendChild(list_link);    list.insertBefore(list_item, list.firstElementChild); });