From Test-Scratch-Wiki

< User:-iviedwall-

m (Fixed a bug)
(Added link)
 
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
/* Remove lang attribute from editor so the font is more readable (not having syntax highlight is enough) */
+
var delayInMilliseconds = 500; //.5 seconds
document.getElementById("wpTextbox1").removeAttribute("lang");
+
setTimeout(function() {
/* Add semicolon */
+
    /* Remove lang attribute from editor so the font is more readable (not having syntax highlight is enough) */
const scDiv = document.createElement("div");
+
    if (['edit', 'submit'].includes(mw.config.get('wgAction'))) { //Only work if you are editing, otherwise the getElementById will return NULL and my code will break
const semicolon = document.createTextNode("  ;");
+
        document.getElementById("wpTextbox1").removeAttribute("lang")
scDiv.appendChild(semicolon);
+
    }
const notNav = document.getElementById("not-nav");
+
    console.log('Successfully changed editor appearance')
notNav.appendChild(scDiv);
+
 
/* Add status to left navbar */
+
    /* Add semicolon */
const statusLI = document.createElement("li");
+
    const scDiv = document.createElement("div")
statusLI.setAttribute("id", "n-Your-Status");
+
    const semicolon = document.createTextNode("  ;")
const statusLink = document.createElement("a");
+
    scDiv.appendChild(semicolon)
statusLink.setAttribute("href", "/wiki/Special:MyPage/status");
+
    const notNav = document.getElementById("not-nav")
statusLink.appendChild(document.createTextNode("Your Status"));
+
    notNav.appendChild(scDiv)
statusLI.appendChild(statusLink);
+
    console.log('Successfully added semicolons')
const nEdit = document.getElementById("n-Edit");
+
 
const parentBox = nEdit.parentNode;
+
    /* Add links to left navbar */
parentBox.insertBefore(statusLI, nEdit)
+
    const statusLI = document.createElement("li")
/* Removing some interwikis since I don't use them */
+
    statusLI.setAttribute("id", "n-Your-Status")
document.querySelector('[aria-label="Scratch Wikis"]').remove();
+
    const statusLink = document.createElement("a")
console.log('Loaded');
+
    statusLink.setAttribute("href", "/wiki/Special:MyPage/status")
 +
    statusLink.appendChild(document.createTextNode("Your Status"))
 +
    statusLI.appendChild(statusLink)
 +
    const nEdit = document.getElementById("n-Edit")
 +
    const parentBox1 = nEdit.parentNode
 +
    parentBox1.insertBefore(statusLI, nEdit)
 +
 
 +
    const enwikiLI = document.createElement("li")
 +
    enwikiLI.setAttribute("id", "n-English-Wiki")
 +
    const enwikiLink = document.createElement("a")
 +
    enwikiLink.setAttribute("href", "https://en.scratch-wiki.info")
 +
    enwikiLink.appendChild(document.createTextNode("English Wiki"))
 +
    enwikiLI.appendChild(enwikiLink)
 +
    const recentChanges = document.getElementById("n-recentchanges")
 +
    const parentBox2 = recentChanges.parentNode
 +
    parentBox2.insertBefore(enwikiLI, recentChanges)
 +
 
 +
    const zhwikiLI = document.createElement("li")
 +
    zhwikiLI.setAttribute("id", "n-Chinese-Wiki")
 +
    const zhwikiLink = document.createElement("a")
 +
    zhwikiLink.setAttribute("href", "https://test.scratch-wiki.info/wiki/Zho:首页")
 +
    zhwikiLink.appendChild(document.createTextNode("中文维基"))
 +
    zhwikiLI.appendChild(zhwikiLink)
 +
    parentBox2.insertBefore(zhwikiLI, recentChanges)
 +
 
 +
    /* Removing unnecessary tools on the left of the page */
 +
    document.getElementById("n-mainpage-description").remove()
 +
    document.getElementById("n-FAQ").remove()
 +
    document.querySelector('[aria-label="For Authors"]').remove()
 +
    document.querySelector('[aria-label="Scratch Wikis"]').remove()
 +
    console.log('Successfully changed sidebar tools')
 +
}, delayInMilliseconds); //Delayed

Latest revision as of 02:14, 28 July 2022

var delayInMilliseconds = 500; //.5 seconds
setTimeout(function() {
    /* Remove lang attribute from editor so the font is more readable (not having syntax highlight is enough) */
    if (['edit', 'submit'].includes(mw.config.get('wgAction'))) { //Only work if you are editing, otherwise the getElementById will return NULL and my code will break
        document.getElementById("wpTextbox1").removeAttribute("lang")
    }
    console.log('Successfully changed editor appearance')

    /* Add semicolon */
    const scDiv = document.createElement("div")
    const semicolon = document.createTextNode("  ;")
    scDiv.appendChild(semicolon)
    const notNav = document.getElementById("not-nav")
    notNav.appendChild(scDiv)
    console.log('Successfully added semicolons')

    /* Add links to left navbar */
    const statusLI = document.createElement("li")
    statusLI.setAttribute("id", "n-Your-Status")
    const statusLink = document.createElement("a")
    statusLink.setAttribute("href", "/wiki/Special:MyPage/status")
    statusLink.appendChild(document.createTextNode("Your Status"))
    statusLI.appendChild(statusLink)
    const nEdit = document.getElementById("n-Edit")
    const parentBox1 = nEdit.parentNode
    parentBox1.insertBefore(statusLI, nEdit)

    const enwikiLI = document.createElement("li")
    enwikiLI.setAttribute("id", "n-English-Wiki")
    const enwikiLink = document.createElement("a")
    enwikiLink.setAttribute("href", "https://en.scratch-wiki.info")
    enwikiLink.appendChild(document.createTextNode("English Wiki"))
    enwikiLI.appendChild(enwikiLink)
    const recentChanges = document.getElementById("n-recentchanges")
    const parentBox2 = recentChanges.parentNode
    parentBox2.insertBefore(enwikiLI, recentChanges)

    const zhwikiLI = document.createElement("li")
    zhwikiLI.setAttribute("id", "n-Chinese-Wiki")
    const zhwikiLink = document.createElement("a")
    zhwikiLink.setAttribute("href", "https://test.scratch-wiki.info/wiki/Zho:首页")
    zhwikiLink.appendChild(document.createTextNode("中文维基"))
    zhwikiLI.appendChild(zhwikiLink)
    parentBox2.insertBefore(zhwikiLI, recentChanges)

    /* Removing unnecessary tools on the left of the page */
    document.getElementById("n-mainpage-description").remove()
    document.getElementById("n-FAQ").remove()
    document.querySelector('[aria-label="For Authors"]').remove()
    document.querySelector('[aria-label="Scratch Wikis"]').remove()
    console.log('Successfully changed sidebar tools')
}, delayInMilliseconds); //Delayed
Cookies help us deliver our services. By using our services, you agree to our use of cookies.