User:MC10/FastButtons.js

From Simple English Wikipedia, the free encyclopedia

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
// FastButtons, based on the original work of Racso from Spanish Wikipedia,
// translated by [[User:Macy|Macy]]
// edited by [[User:MC10|MC10]]
// [[User:MC10/FastButtons.js]]
// <nowiki>

var pagina = '',
    mot = '',
    txt = '',
    botones = '',
    usuario = '',
    temporal = '',
    sep = "|",
    biblio = false,
    ufb = '. ([[User:MC10/FastButtons.js|FBs]])',
    dire = "//en.wikipedia.org/w/index.php?title=",
    fin_otro = "edit&borrar=otro-",
    fin_aviso = "edit&aviso=",
    textopruebas = "Warn user:\n—Vandalism:\n1: Level 1\n2: Level 2\n3: Level 3\n4: Level 4\n4im: Level 4im\n \nAdditionally, you may add the article name\nfollowed by a |",
    FBpersonal = false, // Personal configuration
    FBpruebas = true, // Test edits
    FBblanco = true, // Vandalism
    FBne = true, // Nonsense pages
    FBinfra = true, // Attack pages
    FBautopromo = true, // Promotional
    FBbio = true, // A7
    FBband = true, // A7
    FBweb = true, // A7
    FBinc = true, // Nonsense pages
    FBotro = true, // Custom CSD
    FBcommons = true, // Now Commons
    FBimfu = true, // No fair use rationale
    FBwikify = true, // Wikify
    FBunref = true, // Unreferenced
    FBcleanup = true, //   Cleanup
    FBnpov = true, // POV
    FBglobal = true, // Globalize
    FBcedit = true, // Copyedit
    FBborrar = false, // Speedy delete (test)
    FBaviso = true, // Warn user
    FBwelcome = false; // Welcome user

// All data is here:
for (i = 0; i < mw.config.get("wgUserGroups").length; i++) {
    if (mw.config.get("wgUserGroups")[i] === "sysop") biblio = true;
}

for (i = 0; i < mw.config.get("wgUserGroups").length; i++) {
    if (mw.config.get("wgUserGroups")[i] === "autoconfirmed") autoconfirmed = true;
}

pagina = encodeURI(mw.config.get("wgPageName"));
if (pagina.match("&")) {
    pagina = pagina.replace("&", "%26");
}
dire = dire + pagina + "&action=";
usuario = pagina.split(":")[1];


if (pagina === "Special:Contributions") {
    usuario = location.href.substring(location.href.indexOf('Contributions/') + 14, location.href.length);
}

// Start
if (biblio) {
    tmp = '';

    if (FBborrar) {
        tmp += '[<a href=' + dire + 'delete&rapido=si>speedy delete!</a>] ';
    }

    if (tmp !== '') {
        botones = botones + 'Sysop buttons: ' + tmp + '<br>';
    }
}

if (!biblio && autoconfirmed) {
    tmp = '';

    if (mw.config.get("wgNamespaceNumber") === 0) {
        if (FBpruebas) {
            tmp += '[<a href=' + dire + 'edit&borrar=blanco>test</a>] ';
        }
        if (FBblanco) {
            tmp += '[<a href=' + dire + 'edit&borrar=pruebas>vandalism</a>] ';
        }
        if (FBne) {
            tmp += '[<a href=' + dire + 'edit&borrar=NE>nonsense</a>] ';
        }
        if (FBinfra) {
            tmp += '[<a href=' + dire + 'edit&borrar=infra>attack</a>] ';
        }
        if (FBautopromo) {
            tmp += '[<a href=' + dire + 'edit&borrar=autopromo>promotional</a>] ';
        }
        if (FBotro) {
            tmp += '[<a onclick="mot=prompt(/Enter reason:/);location.href=dire + fin_otro +encodeURI(mot) ;"> other </a>] ';
        }
        if (FBbio) {
            tmp += '/ A7: <b>[</b><a href=' + dire + 'edit&borrar=bio>person</a> ';
        }
        if (FBband) {
            tmp += '| <a href=' + dire + 'edit&borrar=band>band</a> ';
        }
        if (FBweb) {
            tmp += '| <a href=' + dire + 'edit&borrar=web>web</a> ';
        }
        if (FBinc) {
            tmp += '| <a href=' + dire + 'edit&borrar=inc>inc</a><b>]</b> ';
        }
    } else if (mw.config.get("wgNamespaceNumber") === 6) {
        if (FBimfu) {
            tmp += '[<a href=' + dire + 'edit&borrar=norat>no fair use</a>] ';
        }
        if (FBcommons) {
            tmp += '[<a href=' + dire + 'edit&borrar=commons>commons</a>] ';
        }
    }

    if (tmp !== '') {
        botones = botones + 'CSD: ' + tmp + '<br>';
    }
}


