Bot icons

This commit is contained in:
Jiiks 2016-01-07 11:19:46 +02:00
parent 1b06641a24
commit 87c49a61bd
4 changed files with 18 additions and 7 deletions

View File

@ -58,7 +58,7 @@
background-image:url(https://static-cdn.jtvnw.net/emoticons/v1/1/1.0) !important;
}
.member-username[data-reactid*="119598467310944259"]:before {
.boticon:before, .member-username[data-reactid*="119598467310944259"]:before {
content: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAMCAYAAABSgIzaAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAK8SURBVHgBAKwCU/0Bk5OTAOjo6AAEBAQQFxcXjRQUFEX+/v4AAAAAAAAAAAAAAAAAAgICAOzs7Lvp6elz/Pz88BgYGAAEHR0dAO3t7QQhISHlTk5OChAQEAD9/f0AAAAAAAAAAAAAAAAAAwMDAPDw8GKysrJY39/fDx0dHfwEHR0dAPLy8gwkJCQKEBAQAAAAAAD///8A8fHxAAAAAAAMDAwAAwMDABAQEAAkJCQKAQEBDB0dHfAC7e3tBeXl5YcHBwcAtLS0AFVVVQDAwMAADQ0NAA0NDQDOzs4AW1tbAKGhoQANDQ0A5eXlh+3t7QUEyMjIjOPj42jt7e0Al5eXALa2tgD19fUAREREAAAAAACnp6cApqamALi4uAC1tbUA3t7eaPv7+/oEAgICAAEBAQAUFBQALy8vAOnp6QBXV1cA9vb2AAAAAAAuLi4AMDAwAFJSUgAFBQUAAQEBAAICAgABvLy8Bc3NzY8+Pj5rICAgAOjo6AAUFBQA////AAAAAAABAQEA7e3tABcXFwDg4OAAwsLClTMzM3ECERER+xoaGn////8ACAgIAPT09AD09PQAExMTABMTEwDz8/MA8vLyAAgICAD///8AGhoafxEREfsE5ubmANjY2PweHh4ACAgIAN/f3wCoqKgAAwMDAAAAAAD4+PgAOTk5ADY2NgD7+/sA2NjY/BAQEAADKSkpAP7+/vnt7e3dDQ0NUj4+PgAGBgYA7e3tAAkJCQBEREQATExMANfX1wDExMRd+fn5y+vr6wABenp6AA4ODgD19fUACgoKQjAwML0zMzMAFRUVAAAAAADs7OwAy8vLANDQ0EH39/fACwsLAPLy8gAEBAQEAP7+/gAKCgoA+/v7vsPDwwzW1tZKGxsbfgAAAADl5eWB7e3ttggICPYKCgoA/v7+AAQEBAABAAD///Kw+x07CI4VAAAAAElFTkSuQmCC');
}

2
css/main.min.css vendored

File diff suppressed because one or more lines are too long

View File

@ -213,7 +213,7 @@ Core.prototype.saveSettings = function() {
Core.prototype.loadSettings = function() {
settingsCookie = JSON.parse($.cookie("better-discord"));
};
var botlist = ["119598467310944259"]; //Temp
Core.prototype.initObserver = function() {
mainObserver = new MutationObserver(function(mutations) {
@ -223,8 +223,16 @@ Core.prototype.initObserver = function() {
quickEmoteMenu.obsCallback();
voiceMode.obsCallback();
if(typeof pluginModule !== "undefined") pluginModule.channelSwitch();
$(".message-group").each(function() {
var a = $(this).find(".avatar-large").css("background-image").match(/\d+/).toString();
if(botlist.indexOf(a) > -1) {
$(this).find(".user-name").addClass("boticon");
}
});
}
if(mutation.target.getAttribute('class').indexOf('scroller messages') != -1) {
var lastMessage = $(".message-group").last();
if(botlist.indexOf(lastMessage.find(".avatar-large").css("background-image").match(/\d+/).toString()) > -1) { lastMessage.find(".user-name").addClass("boticon"); }
if(typeof pluginModule !== "undefined") pluginModule.newMessage();
}
}
@ -1610,7 +1618,9 @@ BdWSocket.prototype.onClose = function(e) {
};
BdWSocket.prototype.send = function(data) {
bdSocket.send(JSON.stringify(data));
if(bdSocket.readyState == 1) {
bdSocket.send(JSON.stringify(data));
}
};
BdWSocket.prototype.getSocket = function() {

7
js/main.min.js vendored
View File

@ -4,8 +4,9 @@ Core.prototype.init=function(){var self=this;if(version<supportedVersion){this.a
utils=new Utils();var sock=new BdWSocket();sock.start();utils.getHash();emoteModule=new EmoteModule();quickEmoteMenu=new QuickEmoteMenu();voiceMode=new VoiceMode();emoteModule.init();this.initSettings();this.initObserver();function gwDefer(){console.log(new Date().getTime()+" Defer");if($(".guilds-wrapper .guilds").children().length>0){console.log(new Date().getTime()+" Defer Loaded");var guilds=$(".guilds li:first-child");guilds.after($("<li></li>",{id:"bd-pub-li",css:{"height":"20px","display":settingsCookie["bda-gs-1"]==true?"":"none"}}).append($("<div/>",{class:"guild-inner",css:{"height":"20px","border-radius":"4px"}}).append($("<a/>").append($("<div/>",{css:{"line-height":"20px","font-size":"12px"},text:"public",id:"bd-pub-button"})))));var showChannelsButton=$("<button/>",{class:"btn",id:"bd-show-channels",text:"R",css:{"cursor":"pointer"},click:function(){settingsCookie["bda-gs-3"]=false;$("body").removeClass("bd-minimal-chan");self.saveSettings();}});$(".guilds-wrapper").prepend(showChannelsButton);opublicServers=new PublicServers();pluginModule=new PluginModule();pluginModule.loadPlugins();if(typeof(themesupport2)!=="undefined"){themeModule=new ThemeModule();themeModule.loadThemes();}
settingsPanel=new SettingsPanel();settingsPanel.init();quickEmoteMenu.init(false);$("#tc-settings-button").on("click",function(){settingsPanel.show();});$("#bd-pub-button").on("click",function(){opublicServers.show();});opublicServers.init();emoteModule.autoCapitalize();if(settingsCookie["version"]<jsVersion){var cl=self.constructChangelog();$("body").append(cl);settingsCookie["version"]=jsVersion;self.saveSettings();}
$("head").append("<style>.CodeMirror{ min-width:100%; }</style>");$("head").append('<style id="bdemotemenustyle"></style>');}else{setTimeout(gwDefer,100);}}
$(document).ready(function(){setTimeout(gwDefer,1000);});};Core.prototype.initSettings=function(){if($.cookie("better-discord")==undefined){settingsCookie=defaultCookie;this.saveSettings();}else{this.loadSettings();for(var setting in defaultCookie){if(settingsCookie[setting]==undefined){settingsCookie[setting]=defaultCookie[setting];this.saveSettings();}}}};Core.prototype.saveSettings=function(){$.cookie("better-discord",JSON.stringify(settingsCookie),{expires:365,path:'/'});};Core.prototype.loadSettings=function(){settingsCookie=JSON.parse($.cookie("better-discord"));};Core.prototype.initObserver=function(){mainObserver=new MutationObserver(function(mutations){mutations.forEach(function(mutation){if(mutation.target.getAttribute('class')!=null){if(mutation.target.getAttribute('class').indexOf("titlebar")!=-1){quickEmoteMenu.obsCallback();voiceMode.obsCallback();if(typeof pluginModule!=="undefined")pluginModule.channelSwitch();}
if(mutation.target.getAttribute('class').indexOf('scroller messages')!=-1){if(typeof pluginModule!=="undefined")pluginModule.newMessage();}}
$(document).ready(function(){setTimeout(gwDefer,1000);});};Core.prototype.initSettings=function(){if($.cookie("better-discord")==undefined){settingsCookie=defaultCookie;this.saveSettings();}else{this.loadSettings();for(var setting in defaultCookie){if(settingsCookie[setting]==undefined){settingsCookie[setting]=defaultCookie[setting];this.saveSettings();}}}};Core.prototype.saveSettings=function(){$.cookie("better-discord",JSON.stringify(settingsCookie),{expires:365,path:'/'});};Core.prototype.loadSettings=function(){settingsCookie=JSON.parse($.cookie("better-discord"));};var botlist=["119598467310944259"];Core.prototype.initObserver=function(){mainObserver=new MutationObserver(function(mutations){mutations.forEach(function(mutation){if(mutation.target.getAttribute('class')!=null){if(mutation.target.getAttribute('class').indexOf("titlebar")!=-1){quickEmoteMenu.obsCallback();voiceMode.obsCallback();if(typeof pluginModule!=="undefined")pluginModule.channelSwitch();$(".message-group").each(function(){var a=$(this).find(".avatar-large").css("background-image").match(/\d+/).toString();if(botlist.indexOf(a)>-1){$(this).find(".user-name").addClass("boticon");}});}
if(mutation.target.getAttribute('class').indexOf('scroller messages')!=-1){var lastMessage=$(".message-group").last();if(botlist.indexOf(lastMessage.find(".avatar-large").css("background-image").match(/\d+/).toString())>-1){lastMessage.find(".user-name").addClass("boticon");}
if(typeof pluginModule!=="undefined")pluginModule.newMessage();}}
emoteModule.obsCallback(mutation);});});mainObserver.observe(document,{childList:true,subtree:true});};Core.prototype.constructChangelog=function(){var changeLog=''+'<div id="bd-wn-modal" class="modal" style="opacity:1;">'+' <div class="modal-inner">'+' <div id="bdcl" class="change-log"> '+' <div class="header">'+' <strong>What\'s new in BetterDiscord JS v1.53&'+jsVersion+'</strong>'+' <button class="close" onclick=\'$("#bd-wn-modal").remove();\'></button>'+' </div><!--header-->'+' <div class="scroller-wrap">'+' <div class="scroller">';if(bdchangelog.changes!=null){changeLog+=''+'<h1 class="changelog-added">'+' <span>New Stuff</span>'+'</h1>'+'<ul>';for(var change in bdchangelog.changes){change=bdchangelog.changes[change];changeLog+=''+'<li>'+' <strong>'+change.title+'</strong>'+' <div>'+change.text+'</div>'+'</li>';}
changeLog+='</ul>';}
if(bdchangelog.fixes!=null){changeLog+=''+'<h1 class="changelog-fixed">'+' <span>Fixed</span>'+'</h1>'+'<ul>';for(var fix in bdchangelog.fixes){fix=bdchangelog.fixes[fix];changeLog+=''+'<li>'+' <strong>'+fix.title+'</strong>'+' <div>'+fix.text+'</div>'+'</li>';}
@ -65,7 +66,7 @@ ThemeModule.prototype.loadThemes=function(){this.loadThemeData();$.each(bdthemes
if(enabled){$("head").append('<style id="'+name+'">'+unescape(bdthemes[name]["css"])+'</style>');}});};ThemeModule.prototype.handleTheme=function(checkbox){var cb=$(checkbox).children().find('input[type="checkbox"]');var enabled=!cb.is(":checked");var id=cb.attr("id").substring(2);cb.prop("checked",enabled);if(enabled){$("head").append('<style id="'+id+'">'+unescape(bdthemes[id]["css"])+'</style>');themeCookie[id]=true;}else{$("#"+id).remove();themeCookie[id]=false;}
this.saveThemeData();};ThemeModule.prototype.loadThemeData=function(){var cookie=$.cookie("bd-themes");if(cookie!=undefined){themeCookie=JSON.parse($.cookie("bd-themes"));}};ThemeModule.prototype.saveThemeData=function(){$.cookie("bd-themes",JSON.stringify(themeCookie),{expires:365,path:'/'});};var bdSocket;var bdws;function BdWSocket(){bdws=this;}
BdWSocket.prototype.start=function(){var self=this;$.ajax({method:"GET",url:"https://discordapp.com/api/gateway",headers:{authorization:localStorage.token.match(/\"(.+)\"/)[1]},success:function(data){self.open(data.url);}});};BdWSocket.prototype.open=function(host){utils.log("Socket Host: "+host);try{bdSocket=new WebSocket(host);bdSocket.onopen=this.onOpen;bdSocket.onmessage=this.onMessage;bdSocket.onerror=this.onError;bdSocket.onclose=this.onClose;}catch(err){utils.log(err);}};BdWSocket.prototype.onOpen=function(){utils.log("Socket Open");var data={op:2,d:{token:JSON.parse(localStorage.getItem('token')),properties:JSON.parse(localStorage.getItem('superProperties')),v:3}};bdws.send(data);};BdWSocket.prototype.onMessage=function(e){var packet,data,type;try{packet=JSON.parse(e.data);data=packet.d;type=packet.t;}catch(err){utils.err(err);return;}
switch(type){case"READY":bdSocket.interval=setInterval(()=>bdws.send({op:1,d:Date.now()}),data.heartbeat_interval);utils.log("Socket Ready");break;case"PRESENCE_UPDATE":pluginModule.socketEvent("PRESENCE_UPDATE",data);break;case"TYPING_START":pluginModule.socketEvent("TYPING_START",data);break;case"MESSAGE_CREATE":pluginModule.socketEvent("MESSAGE_CREATE",data);break;case"MESSAGE_UPDATE":pluginModule.socketEvent("MESSAGE_UPDATE",data);break;default:break;}};BdWSocket.prototype.onError=function(e){utils.log("Socket Error - "+e.message);};BdWSocket.prototype.onClose=function(e){utils.log("Socket Closed - "+e.code+" : "+e.reason);clearInterval(bdSocket.interval);bdws.start();};BdWSocket.prototype.send=function(data){bdSocket.send(JSON.stringify(data));};BdWSocket.prototype.getSocket=function(){return bdSocket;};function BdApi(){}
switch(type){case"READY":bdSocket.interval=setInterval(()=>bdws.send({op:1,d:Date.now()}),data.heartbeat_interval);utils.log("Socket Ready");break;case"PRESENCE_UPDATE":pluginModule.socketEvent("PRESENCE_UPDATE",data);break;case"TYPING_START":pluginModule.socketEvent("TYPING_START",data);break;case"MESSAGE_CREATE":pluginModule.socketEvent("MESSAGE_CREATE",data);break;case"MESSAGE_UPDATE":pluginModule.socketEvent("MESSAGE_UPDATE",data);break;default:break;}};BdWSocket.prototype.onError=function(e){utils.log("Socket Error - "+e.message);};BdWSocket.prototype.onClose=function(e){utils.log("Socket Closed - "+e.code+" : "+e.reason);clearInterval(bdSocket.interval);bdws.start();};BdWSocket.prototype.send=function(data){if(bdSocket.readyState==1){bdSocket.send(JSON.stringify(data));}};BdWSocket.prototype.getSocket=function(){return bdSocket;};function BdApi(){}
BdApi.joinServer=function(code){opublicServers.joinServer(code);};BdApi.injectCSS=function(id,css){$("head").append('<style id="'+id+'"></style>')
$("#"+id).html(css);};BdApi.clearCSS=function(id){$("#"+id).remove();};BdApi.getPlugin=function(name){if(bdplugins.hasOwnProperty(name)){return bdplugins[name]["plugin"];}
return null;};BdApi.getIpc=function(){return betterDiscordIPC;};BdApi.getCore=function(){return mainCore;};BdApi.getUserIdByName=function(name){var users=$(".member-username");for(var i=0;i<users.length;i++){var user=$(users[i]);if(user.text()==name){var avatarUrl=user.closest(".member").find(".avatar-small").css("background-image");return avatarUrl.match(/\d+/);}}