User:Ditto Duck Penguin/wikia.js

window.avatars = {}; function getURL(user) { $.get("/wiki/Special:Contributions/" + user + "?useskin=oasis", function(data) {       window.avatars[user] = //ig.exec(data)[1] + '';    }); } if ( wgPageName == "User:Ditto_Creeper_Bot/Galleries") { $(window).load(function {       $('.wikinav2 .WikiaPageHeader').css('padding-right', '0');        $('#WikiaPageHeader .comments').after( 'Update avatars ' );       $('#update-avatars').click(function { $(this).replaceWith(''); var usrs = []; var matches; var PC; var pageNewContent; $('.staff-usr-template').each(function {               usrs.push($(this).text.trim);            }); var API = new mw.Api; API.get({               action: 'query',                prop: 'revisions',                rvprop: 'content',                titles: wgPageName            }).done(function(data) {                for (var i in data.query.pages) {                    PC = data.query.pages[i].revisions[0]['*'];                    page = data.query.pages[Object.keys(data.query.pages)[0]];        		}                pageNewContent = PC;                for (var i in usrs) {                    if (usrs[i] !== '') {                        getURL(usrs[i]);                    }                }                setTimeout(function { for (var i in usrs) { if (usrs[i] !== '') { usrs[i] = window.avatars[usrs[i]]; usrs[i] = usrs[i].replace('static', 'images1') + '/scale-to-width-down/' + matches[i].split('/scale-to-width-down/')[1]; }                   }                    if ( PC != pageNewContent ) { var config = { 'minor': true, 'bot': true, 'summary': 'Updating user avatars. (automatic)', 'action': 'edit', 'title': wgPageName, 'token': mw.user.tokens.get('editToken'), 'text': pageNewContent };                       $.ajax({                            url: mw.util.wikiScript('api'),                            data: config,                            dataType: 'json',                            type: 'POST',                            success: function(d) {                                if (!d.error) {                                    new BannerNotification('Avatars successfully updated!', 'confirm').show;                                    $('#progress-img').replaceWith(' Success! ');                               } else {                                    new BannerNotification('Failed while updating avatars: ' + d.error.code, 'error').show;                                    $('#progress-img').replaceWith(' Fail. ');                               }                            },                            error: function {                                new BannerNotification('User avatars have been successfully updated!', 'confirm').show;                                $('#progress-img').replaceWith(' Updated ');                            }                        }); } else { new BannerNotification('No avatars to update.', 'error').show; $('#progress-img').replaceWith(' No new avatars '); }               }, 15000);            });        });    }); }