tmp = '';

if (mw.config.get("wgNamespaceNumber") === 0 || mw.config.get("wgNamespaceNumber") === 1) {
    if (FBwikify) {
        tmp += '[<a href=' + dire + 'edit&plant=wikify>wikify</a>] ';
    }
    if (FBunref) {
        tmp += '[<a href=' + dire + 'edit&plant=unref>unreferenced</a>] ';
    }
    if (FBcleanup) {
        tmp += '[<a href=' + dire + 'edit&plant=cleanup>cleanup</a>] ';
    }
    if (FBnpov) {
        tmp += '[<a href=' + dire + 'edit&plant=npov>POV</a>] ';
    }
    if (FBglobal) {
        tmp += '[<a href=' + dire + 'edit&plant=global>globalize</a>] ';
    }
    if (FBcedit) {
        tmp += '[<a href=' + dire + 'edit&plant=cedit>copyedit</a>] ';
    }
}

if (tmp !== '') {
    botones = botones + 'Templates: ' + tmp + '<br>';
}

tmp = '';

if (mw.config.get("wgNamespaceNumber") === 3) {
    if (FBaviso) {
        tmp += '[<a onclick="mot=prompt(textopruebas);location.href=dire + fin_aviso +encodeURI(mot) ;">warn user</a>] ';
    }

    if (FBwelcome) {
        tmp += '[<a href="' + dire + 'edit&plant=welcome">welcome</a>] ';
    }
}

if (tmp !== '') {
    botones = botones + 'Special: ' + tmp + '<br>';
}

/* Botones funcionando */

