From cf2456ae639fc9d299d4d4eb6bb5ff807ced3e4c Mon Sep 17 00:00:00 2001 From: zSoulweaver Date: Fri, 4 Dec 2015 09:02:32 +1000 Subject: [PATCH] Add Twitch styled emote titles Also makes you able to copy emotes when 'Show Titles' is turned off, due to the alt attribute. --- js/main.js | 68 ++++++++++++++++++++++++------------------------------ 1 file changed, 30 insertions(+), 38 deletions(-) diff --git a/js/main.js b/js/main.js index e6030d4..c1ca2a0 100644 --- a/js/main.js +++ b/js/main.js @@ -414,56 +414,32 @@ EmoteModule.prototype.injectEmote = function(node) { return; } - if(emotesTwitch.emotes.hasOwnProperty(word)) { - if (settingsCookie["bda-es-6"]) { - var len = Math.round(word.length/4); - parentInnerHTML = parentInnerHTML.replace(word, ''); + if (emotesTwitch.emotes.hasOwnProperty(word)) { + var len = Math.round(word.length / 4); + parentInnerHTML = parentInnerHTML.replace(word, '' + word.substr(0, len) + ' ); return; - } - else { - parentInnerHTML = parentInnerHTML.replace(word, "<\/img>"); - return; - } } - if(typeof emotesFfz !== 'undefined' && settingsCookie["bda-es-1"]) { - if(emotesFfz.hasOwnProperty(word)) { - if (settingsCookie["bda-es-6"]) { - var len = Math.round(word.length/4); - parentInnerHTML = parentInnerHTML.replace(word, ''); + if (typeof emotesFfz !== 'undefined' && settingsCookie["bda-es-1"]) { + if (emotesFfz.hasOwnProperty(word)) { + var len = Math.round(word.length / 4); + parentInnerHTML = parentInnerHTML.replace(word, '' + word.substr(0, len) + '); return; } - else { - parentInnerHTML = parentInnerHTML.replace(word, "<\/img>"); - return; - } - } } - if(typeof emotesBTTV !== 'undefined' && settingsCookie["bda-es-2"]) { - if(emotesBTTV.hasOwnProperty(word)) { - if (settingsCookie["bda-es-6"]) { - var len = Math.round(word.length/4); - parentInnerHTML = parentInnerHTML.replace(word, ''); + if (typeof emotesBTTV !== 'undefined' && settingsCookie["bda-es-2"]) { + if (emotesBTTV.hasOwnProperty(word)) { + var len = Math.round(word.length / 4); + parentInnerHTML = parentInnerHTML.replace(word, '' + word.substr(0, len) + '); return; - } - else { - parentInnerHTML = parentInnerHTML.replace(word, "<\/img>"); - return; - } } } if (subEmotesTwitch.hasOwnProperty(word)) { - if (settingsCookie["bda-es-6"]) { - var len = Math.round(word.length/4); - parentInnerHTML = parentInnerHTML.replace(word, ''); + var len = Math.round(word.length / 4); + parentInnerHTML = parentInnerHTML.replace(word, '' + word.substr(0, len) + '); return; - } - else { - parentInnerHTML = parentInnerHTML.replace(word, "<\/img>"); - return; - } } }); @@ -812,7 +788,15 @@ SettingsPanel.prototype.init = function() { settingsCookie["bda-jd"] = false; mainCore.saveSettings(); } - + + if (settingsCookie["bda-es-6"]) { + //Pretty emote titles + emoteNamePopup = $("
"); + $(document).on("mouseover", ".emote", function() { console.log("yes"); var x = $(this).offset(); var title = $(this).attr("alt"); $(emoteNamePopup).find(".tipsy-inner").text(title); $(emoteNamePopup).css('left', x.left - 25); $(emoteNamePopup).css('top', x.top - 32); $("div[data-reactid='.0.1.1']").append($(emoteNamePopup));}); + $(document).on("mouseleave", ".emote", function(){$(".tipsy").remove()}); + } else { + $(document).off('mouseover', '.emote'); + } }; SettingsPanel.prototype.applyCustomCss = function(css) { @@ -940,6 +924,14 @@ SettingsPanel.prototype.construct = function() { } else { voiceMode.disable(); } + if (settingsCookie["bda-es-6"]) { + //Pretty emote titles + emoteNamePopup = $("
"); + $(document).on("mouseover", ".emote", function() { console.log("yes"); var x = $(this).offset(); var title = $(this).attr("alt"); $(emoteNamePopup).find(".tipsy-inner").text(title); $(emoteNamePopup).css('left', x.left - 25); $(emoteNamePopup).css('top', x.top - 32); $("div[data-reactid='.0.1.1']").append($(emoteNamePopup));}); + $(document).on("mouseleave", ".emote", function(){$(".tipsy").remove()}); + } else { + $(document).off('mouseover', '.emote'); + } mainCore.saveSettings(); }