mkv

discord custom nicknames

mkv
Jul 10th, 2017
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Discord Custom Nicknames
  2. // 2017-07-11 01:52 v1.0
  3. //
  4. // needs the browser addon "Custom JavaScript for websites" or similar:
  5. // https://chrome.google.com/webstore/detail/custom-javascript-for-web/poakhlngfciodnhlhhgnaaelnpjljija?utm_source=chrome-app-launcher-info-dialog
  6. //
  7. // the script also needs jQuery, so if you use the above plugin
  8. // select "jQuery 2.1.0" in the predefined scripts dropdown
  9. // (otherwise you'll have to provide jQuery yourself somehow)
  10. //
  11. // the only configuration is the array below this block of commentary
  12. // where you need to add pairs of <userid> and <new nickname>,
  13. // however if the user doesn't have an avatar you'll have to
  14. // provide the original display name instead of userid
  15.  
  16. var ocvme_dcn_names = [
  17.     '215536269420134411', 'ed',
  18.     '232684662244376576', 'string',
  19.     '270058815171461121', 'kurisu',
  20.     '192695843629957120', 'PD',
  21.     '🥑〰🥑', 'ww',
  22. ];
  23.  
  24. function ocvme_dcn_rename()
  25. {
  26.     $('div.message-group:not(.ocvme)').each(function(dc1)
  27.     {
  28.         var obj = $(this);
  29.         obj.addClass('ocvme');
  30.         var id = obj.find('div.avatar-large').eq(0).attr('style').replace(
  31.             /.*discordapp\.com\/avatars\/([^\/]*)\/[0-9a-f]+\.png.*/, function(a, b)
  32.         {
  33.             return b;
  34.         });
  35.         //var nobj = $('<div style="float: left; padding: 0 .3em 0 0"></div>');
  36.         //nobj.text('<user:' + id + '>');
  37.         //obj.find('div.message-text').prepend(nobj);
  38.         var nameobj = obj.find('span.username-wrapper>strong.user-name');
  39.        
  40.         if (id.indexOf('assets') !== -1)
  41.             id = nameobj.text();
  42.        
  43.         var found = false;
  44.         for (var a = 0; a < ocvme_dcn_names.length; a += 2)
  45.         {
  46.             if (ocvme_dcn_names[a] == id)
  47.             {
  48.                 id = ocvme_dcn_names[a+1];
  49.                 found = true;
  50.                 break;
  51.             }
  52.         }
  53.        
  54.         if (found)
  55.             nameobj.text(id);
  56.     });
  57.     setTimeout(ocvme_dcn_rename, 1000);
  58. }
  59.  
  60. function ocvme_dcn_init()
  61. {
  62.     // there is a race condition in cjs which occasionally makes
  63.     // our code execute before jquery has become available,
  64.     // so this function in a settimeout is a quick workaround
  65.     setTimeout(ocvme_dcn_rename, 100);
  66. }
  67. setTimeout(ocvme_dcn_init, 1000);
Advertisement
Add Comment
Please, Sign In to add comment