User:Sophiedp/global.js

/* Sine settings */ Sine = { spacer: '' };

/* AutoEditDropdown settings and inport */ window.AutoEditDropdownConfig = { expandedAreaContribute: true, expandedAreaEdit: false };

/* settings and import for AdvancedOasisUI */ window.AdvancedOasisUI = { accountNavFollowedPages: true, accountNavWatchlist: true, categoryRedlink: true, RCHeader: true, DefaultSourceMode: true, lightbox: true, randomPageLimitedTo: '', activity2RC: false, userLang: true, };

/* Reverting stuff */ (function (mw, $) {   if (mw.config.get('wgAction') !== 'history' && mw.util.getParamValue('diff') === null) {        return;    }    $('.tools').append('');    var node = document.createElement('a');    node.id = 'ajax-revert-link';    node.textContent = 'Revert';    node.addEventListener('click', function  { continueOperation; $(this).prepend(''); });   $('#ajax-revert').append($(node));    function continueOperation {        (new mw.Api).get({ action: 'query', prop: 'revisions', titles: mw.config.get('wgPageName'), rvprop: 'user|ids', rvlimit: '50', format: 'json' }).done(function (result) { var i = 0, currentrev, lastcleanrev, revisions = result.query.pages[mw.config.get('wgArticleId')].revisions; // Iterate over the revisions authored by the same user and cache the first clean rev & the current one do { i++; } while (revisions[i].user === revisions[i - 1].user); currentrev = revisions[0].revid; lastcleanrev = revisions[i].revid; // Edit the page (new mw.Api).post({               action: 'edit',                undo: currentrev,                undoafter: lastcleanrev,                title: mw.config.get('wgPageName'),                token: mw.user.tokens.get('editToken')            }).done(function  {                $('#ajax-throbber').hide;                $('#ajax-revert').html('Complete');            }); });   } }(mediaWiki, jQuery));

/* */ // Reverting tools V6.6 Gold (Original coding by VegaDark, modified by Ajraddatz and Manyman) function getElementsByClass(searchClass,node,tag) { // Function from http://www.dustindiaz.com/getelementsbyclass/ var classElements = new Array; if ( node == null ) node = document; if ( tag == null ) tag = '*'; var els = node.getElementsByTagName(tag); var elsLen = els.length; var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)"); for (i = 0, j = 0; i < elsLen; i++) { if ( pattern.test(els[i].className) ) { classElements[j] = els[i]; j++; } }  return classElements; } // _GET code from NoGray JS Library http://www.nogray.com/new_site/ var _GET = new Array; var _uri = location.href; var _temp_get_arr = _uri.substring(_uri.indexOf('?')+1, _uri.length).split("&"); var _temp_get_arr_1 = new Array; for(_get_arr_i=0; _get_arr_i<_temp_get_arr.length; _get_arr_i++){ _temp_get_arr_1 = _temp_get_arr[_get_arr_i].split("="); _GET[decodeURI(_temp_get_arr_1[0])] = decodeURI(_temp_get_arr_1[1]); } delete _uri; delete _temp_get_arr; delete _temp_get_arr_1; function getMessage (where, user1, user2) { var message = prompt ('Enter undo message below:', ''); window.location = 'http://'+ location.hostname + '/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&'+where+'=2&user1='+user1+'&user2='+user2+'&message='+message; } function AGFMessage (where, user1, user2) { var message = prompt ('Enter undo message below:', ''); window.location = 'http://'+ location.hostname + '/index.php?title=' + _GET['title'] + '&action=edit&oldid=' + _GET['oldid'] + '&'+where+'=3&user1='+user1+'&user2='+user2+'&message='+message; } addOnloadHook(function { if (location.href.match(/diff=/)) {    // Get username of submitter    var user1 = getElementsByClass('diff-otitle',null,'td'); user1 = user1[0].getElementsByTagName('a')[2].innerHTML;    var user2 = getElementsByClass('diff-ntitle',null,'td'); user2 = user2[0].getElementsByTagName('a')[3].innerHTML;    $('#mw-content-text').prepend(' ');    document.getElementById('vda-cont').innerHTML = 'Reverted Revert Revert (Vandalism)  Revert (Good faith)</a> </b> Revert (Spam)</a> </b>' + ''; } else if (location.href.match(/revert=1/)) {    document.getElementById('wpSummary').value = 'Reverted vandalism by '+_GET['user2']+' using VDA';    document.getElementById('editform').submit;  } else if (location.href.match(/revert=6/)) {    document.getElementById('wpSummary').value = 'Reverted good faith edits by '+_GET['user2']+' using VDA';    document.getElementById('editform').submit;  } else if (location.href.match(/revert=3/)) {    document.getElementById('wpSummary').value = 'Reverted edits by '+_GET['user2']+' using VDA';    document.getElementById('editform').submit;  } else if (location.href.match(/revert=2/)) {    document.getElementById('wpSummary').value = 'Reverted edits by ' + _GET['user2'] + ' (' +_GET['message']+ ') using VDA'; document.getElementById('editform').submit; } else if (location.href.match(/revert=4/)) { document.getElementById('wpSummary').value = 'Reverted spam by '+_GET['user2']+' to the last version by '+_GET['user1']+' using VDA'; document.getElementById('editform').submit; } }); /* */

/* Fast delete buttons */ window.fdButtons = []; window.fdButtons.push(   {        summary: 'Housekeeping',        label: 'Clean-up'    },    {        summary: 'Vandalism',        label: 'Vandalism'    },    {        summary: 'Spam',        label: 'Spam'    },    {        summary: 'Unused',        label: 'Unused'    },    {        summary: 'Inappropriate content',        label: 'Content'    } );

/* Inport for various scripts */ importArticles({   type: "script",    articles: [        'u:dev:PurgeButton/code.js',        'u:dev:ColoredColors/code.js',        'u:dev:DisplayClock/code.js',        'u:dev:View_Source/code.js',        'u:dev:ViewRemoved/code.js',        'u:dev:NullEditButton/code.js',        'u:dev:MediaWiki:QuickModTools/loader.js',        'u:dev:MediaWiki:Wikimarks/code.js',        'u:dev:RevealAnonIP/usercode.js',        'u:dev:WallGreetingButton/code.js',        'u:dev:MediaWiki:AjaxPatrol/code.js',        'u:dev:QuickCreateUserPage/code.js',        'u:dev:QuickThreads/code.js',        'u:dev:Sine/code.js',        'u:dev:AutoEditDropdown/code.js',        'u:dev:AdvancedOasisUI/code.js',        'u:dev:FastDelete/code.js',        'u:dev:MediaWiki:RedirectManagement/code.js',        'u:dev:Mediawiki:QuickToolsv2/code.js',        'u:dev:MediaWiki:QuickTools/code.js'    ] });