Difference between revisions of "User:Wookipan/common.js"

From Team Fortress Wiki
Jump to: navigation, search
m
m
Line 1: Line 1:
 
// Start custom username highlighting -----
 
// Start custom username highlighting -----
/*
 
 
var uGroupHighlight = {
 
var uGroupHighlight = {
 
   init: function() {
 
   init: function() {
Line 21: Line 20:
 
           var name = uGroups[user].name;
 
           var name = uGroups[user].name;
  
           $('.mw-userlink[title="' + 'User:' + name + '"]').addClass(group.includes('bot') ? 'bot' : 'staff');
+
           $('bdi').each(function() {
 +
            if ($(this).text().includes(name)) {
 +
              $(this).closest('.mw-userlink').addClass(group.includes('bot') ? 'bot' : 'staff');
 +
            }
 +
          });
 
         }
 
         }
 
       });
 
       });
Line 28: Line 31:
 
};
 
};
 
$(uGroupHighlight.init);
 
$(uGroupHighlight.init);
*/
 
 
// End custom username highlighting -----
 
// End custom username highlighting -----
 +
 
/*
 
/*
 
var apfools22 = {
 
var apfools22 = {

Revision as of 16:44, 26 May 2022

// Start custom username highlighting -----
var uGroupHighlight = {
  init: function() {
    if ($('.mw-userlink')[0]) {
      var params = {
        action: 'query',
        list: 'allusers',
        augroup: ['sysop', 'moderator', 'bot'],
        auprop: 'groups',
        aulimit: 100,
        format: 'json'
      };

      var api = new mw.Api();

      api.get(params).done(function(data) {
        var uGroups = data.query.allusers, user;
        for (user in uGroups) {
          var group = uGroups[user].groups;
          var name = uGroups[user].name;

          $('bdi').each(function() {
            if ($(this).text().includes(name)) {
              $(this).closest('.mw-userlink').addClass(group.includes('bot') ? 'bot' : 'staff');
            }
          });
        }
      });
    }
  },
};
$(uGroupHighlight.init);
// End custom username highlighting -----

/*
var apfools22 = {
  init: function() {
    if (!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
    	
   // var randomSeed = Math.floor(Math.random() * 50)
   // console.log(randomSeed);
      if (
        !$('body').hasClass('action-edit') &&
        !mw.storage.get('skeletonFired') // && randomSeed === 0
      ) {
        var $skeleton = document.createElement('audio');
        var $lootbox = document.createElement('img');

        $skeleton.src = '/w/images/9/93/User_Wookipan_theskeletonappears.wav';

        $lootbox.classList.add('lootbox');
        $lootbox.src = '/w/images/b/b8/User_Wookipan_lootcrate.png';
        $lootbox.title = 'Click me!';

        $('.apfools22').detach().prependTo('.mediawiki');
        $('.mediawiki').prepend($lootbox);

        $('.lootbox').click(function() {
          $('.lootbox').fadeOut();
          $('html, body').animate({scrollTop: '0px'}, 0).css('overflow', 'hidden');

          $skeleton.play();

          $($skeleton).on('ended', function() {
            window.location.reload(true);
          });

          $('.thewikiskeleton').fadeIn('slow');
          setTimeout(function() {
            $('.thewikiskeleton-bg').fadeIn(1000, function () {
              $('.apfools22 p').fadeIn(1000);
            });
          }, 2500);
          mw.storage.set('skeletonFired', 'true');
        });
      } else {
      	$('.apfools22').remove();
      }
    }
  },
};
$(apfools22.init);
*/