FANDOM


/////////////////////////////////////
//A script that will send not a block message, but a warning, to a user's message wall/talk page
//Status: Work in progress
//Will use code from [[w:c:dev:MessageBlock]] (written by [[w:User:Gguigui1]]) & [[w:c:dev:WHAM]] (specifically, the second version written by [[w:User:Ozuzanna]])
/////////////////////////////////////
 
$( document ).ready(function() {
var lng = {
        // English
        en: {
            success: 'Message sent!',
            button: 'Send a message to the warned user\'s talk page',
            blockreason: 'Type the warning reason and comments:'
        },
 
	lng = $.extend(lng.en, lng[mw.config.get('wgContentLanguage')], lng[mw.config.get('wgUserLanguage')]);
var nmspc;
 
            // Detect if Wikia uses user talk or message wall
            $.get('/wiki/User_talk:' + mw.config.get('wgUserName'), function (data) {
                nmspc = data.slice(data.indexOf('"wgCanonicalNamespace":"') + 24, data.indexOf('","wgCanonicalSpecialPageName'));
            });
            // ends the script if it's not SPECIAL:Block
            if (wgCanonicalSpecialPageName !== "Block") {
               return false;
            }
            // Executes the script once
            if ($('#mw-input-wpMessage').length > 0) {
               console.log( 'ALREADYexecuted');
               return false;
            }
            $('tbody').append('<tr class="mw-htmlform-field-HTMLCheckField"><td class="mw-label"><label for="mw-input-wpMessage">&#160;</label></td><td class="mw-input"><input name="wpMessage" type="checkbox" value="1" id="mw-input-wpMessage" />&#160;<label for="mw-input-wpMessage">' + lng.button + '</label></td></tr>');
            if (!Warning.autocheck) {
               Warning.autocheck = false;
            }
            if (Warning.autocheck == true) {
               $('#mw-input-wpMessage').attr( 'CHECKED', true);
            }
	$('.mw-htmlform-submit').click(function() {
	    if ($('#mw-input-wpMessage').attr('checked')) {
            if ($('#mw-input-wpExpiry-other').css('display') == 'none') { 
              var duration = $('#mw-input-wpExpiry option:selected').text();     
            } else {    
              var duration = $('#mw-input-wpExpiry-other').val();    
            }
            if ($('#mw-input-wpReason-other').val()) {
              var warningmessage = prompt(lng.warningreason, $('#mw-input-wpReason option:selected').text() + ":" + $('#mw-input-wpReason-other').val());
              } else {
              var warningmessage = prompt(lng.warningreason, $('#mw-input-wpReason option:selected').text());
            }
            var messages = Warning.message.replace('$2', duration);
            messages = messages.replace('$1', warningmessage);
            switch (nmspc) {
                                    // User talk
                                    case 'User_talk':
                                        $.post(mw.util.wikiScript('api'), {
                                            action      : 'edit',
                                            title       : 'User_talk:' + $('#mw-bi-target').val(),
                                            section     : 'new',
                                            sectiontitle: Warning.title,
                                            text        : messages,
                                            token       : mw.user.tokens.values.editToken
                                        });
                                        break;
                                    // Message wall
                                    default:
                                        $.post(mw.util.wikiScript('wikia'), {
                                            controller   : 'WallExternal',
                                            method       : 'postNewMessage',
                                            pagenamespace: '1200',
                                            pagetitle    : $('#mw-bi-target').val(),
                                            messagetitle : Warning.title,
                                            body         : messages,
                                            format       : 'json'
                                        });
                                        break;
                                    }
			alert(lng.success);
        }			
    });
});
//

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.