User:TheImaCow/common.js

Source: Wikipedia, the free encyclopedia.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//importScript('User:Evad37/MoveToDraft.js'); // Backlink: [[User:Evad37/MoveToDraft]]
importScript('User:Anomie/diffcur.js'); // Linkback: [[User:Anomie/diffcur.js]]
//importScript('User:Mr. Stradivarius/gadgets/ConfirmRollback.js'); // Linkback: [[User:Mr. Stradivarius/gadgets/ConfirmRollback.js]]
importScript("User:RedWarn/.js"); // who needs a backlink :D
importScript('User:DannyS712/Draft no cat.js');// [[User:DannyS712/Draft no cat.js]]
importScript('User:Mr. Stradivarius/gadgets/Draftify.js'); // Linkback: [[User:Mr. Stradivarius/gadgets/Draftify.js]]
//importScript('User:MusikAnimal/responseHelper.js');
//importScript('User:SD0001/draft-sort-burst.js'); // [[User:SD0001/draft-sort-burst.js]]
importScript('User:Music1201/MyCSD.js'); // 
importScript('User:PrimeHunter/My subpages.js'); //
//importScript( 'User:DannyS712/AjaxRollback.js' );// [[User:DannyS712/AjaxRollback.js]]
//importScript("User:Awesome Aasim/oneclickdelete.js")
importScript('User:SD0001/StubSorter.js'); // [[User:SD0001/StubSorter.js]]
importScript('User:Evad37/rater.js'); // [[User:Evad37/rater]]
importScript('User:SD0001/UnassessedArticleLinks.js'); // [[User:SD0001/UnassessedArticleLinks.js]]
importScript('User:Jackmcbarn/editProtectedHelper.js'); // Backlink: [[User:Jackmcbarn/editProtectedHelper.js]]
importScript('User:Enterprisey/cv-revdel.js'); // Backlink: [[User:Enterprisey/cv-revdel.js]]
importScript('User:Enterprisey/reply-link.js'); // Backlink: [[User:Enterprisey/reply-link.js]]
importScript('User:Enterprisey/talk-tab-count.js'); // Backlink: [[User:Enterprisey/talk-tab-count.js]]
importScript('User:Enterprisey/short-tab-titles.js'); // Backlink: [[User:Enterprisey/short-tab-titles.js]]
//importScript('Wikipedia:AutoEd/complete.js'); // Backlink: [[Wikipedia:AutoEd/complete.js]]
importScript('User:DannyS712/deOrphan.js'); // Backlink: [[User:DannyS712/deOrphan.js]]
importScript('User:Awesome Aasim/editrequest.js'); // Backlink: [[User:Awesome Aasim/editrequest.js]]
//importScript('User:Enterprisey/show-abusefilter-hits.js'); // Backlink: [[User:Enterprisey/show-abusefilter-hits.js]]
importScript('User:Enterprisey/rc-thanks.js'); // Backlink: [[User:Enterprisey/rc-thanks.js]]
importScript('User:BrandonXLF/ReferenceExpander.js'); // Backlink: [[User:BrandonXLF/ReferenceExpander.js]]
importScript(':de:Benutzer:TMg/autoFormatter.js'); // Backlink: [[:de:Benutzer:TMg/autoFormatter.js]]
importScript('User:Headbomb/unreliable.js'); // Backlink: [[User:Headbomb/unreliable.js]]
importScript('User:DannyS712/EFFPRH.js'); // Backlink: [[User:DannyS712/EFFPRH.js]]
//importScript('User:TheImaCow/moresidebarlinks.js'); // Backlink: [[User:TheImaCow/moresidebarlinks.js]]
importScript('User:Enterprisey/strike-archived.js'); // Backlink: [[User:Enterprisey/strike-archived.js]]
importScript('User:Anne_drew_Andrew_and_Drew/SetupAutoArchive.js'); // Backlink: [[User:Anne_drew_Andrew_and_Drew/SetupAutoArchive.js]]
importScript('user:Qwertyytrewqqwerty/DisamAssist.js'); // Backlink: [[user:Qwertyytrewqqwerty/DisamAssist.js]]
importScript('User:Awesome Aasim/xfdvote.js'); // Backlink: [[User:Awesome Aasim/xfdvote.js]]
importScript('User:TheImaCow/Notifiercustom.js'); // Backlink: [[User:TheImaCow/Notifiercustom.js]]
importScript('User:SD0001/shortdescs-in-category.js'); // Backlink: [[User:SD0001/shortdescs-in-category.js]]
//importScript('User:Σ/Testing_facility/Archiver.js'); // Backlink: [[User:Σ/Testing_facility/Archiver.js]]

