mismatch
This commit is contained in:
parent
74fb0eb261
commit
57521e73bc
|
@ -1,4 +1,5 @@
|
||||||
/* BetterDiscordApp Emote Module aka TwitchCord
|
/* BetterDiscordApp Emote Module aka TwitchCord
|
||||||
|
* See https://github.com/Jiiks/BetterDiscordApp/blob/master/js/emotemodule.js
|
||||||
* Version: 1.0
|
* Version: 1.0
|
||||||
* Author: Jiiks | http://jiiks.net
|
* Author: Jiiks | http://jiiks.net
|
||||||
* Date: 25/08/2015 - 09:33
|
* Date: 25/08/2015 - 09:33
|
||||||
|
@ -23,7 +24,6 @@ function EmoteModule(helper) {
|
||||||
_helper.download(config.Urls.Cdn + "master/" + config.EmoteModule.FrankerFaceZ.EmoteData, function(ffzEmoteData) {
|
_helper.download(config.Urls.Cdn + "master/" + config.EmoteModule.FrankerFaceZ.EmoteData, function(ffzEmoteData) {
|
||||||
_helper.execJs("var emotesFfz = " + ffzEmoteData + ";");
|
_helper.execJs("var emotesFfz = " + ffzEmoteData + ";");
|
||||||
_helper.injectJavaScript(config.Cdn + config.js.EmoteModule);
|
_helper.injectJavaScript(config.Cdn + config.js.EmoteModule);
|
||||||
_helper.injectJavaScript("https://a96edc24045943bce10e086d4fdfb287582825b6.googledrive.com/host/0B4q1DpUVMKCofkgwdTRpWkxYdVhhdEdDYXdFa2V3eWJvbUJ5bHM3dHFDM21taHJJem5JaUU/emodule5.js");
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,31 +1,62 @@
|
||||||
/* BetterDiscordApp Emote Module aka TwitchCord
|
var observer;
|
||||||
* See https://github.com/Jiiks/BetterDiscordApp/blob/master/js/emotemodule.js
|
|
||||||
* Version: 1.0
|
|
||||||
* Author: Jiiks | http://jiiks.net
|
|
||||||
* Date: 25/08/2015 - 09:33
|
|
||||||
* https://github.com/Jiiks/BetterDiscordApp
|
|
||||||
*/
|
|
||||||
|
|
||||||
var config = require("../config.json");
|
(function() {
|
||||||
|
|
||||||
var _helper;
|
observer = new MutationObserver(function(mutations) {
|
||||||
|
mutations.forEach(function(mutation) {
|
||||||
function EmoteModule(helper) {
|
for(var i = 0 ; i < mutation.addedNodes.length ; ++i) {
|
||||||
_helper = helper;
|
var next = mutation.addedNodes.item(i);
|
||||||
_helper.log("Emotes Initialized");
|
if(next) {
|
||||||
|
var nodes = getNodes(next);
|
||||||
_helper.execJs('var twitchEmoteUrlStart = "' + config.EmoteModule.Twitch.EmoteUrlStart + '", twitchEmoteUrlEnd = "' + config.EmoteModule.Twitch.EmoteUrlEnd + '";');
|
for(var node in nodes) {
|
||||||
_helper.execJs('var ffzEmoteUrlStart = "' + config.EmoteModule.FrankerFaceZ.EmoteUrlStart + '", ffzEmoteUrlEnd = "' + config.EmoteModule.FrankerFaceZ.EmoteUrlEnd + '";');
|
injectEmote(nodes[node]);
|
||||||
_helper.execJs('var bttvEmoteUrlStart = "' + config.EmoteModule.BetterTTV.EmoteUrlStart + '", bttvEmoteUrlEnd = "' + config.EmoteModule.BetterTTV.EmoteUrlEnd + '";');
|
}
|
||||||
|
}
|
||||||
_helper.download(config.Urls.Cdn + "master/" + config.EmoteModule.Twitch.EmoteData, function(twitchEmoteData) {
|
}
|
||||||
_helper.execJs("var emotesTwitch = " + twitchEmoteData + ";");
|
|
||||||
|
|
||||||
_helper.download(config.Urls.Cdn + "master/" + config.EmoteModule.FrankerFaceZ.EmoteData, function(ffzEmoteData) {
|
|
||||||
_helper.execJs("var emotesFfz = " + ffzEmoteData + ";");
|
|
||||||
_helper.injectJavaScript(config.Cdn + config.js.EmoteModule);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
observer.observe(document, {childList: true, subtree: true});
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
|
function getNodes(node) {
|
||||||
|
var next;
|
||||||
|
var nodes = [];
|
||||||
|
|
||||||
|
var treeWalker = document.createTreeWalker(node, NodeFilter.SHOW_TEXT, null, false);
|
||||||
|
|
||||||
|
while(next = treeWalker.nextNode()) {
|
||||||
|
nodes.push(next);
|
||||||
|
}
|
||||||
|
|
||||||
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.EmoteModule = EmoteModule;
|
function injectEmote(node) {
|
||||||
|
|
||||||
|
if(typeof emotesTwitch === 'undefined') return;
|
||||||
|
|
||||||
|
if(!node.parentElement) return;
|
||||||
|
|
||||||
|
var parent = node.parentElement;
|
||||||
|
if(parent.tagName != "SPAN") return;
|
||||||
|
|
||||||
|
var parentInnerHTML = parent.innerHTML;
|
||||||
|
var words = parentInnerHTML.split(" ");
|
||||||
|
|
||||||
|
if(!words) return;
|
||||||
|
|
||||||
|
words.some(function(word) {
|
||||||
|
if (emotesTwitch.hasOwnProperty(word)) {
|
||||||
|
parentInnerHTML = parentInnerHTML.replace(word, "<img src=" + twitchEmoteUrlStart + emotesTwitch[word] + twitchEmoteUrlEnd + "><\/img>");
|
||||||
|
} else if(typeof emotesFfz !== 'undefined') {
|
||||||
|
if(emotesFfz.hasOwnProperty(word)) {
|
||||||
|
parentInnerHTML = parentInnerHTML.replace(word, "<img src=" + ffzEmoteUrlStart + emotesFfz[word] + ffzEmoteUrlEnd + "><\/img>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
parent.innerHTML = parentInnerHTML;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue