For faster navigation, this Iframe is preloading the Wikiwand page for Потребител:V111P/js/rmUncatTemplate.js.

Потребител:V111P/js/rmUncatTemplate.js

// https://bg.wikipedia.org/wiki/Потребител:V111P/js/rmUncatTemplate.js
// v. 30 Oct 2016
//
// Click the (−) link next to the Некатегоризирани_статии category to remove the
// без_категория or некатегоризирана_статия template from the wikitext of the current page

(function ($) {

    var info = mw.config.get(['wgPageName', 'wgUserLanguage', 'wgAction', 'wgScriptPath']);
    info.pageNameEncoded = encodeURIComponent(info.wgPageName);
    var pageText, pageTimestamp;
    var dialogHeading = 'V111P\'s Uncategorized Page Template removing tool:\n';
    var $uncatLink;

    var $uncategorizedPagesCatLink = $('a[href="' + encodeURI('/wiki/Категория:Некатегоризирани_статии') + '"]');
    if ($uncategorizedPagesCatLink[0]) {
        $uncatLink = $('<a/>', {
            text: '(−)',
            href: '#',
            class: 'uncategorizedPagesCatRemoveLink',
            click: function (e) {
                e.preventDefault();
                if (confirm('Премахване на шаблон ((без категория))?')) {
                    $uncatLink.addClass('working');
                    requestWikitext();
                }
            }
        });
        $uncategorizedPagesCatLink.after($uncatLink).after(' ');
    }


    function requestWikitext() {
            $.get(info.wgScriptPath
                    + '/api.php?action=query&prop=revisions&rvprop=content|timestamp&format=json&titles='
                    + info.pageNameEncoded,
                receiveResponse
            );
    }


    function receiveResponse(obj) {
        pageText = null;
        try {
            $.each(obj.query.pages, function (key, val) {
                pageText = val.revisions[0]['*'];
                pageTimestamp = val.revisions[0].timestamp;
            });
        }
        catch (e) {
            error('Грешка при получаване на кода на страницата:\n' + e.message);
            return;
        }

        var newWikitext = pageText.replace(/\{\{(без категория|некатегоризирана статия) *))\n{0,2}/i, '');
        if (newWikitext == pageText) {
            error('В кода на страницата не беше открит шаблон ((без категория)) или ((некатегоризирана статия)).');
            return;
        }
        savePage(newWikitext);
    }


    function savePage(wikitext) {
        var editRequestObj = {
            action: 'edit',
            minor: true,
            nocreate: '',
            title: info.wgPageName,
            basetimestamp: pageTimestamp,
            summary: 'без ((без категория))',
            text: wikitext,
            token: mw.user.tokens.get('editToken'),
            format: 'json'
        };
        $.post(info.wgScriptPath + '/api.php', editRequestObj, function (data) {
            var err = data.error;
            var msg = '';
            if (err) {
                if (err.code == 'editconflict')
                    error('Конфликт на редакциите. Опитай отново.');
                else
                    error('Грешка при записване на страницата: ' + err.info + ' (' + err.code + ')' );
            } else {
                mw.notify('Готово');
                $uncategorizedPagesCatLink.remove();
                $uncatLink.remove();
            }
        });
    }

    function error(msg) {
        $uncatLink.removeClass('working');
        console.error(dialogHeading + msg);
        alert(dialogHeading + msg);
    }

})($);
{{bottomLinkPreText}} {{bottomLinkText}}
Потребител:V111P/js/rmUncatTemplate.js
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?