User:Natalya-ru/global.js

importArticles({   type: 'script',    articles: [        'u:dev:MediaWiki:Wikificator.js', /* Викификатор */        'u:dev:MediaWiki:MassEdit/code.js', /* Массовые правки */        'u:dev:MediaWiki:AjaxEdit.js', /* Автообновление свежих правок */    ] }); importScriptPage('User:Joeyaa/wham.js','vstf'); //WHAM

mw.loader.load('//internal-soap.fandom.com/wiki/User:Kuzura/scripts-ucp.js?action=raw&ctype=text/javascript&templates=expand');

/*** Открывать ссылку в редакторе при нажатии ctrl ***/ mw.loader.using(["mediawiki.api", "mediawiki.cookie"]).then(   function  {        function checkCookie(cookie, prefix) {            var result;            var c = mw.cookie.get(cookie, prefix);            if (c === null || c === "false") {                result = false;            } else if (c === "true") {                result = true;            }

return result; }

const toolbarButtonWrapper = document.createElement("li"); document.querySelector("#WikiaBar .toolbar .tools").appendChild(toolbarButtonWrapper);

const toolbarButton = document.createElement("a"); toolbarButtonWrapper.appendChild(toolbarButton);

Object.assign(toolbarButton.style, {           display: "flex",            alignItems: "center"        });

const icon = document.createElementNS("http://www.w3.org/2000/svg", "svg"); icon.setAttributeNS(null, "viewBox", "0 0 18 18");

icon.classList.add("wds-icon", "wds-icon-small");

Object.assign(icon.style, {           background: "white",            borderRadius: "3px",            cursor: "pointer",            padding: "2px"        });

switch (checkCookie("openLinksInEditMode", "nkch_")) { case true: icon.style.fill = "var(--theme-success-color)"; break; case false: icon.style.fill = "var(--theme-alert-color)"; break; }

toolbarButton.appendChild(icon);

const iconSrc = document.createElementNS("http://www.w3.org/2000/svg", "use"); iconSrc.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "#wds-icons-external-small"); icon.appendChild(iconSrc);

toolbarButton.addEventListener("click", function {            switch (checkCookie("openLinksInEditMode", "nkch_")) {                case true:                    mw.cookie.set("openLinksInEditMode", "false", { prefix: "nkch_", });                   icon.style.fill = "var(--theme-alert-color)";                    break;                case false:                    mw.cookie.set("openLinksInEditMode", "true", { prefix: "nkch_", });                   icon.style.fill = "var(--theme-success-color)";                    break;            }        });

document.querySelectorAll("#content a:not(.extiw):not(.external):not([href*='?action']):not([href*='" + encodeURI(mw.config.get("wgFormattedNamespaces")[-1]) + ":'])").forEach(           function (link) {                if (link.href.indexOf(location.protocol + "//" + location.hostname) === 0) {                    const linkHref = link.getAttribute("href");

link.addEventListener("mouseover", function (event) {                       setInterval(checkKey(event), 100);                    })

link.addEventListener("mouseout", function (event) {                       link.setAttribute("href", linkHref);                    })

function checkKey(e) { if (checkCookie("openLinksInEditMode", "nkch_") === true) { if (e.ctrlKey) { link.setAttribute("href", linkHref + "?action=edit"); } else { link.setAttribute("href", linkHref); }                       }                    };                };            }        );    } );