$(function () {
    if (document.getElementById('contentSub').innerHTML != '') {
        document.getElementById('contentSub').innerHTML += '<br>';
    }

    document.getElementById('contentSub').innerHTML = document.getElementById('contentSub').innerHTML + botones;

    if (location.href.match("borrar=blanco")) {
        txt = document.getElementById("wpTextbox1").value;
        if (!(txt.match("\{db"))) {
            txt = '\{\{db-test}}\n' + txt;
            document.getElementById("wpTextbox1").value = txt;
            document.editform.wpSummary.value = 'Requesting speedy deletion G2' + ufb;
            document.editform.submit();
        }
    } else if (location.href.match("borrar=pruebas")) {
        txt = document.getElementById("wpTextbox1").value;
        if (!(txt.match("\{db")) && (txt !== "")) {
            txt = '\{\{db-vandalism}}\n' + txt;
            document.getElementById("wpTextbox1").value = txt;
            document.editform.wpSummary.value = 'Requesting speedy deletion G3' + ufb;
            document.editform.submit();
        }
    } else if (location.href.match("borrar=NE")) {
        txt = document.getElementById("wpTextbox1").value
        if (!(txt.match("\{db")) && (txt !== "")) {
            txt = '\{\{db-nonsense}}\n' + txt
            document.getElementById("wpTextbox1").value = txt;
            document.editform.wpSummary.value = 'Requesting speedy deletion G1' + ufb;
            document.editform.submit();
        }
    } else if (location.href.match("borrar=infra")) {
        txt = document.getElementById("wpTextbox1").value
        if (!(txt.match("\{db")) && (txt !== "")) {
            txt = '\{\{db-attack}}\n' + txt
            document.getElementById("wpTextbox1").value = txt;
            document.editform.wpSummary.value = 'Requesting speedy deletion G10' + ufb;
            document.editform.submit();
        }
    } else if (location.href.match("borrar=autopromo")) {
        txt = document.getElementById("wpTextbox1").value
        if (!(txt.match("\{db")) && (txt !== "")) {
            txt = '\{\{db-g11}}\n' + txt
            document.getElementById("wpTextbox1").value = txt;
            document.editform.wpSummary.value = 'Requesting speedy deletion G11' + ufb;
            document.editform.submit();
        }
    } else if (location.href.match("borrar=otro")) {
        txt = document.getElementById("wpTextbox1").value
        if (!(txt.match("\{db")) && (txt !== "")) {
            mot = location.href.substring(location.href.indexOf('otro-') + 5, location.href.length)
            if (mot != null) {
                txt = '\{\{delete|' + decodeURI(mot) + '}}\n' + txt;
                document.getElementById("wpTextbox1").value = txt;
                document.editform.wpSummary.value = 'Requesting speedy deletion' + ufb;
                document.editform.submit();
            }
        }
    } else if (location.href.match("borrar=norat")) {
        txt = document.getElementById("wpTextbox1").value
        if (!(txt.match("\{db")) && (txt !== "")) {
            txt = '\{\{db-i8}}\n' + txt
            document.getElementById("wpTextbox1").value = txt;
            document.editform.wpSummary.value = 'Requesting speedy deletion I8' + ufb;
            document.editform.submit();
        }
    } else if (location.href.match("borrar=commons")) {
        txt = document.getElementById("wpTextbox1").value
        if (!(txt.match("\{db")) && (txt !== "")) {
            txt = '\{\{db-i6}}\n' + txt
            document.getElementById("wpTextbox1").value = txt;
            document.editform.wpSummary.value = 'Requesting speedy deletion I6' + ufb;
            document.editform.submit();
        }
    } else if (location.href.match("borrar=bio")) {
        txt = document.getElementById("wpTextbox1").value
        if (!(txt.match("\{db")) && (txt !== "")) {
            txt = '\{\{db-person}}\n' + txt
            document.getElementById("wpTextbox1").value = txt;
            document.editform.wpSummary.value = 'Requesting speedy deletion A7' + ufb;
            document.editform.submit();
        }
    } else if (location.href.match("borrar=band")) {
        txt = document.getElementById("wpTextbox1").value
        if (!(txt.match("\{db")) && (txt !== "")) {
            txt = '\{\{db-band}}\n' + txt
            document.getElementById("wpTextbox1").value = txt;
            document.editform.wpSummary.value = 'Requesting speedy deletion A7' + ufb;
            document.editform.submit();
        }
    } else if (location.href.match("borrar=web")) {
        txt = document.getElementById("wpTextbox1").value
        if (!(txt.match("\{db")) && (txt !== "")) {
            txt = '\{\{db-web}}\n' + txt
            document.getElementById("wpTextbox1").value = txt;
            document.editform.wpSummary.value = 'Requesting speedy deletion A7' + ufb;
            document.editform.submit();
        }
    } else if (location.href.match("borrar=inc")) {
        txt = document.getElementById("wpTextbox1").value
        if (!(txt.match("{db")) && (txt !== "")) {
            txt = '\{\{db-inc}}\n' + txt
            document.getElementById("wpTextbox1").value = txt;
            document.editform.wpSummary.value = 'Requesting speedy deletion A7' + ufb;
            document.editform.submit();
        }
    } else if (location.href.match("plant=wikify")) {
        txt = document.getElementById("wpTextbox1").value
        if (!(txt.match("\{wikify")) && (txt !== "")) {
            txt = '\{\{wikify|date=October 2011}}\n' + txt;
            document.getElementById("wpTextbox1").value = txt;
            document.editform.wpSummary.value = 'Tagged with \{\{wikify}}' + ufb;
            document.editform.submit();
        }
    } else if (location.href.match("plant=unref")) {
        txt = document.getElementById("wpTextbox1").value
        if (!(txt.match("\{unreferenced")) && (txt !== "")) {
            txt = '\{\{unreferenced|date=October 2011}}\n' + txt;
            document.getElementById("wpTextbox1").value = txt;
            document.editform.wpSummary.value = 'Tagged with \{\{unreferenced}}' + ufb;
            document.editform.submit();
        }
    } else if (location.href.match("plant=cleanup")) {
        txt = document.getElementById("wpTextbox1").value
        if (!(txt.match("{cleanup")) && (txt !== "")) {
            txt = '\{\{cleanup|date=October 2011}}\n' + txt;
            document.getElementById("wpTextbox1").value = txt;
            document.editform.wpSummary.value = 'Tagged with \{\{cleanup}}' + ufb;
            document.editform.wpSave.click();
        }
    } else if (location.href.match("plant=npov")) {
        txt = document.getElementById("wpTextbox1").value
        if (!(txt.match("\{POV")) && (txt !== "")) {
            txt = '\{\{POV|date=October 2011}}\n' + txt;
            document.getElementById("wpTextbox1").value = txt;
            document.editform.wpSummary.value = 'Tagged with \{\{POV}}' + ufb;
            document.editform.wpSave.click();
        }
    } else if (location.href.match("plant=global")) {
        txt = document.getElementById("wpTextbox1").value
        if (!(txt.match("\{globalize")) && (txt !== "")) {
            txt = '\{\{globalize|date=October 2011}}\n' + txt;
            document.getElementById("wpTextbox1").value = txt;
            document.editform.wpSummary.value = 'Tagged with \{\{globalize}}' + ufb;
            document.editform.wpSave.click();
        }
    } else if (location.href.match("plant=cedit")) {
        txt = document.getElementById("wpTextbox1").value
        if (!(txt.match("\{copyedit")) && (txt !== "")) {
            txt = '\{\{copyedit|date=October 2011}}\n' + txt;
            document.getElementById("wpTextbox1").value = txt;
            document.editform.wpSummary.value = 'Tagged with \{\{copyedit}}' + ufb;
            document.editform.submit();
        }
    } else if (location.href.match("plant=welcome")) {
        txt = document.getElementById("wpTextbox1").value
        if (!(txt.match("\{welcome"))) {
            txt = '\{\{subst:User:MC10/Welcome}}\n' + txt;
            document.getElementById("wpTextbox1").value = txt;
            document.editform.wpSummary.value = 'Welcoming user' + ufb;
            document.editform.submit();
        }
    } else if (location.href.match("rapido=si")) {
        document.getElementById("wpConfirmB").click();
    } else if (location.href.match("aviso=")) {
        txt = document.getElementById("wpCombobox1").value;
        mot = location.href.substring(location.href.indexOf('aviso=') + 6, location.href.length);
        txt = txt + '\n\n\{\{subst:uw-vandalism' + decodeURI(mot) + '}} --\~\~\~\~';
        document.getElementById("wpTextbox1").value = txt;
        document.editform.wpSummary.value = 'Warning user' + ufb;
        document.editform.submit();
    }
});

