Fixed edit emotes
This commit is contained in:
parent
97daae9090
commit
63a8d60ee1
83
js/main.js
83
js/main.js
|
@ -375,37 +375,46 @@ EmoteModule.prototype.injectEmote = function(node) {
|
||||||
if(!node.parentElement) return;
|
if(!node.parentElement) return;
|
||||||
|
|
||||||
var parent = node.parentElement;
|
var parent = node.parentElement;
|
||||||
|
|
||||||
if(parent.tagName != "SPAN") return;
|
if(parent.tagName != "SPAN") return;
|
||||||
if(!$(parent.parentElement).hasClass("markup") && !$(parent.parentElement).hasClass("message-content")) return;
|
|
||||||
|
var edited = false;
|
||||||
|
|
||||||
|
if($(parent.parentElement).hasClass("edited")) {
|
||||||
|
parent = parent.parentElement.parentElement.firstChild; //:D
|
||||||
|
edited = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//if(!$(parent.parentElement).hasClass("markup") && !$(parent.parentElement).hasClass("message-content")) return;
|
||||||
|
|
||||||
var parentInnerHTML = parent.innerHTML;
|
function inject() {
|
||||||
var words = parentInnerHTML.split(/\s+/g);
|
if(!$(parent.parentElement).hasClass("markup") && !$(parent.parentElement).hasClass("message-content")) { return; }
|
||||||
|
|
||||||
if(!words) return;
|
var parentInnerHTML = parent.innerHTML;
|
||||||
|
var words = parentInnerHTML.split(/\s+/g);
|
||||||
|
|
||||||
words.some(function(word) {
|
if(!words) return;
|
||||||
|
|
||||||
if(word.slice(0, 4) == "[!s]" ) {
|
words.some(function(word) {
|
||||||
|
|
||||||
parentInnerHTML = parentInnerHTML.replace("[!s]", "");
|
if(word.slice(0, 4) == "[!s]" ) {
|
||||||
|
|
||||||
var markup = $(parent).parent();
|
parentInnerHTML = parentInnerHTML.replace("[!s]", "");
|
||||||
|
var markup = $(parent).parent();
|
||||||
|
var reactId = markup.attr("data-reactid");
|
||||||
|
|
||||||
|
if(spoilered.indexOf(reactId) > -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var reactId = markup.attr("data-reactid");
|
markup.addClass("spoiler");
|
||||||
|
markup.on("click", function() {
|
||||||
|
$(this).removeClass("spoiler");
|
||||||
|
spoilered.push($(this).attr("data-reactid"));
|
||||||
|
});
|
||||||
|
|
||||||
if(spoilered.indexOf(reactId) > -1) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
markup.addClass("spoiler");
|
|
||||||
|
|
||||||
markup.on("click", function() {
|
|
||||||
$(this).removeClass("spoiler");
|
|
||||||
spoilered.push($(this).attr("data-reactid"));
|
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(word.length < 4) {
|
if(word.length < 4) {
|
||||||
return;
|
return;
|
||||||
|
@ -414,24 +423,24 @@ EmoteModule.prototype.injectEmote = function(node) {
|
||||||
if($.inArray(word, bemotes) != -1) return;
|
if($.inArray(word, bemotes) != -1) return;
|
||||||
|
|
||||||
if (emotesTwitch.emotes.hasOwnProperty(word)) {
|
if (emotesTwitch.emotes.hasOwnProperty(word)) {
|
||||||
var len = Math.round(word.length / 4);
|
var len = Math.round(word.length / 4);
|
||||||
parentInnerHTML = parentInnerHTML.replace(word, '<img class="emote" alt="' + word.substr(0, len) + "\uFDD9" + word.substr(len, len) + "\uFDD9" + word.substr(len * 2, len) + "\uFDD9" + word.substr(len * 3) + '" src="' + twitchEmoteUrlStart + emotesTwitch.emotes[word].image_id + twitchEmoteUrlEnd + '" />' );
|
parentInnerHTML = parentInnerHTML.replace(word, '<img class="emote" alt="' + word.substr(0, len) + "\uFDD9" + word.substr(len, len) + "\uFDD9" + word.substr(len * 2, len) + "\uFDD9" + word.substr(len * 3) + '" src="' + twitchEmoteUrlStart + emotesTwitch.emotes[word].image_id + twitchEmoteUrlEnd + '" />' );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof emotesFfz !== 'undefined' && settingsCookie["bda-es-1"]) {
|
if (typeof emotesFfz !== 'undefined' && settingsCookie["bda-es-1"]) {
|
||||||
if (emotesFfz.hasOwnProperty(word)) {
|
if (emotesFfz.hasOwnProperty(word)) {
|
||||||
var len = Math.round(word.length / 4);
|
var len = Math.round(word.length / 4);
|
||||||
parentInnerHTML = parentInnerHTML.replace(word, '<img class="emote" alt="' + word.substr(0, len) + "\uFDD9" + word.substr(len, len) + "\uFDD9" + word.substr(len * 2, len) + "\uFDD9" + word.substr(len * 3) + '" src="' + ffzEmoteUrlStart + emotesFfz[word] + ffzEmoteUrlEnd + '" />');
|
parentInnerHTML = parentInnerHTML.replace(word, '<img class="emote" alt="' + word.substr(0, len) + "\uFDD9" + word.substr(len, len) + "\uFDD9" + word.substr(len * 2, len) + "\uFDD9" + word.substr(len * 3) + '" src="' + ffzEmoteUrlStart + emotesFfz[word] + ffzEmoteUrlEnd + '" />');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof emotesBTTV !== 'undefined' && settingsCookie["bda-es-2"]) {
|
if (typeof emotesBTTV !== 'undefined' && settingsCookie["bda-es-2"]) {
|
||||||
if (emotesBTTV.hasOwnProperty(word)) {
|
if (emotesBTTV.hasOwnProperty(word)) {
|
||||||
var len = Math.round(word.length / 4);
|
var len = Math.round(word.length / 4);
|
||||||
parentInnerHTML = parentInnerHTML.replace(word, '<img class="emote" alt="' + word.substr(0, len) + "\uFDD9" + word.substr(len, len) + "\uFDD9" + word.substr(len * 2, len) + "\uFDD9" + word.substr(len * 3) + '" src="' + emotesBTTV[word] + '" />');
|
parentInnerHTML = parentInnerHTML.replace(word, '<img class="emote" alt="' + word.substr(0, len) + "\uFDD9" + word.substr(len, len) + "\uFDD9" + word.substr(len * 2, len) + "\uFDD9" + word.substr(len * 3) + '" src="' + emotesBTTV[word] + '" />');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,9 +453,9 @@ EmoteModule.prototype.injectEmote = function(node) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subEmotesTwitch.hasOwnProperty(word)) {
|
if (subEmotesTwitch.hasOwnProperty(word)) {
|
||||||
var len = Math.round(word.length / 4);
|
var len = Math.round(word.length / 4);
|
||||||
parentInnerHTML = parentInnerHTML.replace(word, '<img class="emote" alt="' + word.substr(0, len) + "\uFDD9" + word.substr(len, len) + "\uFDD9" + word.substr(len * 2, len) + "\uFDD9" + word.substr(len * 3) + '" src="' + twitchEmoteUrlStart + subEmotesTwitch[word] + twitchEmoteUrlEnd + '" />');
|
parentInnerHTML = parentInnerHTML.replace(word, '<img class="emote" alt="' + word.substr(0, len) + "\uFDD9" + word.substr(len, len) + "\uFDD9" + word.substr(len * 2, len) + "\uFDD9" + word.substr(len * 3) + '" src="' + twitchEmoteUrlStart + subEmotesTwitch[word] + twitchEmoteUrlEnd + '" />');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -459,6 +468,14 @@ EmoteModule.prototype.injectEmote = function(node) {
|
||||||
//Scrollfix
|
//Scrollfix
|
||||||
var scrollPane = $(".scroller.messages").first();
|
var scrollPane = $(".scroller.messages").first();
|
||||||
scrollPane.scrollTop(scrollPane.scrollTop() + (newHeight - oldHeight));
|
scrollPane.scrollTop(scrollPane.scrollTop() + (newHeight - oldHeight));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(edited) {
|
||||||
|
setTimeout(inject, 250);
|
||||||
|
} else {
|
||||||
|
inject();
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
EmoteModule.prototype.autoCapitalize = function() {
|
EmoteModule.prototype.autoCapitalize = function() {
|
||||||
|
|
Loading…
Reference in New Issue