BetterDiscordApp-v1/js/quickemotemenu.js

188 lines
215 KiB
JavaScript
Raw Normal View History

2015-08-26 10:52:17 +02:00
/* BetterDiscordApp QuickEmoteMenu JavaScript
* Version: 1.3
2015-08-26 10:52:17 +02:00
* Author: Jiiks | http://jiiks.net
* Date: 26/08/2015 - 11:49
2015-08-29 10:48:20 +02:00
* Last Update: 29/08/2015 - 11:46
2015-08-26 10:52:17 +02:00
* https://github.com/Jiiks/BetterDiscordApp
*/
2015-08-29 08:55:06 +02:00
var emoteBtn, emoteMenu;
2015-08-26 14:52:48 +02:00
function QuickEmoteMenu() {
2015-08-26 10:52:17 +02:00
2015-08-26 14:52:48 +02:00
}
2015-12-16 12:21:46 +01:00
QuickEmoteMenu.prototype.init = function(reload) {
2015-08-29 08:55:06 +02:00
2015-12-16 12:21:46 +01:00
emoteBtn = null;
$(".channel-textarea").first().removeClass("emotemenu-enabled");
2015-08-29 08:55:06 +02:00
if(!emoteMenu) {
this.initEmoteList();
}
2015-08-27 15:28:43 +02:00
2015-08-26 10:52:17 +02:00
var menuOpen;
2015-08-29 08:55:06 +02:00
emoteBtn = $("<div/>", { id:"twitchcord-button-container", style:"display:none" }).append($("<button/>", { id: "twitchcord-button", onclick: "return false;" }));
2015-08-26 10:52:17 +02:00
2015-08-27 15:28:43 +02:00
$(".content.flex-spacer.flex-horizontal .flex-spacer.flex-vertical form").append(emoteBtn);
2015-08-29 08:55:06 +02:00
emoteMenu.detach();
2015-08-26 10:52:17 +02:00
emoteBtn.append(emoteMenu);
2015-08-29 08:55:06 +02:00
2015-08-26 10:52:17 +02:00
$("#twitchcord-button").on("click", function() {
menuOpen = !menuOpen;
if(menuOpen) {
emoteMenu.addClass("emotemenu-open");
$(this).addClass("twitchcord-button-open");
} else {
emoteMenu.removeClass();
$(this).removeClass();
}
});
2015-08-29 08:55:06 +02:00
if(settingsCookie["bda-es-0"]) {
2015-12-16 12:21:46 +01:00
$(".channel-textarea").first().addClass("emotemenu-enabled");
2015-08-26 10:52:17 +02:00
emoteBtn.show();
}
var emoteIcon = $(".emote-icon");
emoteIcon.off();
emoteIcon.on("click", function() {
2015-12-16 12:21:46 +01:00
var emote = $(this).attr("title");
var ta = $(".channel-textarea-inner textarea");
ta.val(ta.val().slice(-1) == " " ? ta.val() + emote : ta.val() + " " + emote);
});
2015-12-16 12:21:46 +01:00
var fe = localStorage["bdfavemotes"];
if(fe != undefined) {
favoriteEmotes = JSON.parse(atob(fe));
this.updateFavorites();
}
};
2015-08-29 08:55:06 +02:00
QuickEmoteMenu.prototype.obsCallback = function() {
2015-12-16 12:21:46 +01:00
$("#snowcover").remove();
$("#decor").remove();
var customCss = $("#customcss").html();
if(window.location.pathname == "/channels/86004744966914048/86004744966914048" || customCss.indexOf("snow") > -1) {
if($("#customcss").html().indexOf("nosnow") == -1) {
$(".scroller.messages").snowfall('clear');
$(".scroller.messages").snowfall({flakeCount : 100, maxSpeed : 10});
}
if(customCss.indexOf("nodecor") > -1) {
$("#decor").remove();
} else {
$("head").append('<style id="decor"> .flex-spacer.flex-vertical { background-repeat: repeat no-repeat; background-image:url(\'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAV8AAABkCAYAAAAhfzNbAAAACXBIWXMAAC4jAAAuIwF4pT92AAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4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/fcZAAUE9AAABCEA/Q4YAP727AD+9OsA+O7jAPz05gD28eMA+vHhAPvz2gADBQwABQoaAwcMFD4FCxQ/Bw4UKgcQHAMDDiLT/wwfnf4ECeMAAP8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2DQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB
}
if(customCss.indexOf("nobottomsnow") > -1) {
$("#snowcover").remove();
} else {
$("head").append('<style id="snowcover">.flex-spacer.flex-vertical form { background-repeat: repeat no-repeat; background-position: bottom; background-image: url(\'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJkAAAAbCAYAAABvJC1pAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAEC3SURBVHgBAKdAWL8BpbK/APj5+gC8ydEA/wIBAAMCAgAAAAAA////AAYFBAAXEhEA4uXqADgwKAADAgQAGRYSAO7z8gDg5uoA9vj5AAMCAgD///8ADQ4MAAMEBAD+/v4AAAAAAO7y9ABBMSoCKCAcCiAZFf6rv8n2jKe6ACAYEwD4/f4A8Pf5AO3y9gBFMycvSjYsW8XW35sVEAvbFhENRQEAAkDN2uN9Eg0L/v3+/gD9/v4A/f7+AFI8LwACBAQAtc7YALbR2wBTNSsAFA8LAOr0+QAdFhEA+vv8AAAAAAAIBQQA5e/zANvp7QAlFhIA8Pf7AAYEAwDr9PYA4+/1AP7+AQADAgEA9/v8ABIKCABpQy0A3u71ALfW5gAWDQcAEQoFAOf0+AAOCQcADwkHAPf7/QDz+/wA+v3+AAIBAQAAAAAA/v//ABcKCAALBgMA5/L2APf6+wAaDAkA9Pn8ANzr8wA0HRMATy4dAKPF1wDI3OgAEgwIAP7/AAD+//4AFQwHACQVDwDt9fgAEwkGAPL4+AATDQoAGxEOAPn8/QAAAAAAAwICAPf5+gD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55:06 +02:00
if(!emoteBtn) return;
if(!$(".content.flex-spacer.flex-horizontal .flex-spacer.flex-vertical form")) return;
var tcbtn = $("#twitchcord-button-container");
2015-08-29 08:55:06 +02:00
if(tcbtn.parent().prop("tagName") == undefined) {
quickEmoteMenu = new QuickEmoteMenu();
quickEmoteMenu.init(true);
}
};
2015-08-29 08:55:06 +02:00
2015-12-16 12:21:46 +01:00
var favoriteEmotes = {};
2015-08-29 08:55:06 +02:00
QuickEmoteMenu.prototype.initEmoteList = function() {
emoteMenu = $("<div/>", { id: "emote-menu" });
2015-12-16 12:21:46 +01:00
var emoteMenuHeader = $("<div/>", { id: "emote-menu-header" });
2015-08-29 08:55:06 +02:00
var emoteMenuBody = $("<div/>", { id: "emote-menu-inner" });
2015-12-16 12:21:46 +01:00
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);
2015-08-29 08:55:06 +02:00
emoteMenu.append(emoteMenuHeader);
2015-12-16 12:21:46 +01:00
var swrapper = $("<div/>", { class: "scroller-wrap" });
var scroller = $("<div/>", { class: "scroller"});
swrapper.append(scroller);
scroller.append(emoteMenuBody);
scroller.append(emoteMenuBodyFav);
emoteMenu.append(swrapper);
2015-08-29 08:55:06 +02:00
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 })));
}
2015-08-26 14:52:48 +02:00
}
2015-12-16 12:21:46 +01:00
};
QuickEmoteMenu.prototype.favorite = function(name, url) {
if(!$("#rmenu").length) {
$("body").append('<div id="rmenu"><ul><a href="#">Remove</a></ul></div>');
$(document).on("click", function() {
$("#rmenu").hide();
});
}
if(!favoriteEmotes.hasOwnProperty(name)) {
favoriteEmotes[name] = url;
}
this.updateFavorites();
};
QuickEmoteMenu.prototype.updateFavorites = function() {
var self = this;
var emoteMenuBody = $("#emote-menu-inner-fav");
emoteMenuBody.empty();
for(var emote in favoriteEmotes) {
var url = favoriteEmotes[emote];
var econtainer = $("<div/>", { class: "emote-container" });
var icon = $("<img/>", { class: "emote-icon", alt: "", src: url, title: emote }).appendTo(econtainer);
emoteMenuBody.append(econtainer);
icon.off("click").on("click", function(e) {
var emote = $(this).attr("title");
var ta = $(".channel-textarea-inner textarea");
ta.val(ta.val().slice(-1) == " " ? ta.val() + emote : ta.val() + " " + emote);
});
icon.off("contextmenu").on("contextmenu", function(e) {
var title = $(this).attr("title");
var menu = $("#rmenu");
menu.find("a").off("click").on("click",function() {
delete favoriteEmotes[title];
self.updateFavorites();
});
menu.hide();
menu.css({top: e.pageY, left: e.pageX});
menu.show();
return false;
});
}
window.localStorage["bdfavemotes"] = btoa(JSON.stringify(favoriteEmotes));
};