// Special FastButtons start here
// Edit count FastButton
$(function () {
    if (mw.config.get("wgTitle").indexOf("/") !== -1 || document.title.indexOf("- History -") !== -1) // no subpages or history
        return;
    if (mw.config.get("wgCanonicalNamespace") === "User" || mw.config.get("wgCanonicalNamespace") === "User_talk") {
        var username = encodeURIComponent(mw.config.get("wgTitle"));
        var checkurl = "//toolserver.org/~soxred93/count/index.php?name=" + username + "&lang=simple&wiki=wikipedia";

        mw.util.addPortletLink("p-cactions", checkurl, "edc", "ca-contrib", "View edit count by this user");
    }
});

// Special:PrefixIndex FastButton
$(function () {
    if (mw.config.get("wgTitle").indexOf("/") !== -1 || document.title.indexOf("- History -") !== -1) // no subpages or history
        return;
    if (mw.config.get("wgCanonicalNamespace") === "User" || mw.config.get("wgCanonicalNamespace") === "User_talk") {
        var username = encodeURIComponent(mw.config.get("wgTitle"));
        var checkurl = mw.config.get("wgServer") + "/w/index.php?title=Special:PrefixIndex&prefix=" + username + "&namespace=2";

        mw.util.addPortletLink("p-cactions", checkurl, "all pages", "ca-contrib", "List of pages by this user");
    }
});

// </nowiki>
// [[Category:Wikipedia scripts]]