Emotemenu random icon
This commit is contained in:
parent
08d5eb0740
commit
40239dfc40
|
@ -177,6 +177,7 @@ Core.prototype.init = function() {
|
|||
}
|
||||
|
||||
$("head").append("<style>.CodeMirror{ min-width:100%; }</style>");
|
||||
$("head").append('<style id="bdemotemenustyle"></style>');
|
||||
|
||||
} else {
|
||||
setTimeout(gwDefer, 100);
|
||||
|
@ -736,6 +737,7 @@ PublicServers.prototype.joinServer = function(code) {
|
|||
*/
|
||||
|
||||
var emoteBtn, emoteMenu;
|
||||
var eiarr = [1, 3, 4, 6, 7, 8, 10, 11, 12, 13, 14];
|
||||
|
||||
function QuickEmoteMenu() {
|
||||
|
||||
|
@ -761,6 +763,7 @@ QuickEmoteMenu.prototype.init = function(reload) {
|
|||
$("#twitchcord-button").on("click", function() {
|
||||
menuOpen = !menuOpen;
|
||||
if(menuOpen) {
|
||||
$("#bdemotemenustyle").html('.twitchcord-button-open { background-image:url(https://static-cdn.jtvnw.net/emoticons/v1/'+eiarr[Math.floor(Math.random()*eiarr.length)]+'/1.0) !important; }');
|
||||
emoteMenu.addClass("emotemenu-open");
|
||||
$(this).addClass("twitchcord-button-open");
|
||||
} else {
|
||||
|
|
|
@ -3,7 +3,7 @@ var links={"Jiiks.net":{"text":"Jiiks.net","href":"http://jiiks.net","target":"_
|
|||
Core.prototype.init=function(){var self=this;if(version<supportedVersion){this.alert("Not Supported","BetterDiscord v"+version+"(your version)"+" is not supported by the latest js("+jsVersion+").<br><br> Please download the latest version from <a href='https://betterdiscord.net' target='_blank'>BetterDiscord.net</a>");return;}
|
||||
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>");}else{setTimeout(gwDefer,100);}}
|
||||
$("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();}}
|
||||
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>';}
|
||||
|
@ -26,9 +26,9 @@ if(typeof emotesBTTV!=='undefined'&&settingsCookie["bda-es-2"]){if(emotesBTTV.ha
|
|||
if(typeof emotesBTTV2!=='undefined'&&settingsCookie["bda-es-2"]){if(emotesBTTV2.hasOwnProperty(word)){var len=Math.round(word.length / 4);var name=word.substr(0,len)+"\uFDD9"+word.substr(len,len)+"\uFDD9"+word.substr(len*2,len)+"\uFDD9"+word.substr(len*3);var url=bttvEmoteUrlStart+emotesBTTV2[word]+bttvEmoteUrlEnd;parentInnerHTML=parentInnerHTML.replace(word,'<div class="emotewrapper"><img class="emote" alt="'+name+'" src="'+url+'" /><input onclick=\'quickEmoteMenu.favorite(\"'+name+'\", \"'+url+'\");\' class="fav" title="Favorite!" type="button"></div>');return;}}
|
||||
if(subEmotesTwitch.hasOwnProperty(word)){var len=Math.round(word.length / 4);var name=word.substr(0,len)+"\uFDD9"+word.substr(len,len)+"\uFDD9"+word.substr(len*2,len)+"\uFDD9"+word.substr(len*3);var url=twitchEmoteUrlStart+subEmotesTwitch[word]+twitchEmoteUrlEnd;parentInnerHTML=parentInnerHTML.replace(word,'<div class="emotewrapper"><img class="emote" alt="'+name+'" src="'+url+'" /><input onclick=\'quickEmoteMenu.favorite(\"'+name+'\", \"'+url+'\");\' class="fav" title="Favorite!" type="button"></div>');return;}});if(parent.parentElement==null)return;var oldHeight=parent.parentElement.offsetHeight;parent.innerHTML=parentInnerHTML.replace(new RegExp("\uFDD9","g"),"");var newHeight=parent.parentElement.offsetHeight;var scrollPane=$(".scroller.messages").first();scrollPane.scrollTop(scrollPane.scrollTop()+(newHeight-oldHeight));}
|
||||
if(edited){setTimeout(inject,250);}else{inject();}};EmoteModule.prototype.autoCapitalize=function(){var self=this;$('body').delegate($(".channel-textarea-inner textarea"),'keyup change paste',function(){if(!settingsCookie["bda-es-4"])return;var text=$(".channel-textarea-inner textarea").val();if(text==undefined)return;var lastWord=text.split(" ").pop();if(lastWord.length>3){if(lastWord=="danSgame")return;var ret=self.capitalize(lastWord.toLowerCase());if(ret!==null&&ret!==undefined){$(".channel-textarea-inner textarea").val(text.replace(lastWord,ret));}}});};EmoteModule.prototype.capitalize=function(value){var res=emotesTwitch.emotes;for(var p in res){if(res.hasOwnProperty(p)&&value==(p+'').toLowerCase()){return p;}}};var publicServers={"servers":{"server":{"code":0,"icon":null,"title":"title","language":"EN","description":"description"}}};function PublicServers(){}
|
||||
PublicServers.prototype.getPanel=function(){return this.container;};PublicServers.prototype.init=function(){var self=this;this.container=$("<div/>",{id:"bd-ps-container",style:"display:none"});var header=$("<div/>",{id:"bd-ps-header"});$("<h2/>",{text:"Public Servers"}).appendTo(header);$("<span/>",{id:"bd-ps-close",style:"cursor:pointer;",text:"X"}).appendTo(header);header.appendTo(this.getPanel());var psbody=$("<div/>",{id:"bd-ps-body"});psbody.appendTo(this.getPanel());var table=$("<table/>",{border:"0"});var thead=$("<thead/>");thead.appendTo(table);var headers=$("<tr/>",{}).append($("<th/>",{text:"Name"})).append($("<th/>",{text:"Code"})).append($("<th/>",{text:"Language"})).append($("<th/>",{text:"Description"})).append($("<th/>",{text:"Join"}));headers.appendTo(thead);var tbody=$("<tbody/>",{id:"bd-ps-tbody"});tbody.appendTo(table);table.appendTo(psbody);$("body").append(this.getPanel());$("#bd-ps-close").on("click",function(){self.show();});var servers=publicServers.servers;for(var server in servers){if(servers.hasOwnProperty(server)){var s=servers[server];var code=s.code;var title=s.title;var language=s.language;var description=s.description;this.addServer(server,code,title,language,description);}}};PublicServers.prototype.addServer=function(name,code,title,language,description){var self=this;var tableBody=$("#bd-ps-tbody");var desc=$("<td/>").append($("<div/>",{class:"bd-ps-description",text:description}));var tr=$("<tr/>");tr.append($("<td/>",{text:title}));tr.append($("<td/>",{css:{"-webkit-user-select":"initial","user-select":"initial"},text:code}));tr.append($("<td/>",{text:language}));tr.append(desc);tr.append($("<td/>").append($("<button/>",{text:"Join",css:{"height":"30px","display":"block","margin-top":"10px","background-color":"#36393E","border":"1px solid #404040","outline":"1px solid #000","color":"#EDEDED"},click:function(){self.joinServer(code);}})));tableBody.append(tr);};PublicServers.prototype.show=function(){this.getPanel().toggle();var li=$("#bd-pub-li");li.removeClass();if(this.getPanel().is(":visible")){li.addClass("active");}};PublicServers.prototype.joinServer=function(code){$(".guilds-add").click();$(".action.join .btn").click();$(".create-guild-container input").val(code);$(".form.join-server .btn-primary").click();};var emoteBtn,emoteMenu;function QuickEmoteMenu(){}
|
||||
PublicServers.prototype.getPanel=function(){return this.container;};PublicServers.prototype.init=function(){var self=this;this.container=$("<div/>",{id:"bd-ps-container",style:"display:none"});var header=$("<div/>",{id:"bd-ps-header"});$("<h2/>",{text:"Public Servers"}).appendTo(header);$("<span/>",{id:"bd-ps-close",style:"cursor:pointer;",text:"X"}).appendTo(header);header.appendTo(this.getPanel());var psbody=$("<div/>",{id:"bd-ps-body"});psbody.appendTo(this.getPanel());var table=$("<table/>",{border:"0"});var thead=$("<thead/>");thead.appendTo(table);var headers=$("<tr/>",{}).append($("<th/>",{text:"Name"})).append($("<th/>",{text:"Code"})).append($("<th/>",{text:"Language"})).append($("<th/>",{text:"Description"})).append($("<th/>",{text:"Join"}));headers.appendTo(thead);var tbody=$("<tbody/>",{id:"bd-ps-tbody"});tbody.appendTo(table);table.appendTo(psbody);$("body").append(this.getPanel());$("#bd-ps-close").on("click",function(){self.show();});var servers=publicServers.servers;for(var server in servers){if(servers.hasOwnProperty(server)){var s=servers[server];var code=s.code;var title=s.title;var language=s.language;var description=s.description;this.addServer(server,code,title,language,description);}}};PublicServers.prototype.addServer=function(name,code,title,language,description){var self=this;var tableBody=$("#bd-ps-tbody");var desc=$("<td/>").append($("<div/>",{class:"bd-ps-description",text:description}));var tr=$("<tr/>");tr.append($("<td/>",{text:title}));tr.append($("<td/>",{css:{"-webkit-user-select":"initial","user-select":"initial"},text:code}));tr.append($("<td/>",{text:language}));tr.append(desc);tr.append($("<td/>").append($("<button/>",{text:"Join",css:{"height":"30px","display":"block","margin-top":"10px","background-color":"#36393E","border":"1px solid #404040","outline":"1px solid #000","color":"#EDEDED"},click:function(){self.joinServer(code);}})));tableBody.append(tr);};PublicServers.prototype.show=function(){this.getPanel().toggle();var li=$("#bd-pub-li");li.removeClass();if(this.getPanel().is(":visible")){li.addClass("active");}};PublicServers.prototype.joinServer=function(code){$(".guilds-add").click();$(".action.join .btn").click();$(".create-guild-container input").val(code);$(".form.join-server .btn-primary").click();};var emoteBtn,emoteMenu;var eiarr=[1,3,4,6,7,8,10,11,12,13,14];function QuickEmoteMenu(){}
|
||||
QuickEmoteMenu.prototype.init=function(reload){emoteBtn=null;$(".channel-textarea").first().removeClass("emotemenu-enabled");if(!emoteMenu){this.initEmoteList();}
|
||||
var menuOpen;emoteBtn=$("<div/>",{id:"twitchcord-button-container",style:"display:none"}).append($("<button/>",{id:"twitchcord-button",onclick:"return false;"}));$(".content.flex-spacer.flex-horizontal .flex-spacer.flex-vertical form").append(emoteBtn);emoteMenu.detach();emoteBtn.append(emoteMenu);$("#twitchcord-button").on("click",function(){menuOpen=!menuOpen;if(menuOpen){emoteMenu.addClass("emotemenu-open");$(this).addClass("twitchcord-button-open");}else{emoteMenu.removeClass();$(this).removeClass();}
|
||||
var menuOpen;emoteBtn=$("<div/>",{id:"twitchcord-button-container",style:"display:none"}).append($("<button/>",{id:"twitchcord-button",onclick:"return false;"}));$(".content.flex-spacer.flex-horizontal .flex-spacer.flex-vertical form").append(emoteBtn);emoteMenu.detach();emoteBtn.append(emoteMenu);$("#twitchcord-button").on("click",function(){menuOpen=!menuOpen;if(menuOpen){$("#bdemotemenustyle").html('.twitchcord-button-open { background-image:url(https://static-cdn.jtvnw.net/emoticons/v1/'+eiarr[Math.floor(Math.random()*eiarr.length)]+'/1.0) !important; }');emoteMenu.addClass("emotemenu-open");$(this).addClass("twitchcord-button-open");}else{emoteMenu.removeClass();$(this).removeClass();}
|
||||
return false;});$(document).off("click.bdem").on("click.bdem",function(){if(menuOpen){menuOpen=!menuOpen;emoteMenu.removeClass();$("#twitchcord-button").removeClass();}});$("#emote-menu").on("click",function(){$("#rmenu").hide();return false;});if(settingsCookie["bda-es-0"]){$(".channel-textarea").first().addClass("emotemenu-enabled");emoteBtn.show();}
|
||||
var emoteIcon=$(".emote-icon");emoteIcon.off();emoteIcon.on("click",function(){var emote=$(this).attr("title");var ta=$(".channel-textarea-inner textarea");ta.val(ta.val().slice(-1)==" "?ta.val()+emote:ta.val()+" "+emote);});var fe=localStorage["bdfavemotes"];if(fe!=undefined){favoriteEmotes=JSON.parse(atob(fe));this.updateFavorites();}};var bdfw={};QuickEmoteMenu.prototype.obsCallback=function(){if(!emoteBtn)return;if(!$(".content.flex-spacer.flex-horizontal .flex-spacer.flex-vertical form"))return;var tcbtn=$("#twitchcord-button-container");if(tcbtn.parent().prop("tagName")==undefined){quickEmoteMenu=new QuickEmoteMenu();quickEmoteMenu.init(true);}};var favoriteEmotes={};QuickEmoteMenu.prototype.initEmoteList=function(){emoteMenu=$("<div/>",{id:"emote-menu"});var emoteMenuHeader=$("<div/>",{id:"emote-menu-header"});var emoteMenuBody=$("<div/>",{id:"emote-menu-inner"});var emoteMenuBodyFav=$("<div/>",{id:"emote-menu-inner-fav",css:{"display":"none"}})
|
||||
var globalTab=$("<div/>",{class:"emote-menu-tab emote-menu-tab-selected",id:"emgb",text:"Global",click:function(){$("#emfa").removeClass("emote-menu-tab-selected");$("#emgb").addClass("emote-menu-tab-selected");$("#emote-menu-inner-fav").hide();$("#emote-menu-inner").show();}});var favoriteTab=$("<div/>",{class:"emote-menu-tab",id:"emfa",text:"Favorite",click:function(){$("#emgb").removeClass("emote-menu-tab-selected");$("#emfa").addClass("emote-menu-tab-selected");$("#emote-menu-inner").hide();$("#emote-menu-inner-fav").show();}});emoteMenuHeader.append(globalTab);emoteMenuHeader.append(favoriteTab);emoteMenu.append(emoteMenuHeader);var swrapper=$("<div/>",{class:"scroller-wrap"});var scroller=$("<div/>",{class:"scroller"});swrapper.append(scroller);scroller.append(emoteMenuBody);scroller.append(emoteMenuBodyFav);emoteMenu.append(swrapper);for(var emote in emotesTwitch.emotes){if(emotesTwitch.emotes.hasOwnProperty(emote)){var id=emotesTwitch.emotes[emote].image_id;emoteMenuBody.append($("<div/>",{class:"emote-container"}).append($("<img/>",{class:"emote-icon",id:emote,alt:"",src:"https://static-cdn.jtvnw.net/emoticons/v1/"+id+"/1.0",title:emote})));}}};QuickEmoteMenu.prototype.favorite=function(name,url){if(!favoriteEmotes.hasOwnProperty(name)){favoriteEmotes[name]=url;}
|
||||
|
|
Loading…
Reference in New Issue