Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Discord Custom Nicknames
- // 2017-07-11 01:52 v1.0
- //
- // needs the browser addon "Custom JavaScript for websites" or similar:
- // https://chrome.google.com/webstore/detail/custom-javascript-for-web/poakhlngfciodnhlhhgnaaelnpjljija?utm_source=chrome-app-launcher-info-dialog
- //
- // the script also needs jQuery, so if you use the above plugin
- // select "jQuery 2.1.0" in the predefined scripts dropdown
- // (otherwise you'll have to provide jQuery yourself somehow)
- //
- // the only configuration is the array below this block of commentary
- // where you need to add pairs of <userid> and <new nickname>,
- // however if the user doesn't have an avatar you'll have to
- // provide the original display name instead of userid
- var ocvme_dcn_names = [
- '215536269420134411', 'ed',
- '232684662244376576', 'string',
- '270058815171461121', 'kurisu',
- '192695843629957120', 'PD',
- '🥑〰🥑', 'ww',
- ];
- function ocvme_dcn_rename()
- {
- $('div.message-group:not(.ocvme)').each(function(dc1)
- {
- var obj = $(this);
- obj.addClass('ocvme');
- var id = obj.find('div.avatar-large').eq(0).attr('style').replace(
- /.*discordapp\.com\/avatars\/([^\/]*)\/[0-9a-f]+\.png.*/, function(a, b)
- {
- return b;
- });
- //var nobj = $('<div style="float: left; padding: 0 .3em 0 0"></div>');
- //nobj.text('<user:' + id + '>');
- //obj.find('div.message-text').prepend(nobj);
- var nameobj = obj.find('span.username-wrapper>strong.user-name');
- if (id.indexOf('assets') !== -1)
- id = nameobj.text();
- var found = false;
- for (var a = 0; a < ocvme_dcn_names.length; a += 2)
- {
- if (ocvme_dcn_names[a] == id)
- {
- id = ocvme_dcn_names[a+1];
- found = true;
- break;
- }
- }
- if (found)
- nameobj.text(id);
- });
- setTimeout(ocvme_dcn_rename, 1000);
- }
- function ocvme_dcn_init()
- {
- // there is a race condition in cjs which occasionally makes
- // our code execute before jquery has become available,
- // so this function in a settimeout is a quick workaround
- setTimeout(ocvme_dcn_rename, 100);
- }
- setTimeout(ocvme_dcn_init, 1000);
Advertisement
Add Comment
Please, Sign In to add comment