mw.loader.using( "mediawiki.util" ).then( function () {
    mw.util.addPortletLink("p-navigation", "https://commons.wikimedia.org/wiki/Commons:Freedom_of_panorama#Situation_in_different_countries", "FOP map");
    mw.util.addPortletLink("p-navigation", "https://commons.wikimedia.org/wiki/Commons:Screenshots", "CC screenshots");
    mw.util.addPortletLink("p-navigation", "https://commons.wikimedia.org/wiki/Commons:Copyright_rules_by_subject_matter", "CC other subjects");
    mw.util.addPortletLink("p-navigation", "https://upload.wikimedia.org/wikipedia/commons/thumb/5/52/Derivative_Works_Decision_Tree.svg/546px-Derivative_Works_Decision_Tree.svg.png", "DerivativeWork FChart");
    mw.util.addPortletLink("p-navigation", "https://commons.wikimedia.org/wiki/Commons:Threshold of originality", "C:TOO");
    mw.util.addPortletLink("p-navigation", "https://images.google.com/", "GoogleImageSearch");
    mw.util.addPortletLink('p-navigation', mw.config.get( 'wgServer' ) + '/wiki/Template:Admin dashboard', 'DASHBOARD', 'rh-dashboard');
	mw.util.addPortletLink('p-navigation', mw.config.get( 'wgServer' ) + '/wiki/Wikipedia:Administrator intervention against vandalism', "WP:AIV");
	mw.util.addPortletLink('p-navigation', mw.config.get( 'wgServer' ) + '/wiki/Wikipedia:Requests for permissions', "WP:PERM");
	mw.util.addPortletLink('p-navigation', mw.config.get( 'wgServer' ) + '/wiki/Wikipedia:Requests for page protection', "WP:RFPP");
	mw.util.addPortletLink('p-navigation', mw.config.get( 'wgServer' ) + '/wiki/Wikipedia:Usernames for administrator attention', "WP:UAA");
	mw.util.addPortletLink('p-navigation', mw.config.get( 'wgServer' ) + '/wiki/Wikipedia:Sockpuppet investigations', "WP:SPI");
} );
importScript('User:Epicgenius/commonshelperlink.js'); // Backlink: [[User:Epicgenius/commonshelperlink.js]]
importScript('User:קיפודנחש/cat-a-lot.js'); // Backlink: [[User:קיפודנחש/cat-a-lot.js]]




$.when( mw.loader.using(['mediawiki.util','mediawiki.api']), $.ready).done( function () {
	    if (mw.config.get("wgNamespaceNumber") != 1)
	    if (mw.config.get("wgNamespaceNumber") != 2)
	    	    if (mw.config.get("wgNamespaceNumber") != 3)
	    	    	    if (mw.config.get("wgNamespaceNumber") != 5)
        return;
    $("head").append("<style>a.arkylink { font-weight:bold } .arkyhighlight { background-color:#D9E9FF }</style>");
    var validSections = new Object();
    var fromTos = new Object();
    var wikiText = "";
    var revStamp;
    var startArchiveButton = mw.util.addPortletLink("p-cactions", "#", "ØCA", "pt-oeca", "Enter/exit the archival process", null, null);
    var overlay = $(document.createElement("button"));
    $(startArchiveButton).click(function(e) {
        $(".arkylink").click();
        $(".arky").toggle();
        $("#archivebutton").toggle();
    });
    overlay.html("archive all the selected threads")
        .attr("id", 'archivebutton')
        .css("position", 'sticky')
        .css("bottom", 0)
        .css("width", '100%')
        .css("font-size", '200%');
    $(document.body).append(overlay);
    overlay.toggle();
    overlay.click(function(e) {
        var numOfThreads, archiveTarget;
        var sections, archiveThis;
        var cutOffset, revisedPage;
        function cut(s, start, end) {
            return s.substr(0, start) + s.substring(end);
        }
        cutOffset = numOfThreads = 0;
        revisedPage = wikiText;
        sections = $("a.arkylink").map(function() {
            return $(this).attr("data-section");
        });
        if (!(numOfThreads = sections.length))
            return alert("No threads selected, aborting");
        archiveTarget = prompt("Archiving " + numOfThreads + " threads: where should we move them to? (e.g. Wikipedia:Sandbox/Archive 1)", mw.config.get("wgPageName"));
        if (!archiveTarget || archiveTarget == mw.config.get("wgPageName"))
            return alert("No archive target selected, aborting");
        sections.each(function(i, n) {
            revisedPage = cut(
                    revisedPage,
                    fromTos[n][0] - cutOffset,
                    fromTos[n][1] - cutOffset
            );
            cutOffset += fromTos[n][1] - fromTos[n][0];
        });
        archiveThis = sections.map(function() {
            return wikiText.substring(fromTos[this][0], fromTos[this][1]);
        }).toArray().join("");
        console.log("archive this:" + archiveThis);
        console.log("revised page:" + revisedPage);
        if (1) new mw.Api().postWithToken("csrf", {action: 'edit', title: mw.config.get("wgPageName"), text: revisedPage, summary: "Removed " + numOfThreads + " threads to [[" + archiveTarget + "]]", basetimestamp: revStamp, starttimestamp: revStamp})
            .done(function(res1) {
                alert("Successfully removed threads from talk page");
                console.log(res1);
                new mw.Api().postWithToken("csrf", {action: 'edit', title: archiveTarget, appendtext: "\n" + archiveThis, summary: "Added threads from [[" + mw.config.get("wgPageName") + "]]"})
                    .done(function(res2) {
                        alert("Successfully added threads to archive page");
                    })
                    .fail(function(res2) {
                        alert("failed to add threads to archive page. manual inspection needed.");
                    })
                    .always(function(res2) {
                        console.log(res2);
                        window.location.reload();
                    });
            })
            .fail(function(res1) {
                alert("failed to remove threads from talk page. aborting archive process.");
                console.log(res1);
                window.location.reload();
            });
    });
    new mw.Api().get({action: 'parse', page: mw.config.get("wgPageName")}).done(function(dataShit) {
        new mw.Api().get({action: 'query', pageids: mw.config.get("wgArticleId"), prop: ['revisions'], rvprop: ['content', 'timestamp']}).done(function(shit) {
            var rv;
            rv = shit.query.pages[mw.config.get("wgArticleId")].revisions[0];
            wikiText = rv["*"];
            revStamp = rv['timestamp'];
        });
        $(dataShit.parse.sections)
            .filter(function(i, s) { return s.index == parseInt(s.index) })
            .each(function(i, s) { validSections[s.index] = s });
        for (var i in validSections) {
            i = parseInt(i);
            fromTos[i] = [
                validSections[i].byteoffset,
                validSections.hasOwnProperty(i+1)?validSections[i+1].byteoffset:Infinity
            ];
        }
        $("#mw-content-text").find(":header").find("span.mw-headline").each(function(i, title) {
            var header, headerNum, editSection, sectionNumber;
            header = $(this).parent();
            headerNum = header.prop("tagName").substr(1, 1) * 1; // wtf javascript
            editSection = header.find(".mw-editsection"); // 1st child
            sectionNumber = header.find(".mw-editsection a:last");
            if (sectionNumber[0]) {
               // Note: href may not be set.
                sectionNumber = sectionNumber.attr("href") && sectionNumber.attr("href").match(/&section=(\d+)/);
                if (sectionNumber)
                    sectionNumber = sectionNumber[1];
            } else // eg <h2>not a real section</h2>
                sectionNumber = undefined;
            if (validSections.hasOwnProperty(sectionNumber))
                editSection[0].innerHTML += "&nbsp;<span class=arky style=display:none><span class=mw-editsection-bracket>[</span><a data-header=" + headerNum + " " + "data-section=" + sectionNumber + " " + "onclick='$(this).closest(\":header\").toggleClass(\"arkyhighlight\");$(this).toggleClass(\"arkylink\");var archivable = $(\".arky a\"); for(var i=archivable.index(this); i<archivable.length; ++i) { if (archivable[i] == this) { continue; } if ($(archivable[i]).attr(\"data-header\") > " + headerNum + " && $(archivable[i]).hasClass(\"arkylink\") != $(this).hasClass(\"arkylink\")) { $(archivable[i]).click(); } else { break; } }'>archive</a><span class=mw-editsection-bracket>]</span></span>";
        });
    });
});
//importScript("User:A930913/vada/import.js"); //[[User:A930913/vada/import.js]]
importScript('User:Eejit43/scripts/redirect-helper.js'); // Backlink: [[User:Eejit43/scripts/redirect-helper.js]]