diff --git a/dev/js/00core.js b/dev/js/00core.js deleted file mode 100644 index 45a4b92c..00000000 --- a/dev/js/00core.js +++ /dev/null @@ -1,265 +0,0 @@ -/* BetterDiscordApp Core JavaScript - * Version: 1.53 - * Author: Jiiks | http://jiiks.net - * Date: 27/08/2015 - 16:36 - * Last Update: 02/04/2016 - * https://github.com/Jiiks/BetterDiscordApp - */ - -var BD; - -function Core() { - BD = this; -} - -Core.prototype.init = function () { - var self = this; - this.version = version; - - if (this.version < bdConfig.versionInfo.supportedVersion) { - this.alert("Not Supported", "BetterDiscord v" + this.version + "(your version)" + " is not supported by the latest js(" + bdConfig.versionInfo.version + ").

Please download the latest version from BetterDiscord.net"); - return; - } - - this.modules = { - emoteModule: new EmoteModule(), - publicServers: new PublicServers(), - emoteMenu: new QuickEmoteMenu(), - cssEditor: new customCssEditor(), - settingsPanel: new SettingsPanel(), - utils: new Utils(), - voiceMode: new VoiceMode(), - pluginModule: new pluginModule(), - themeModule: new ThemeModule() - } - - this.modules.utils.getHash(); - - this.modules.emoteModule.init(); - - this.initSettings(); - this.initObserver(); - - - //Incase were too fast - function gwDefer() { - self.modules.utils.log(new Date().getTime() + " Defer"); - - if ($(".guilds-wrapper .guilds").children().length > 0) { - self.modules.utils.log(new Date().getTime() + " Defer Loaded"); - var guilds = $(".guilds>li:first-child"); - - var showChannelsButton = $("' + - ' ' + - '
' + - '
'; - - if (bdConfig.changelog.changes != null) { - changeLog += '' + - '

' + - ' New Stuff' + - '

' + - ''; - } - - if (bdConfig.changelog.fixes != null) { - changeLog += '' + - '

' + - ' Fixed' + - '

' + - ''; - } - - if (bdConfig.changelog.upcoming != null) { - changeLog += '' + - '

' + - ' Coming Soon' + - '

' + - ''; - } - - changeLog += '' + - '
' + - '
' + - ' ' + - ' ' + - ' ' + - ''; - - return changeLog; -}; - -Core.prototype.alert = function (title, text) { - $("body").append('' + - '
' + - '
' + - ' ' + title + '' + - '
×
' + - '
' + - '
' + - '
' + - '
' + text + '
' + - '
' + - '
' + - '
'); -}; \ No newline at end of file diff --git a/dev/js/00settings.js b/dev/js/00settings.js index 19ecd454..e69de29b 100644 --- a/dev/js/00settings.js +++ b/dev/js/00settings.js @@ -1,121 +0,0 @@ -var bdConfig = (function() { - return { - versionInfo: { - version: 1.63, - supportedVersion: "0.2.5" - }, - defaults: { - "version": 1.63, - "bda-gs-0": false, - "bda-gs-1": true, - "bda-gs-2": false, - "bda-gs-3": false, - "bda-gs-4": false, - "bda-gs-5": true, - "bda-es-0": true, - "bda-es-1": true, - "bda-es-2": true, - "bda-es-3": false, - "bda-es-4": false, - "bda-es-5": true, - "bda-es-6": true, - "bda-es-7": true, - "bda-es-8": true, - "bda-jd": true, - "bda-es-8": true, - "bda-dc-0": false, - "bda-css-0": false, - "bda-css-1": false, - "bda-es-9": true - }, - options: { - "Save logs locally": { "id": "bda-gs-0", "info": "Saves chat logs locally", "implemented": false, "hidden": false, "cat": "core"}, - "Public Servers": { "id": "bda-gs-1", "info": "Display public servers button", "implemented": true, "hidden": false, "cat": "core"}, - "Minimal Mode": { "id": "bda-gs-2", "info": "Hide elements and reduce the size of elements.", "implemented": true, "hidden": false, "cat": "core"}, - "Voice Mode": { "id": "bda-gs-4", "info": "Only show voice chat", "implemented": true, "hidden": false, "cat": "core"}, - "Hide Channels": { "id": "bda-gs-3", "info": "Hide channels in minimal mode", "implemented": true, "hidden": false, "cat": "core"}, - "Dark Mode": { "id": "bda-gs-5", "info": "Make certain elements dark by default(wip)", "implemented": true, "hidden": false, "cat": "core"}, - "Override Default Emotes": { "id": "bda-es-5", "info": "Override default emotes", "implemented": false, "hidden": false, "cat": "core"}, - "Voice Disconnect": { "id": "bda-dc-0", "info": "Disconnect from voice server when closing Discord", "implemented": true, "hidden": false, "cat": "core"}, - "Custom css live update": { "id": "bda-css-0", "info": "", "implemented": true, "hidden": true , "cat": "core"}, - "Custom css auto udpate": { "id": "bda-css-1", "info": "", "implemented": true, "hidden": true , "cat": "core"}, - - "Show Emotes": { "id": "bda-es-7", "info": "Show any emotes", "implemented": true, "hidden": false, "cat": "emote"}, - "FrankerFaceZ Emotes": { "id": "bda-es-1", "info": "Show FrankerFaceZ Emotes", "implemented": true, "hidden": false, "cat": "emote"}, - "BetterTTV Emotes": { "id": "bda-es-2", "info": "Show BetterTTV Emotes", "implemented": true, "hidden": false, "cat": "emote"}, - "Emote Menu": { "id": "bda-es-0", "info": "Show Twitch/Favourite emotes in emote menu", "implemented": true, "hidden": false, "cat": "emote"}, - "Emoji Menu": { "id": "bda-es-9", "info": "Show Discord emoji menu", "implemented": true, "hidden": false, "cat": "emote"}, - "Emote Autocomplete": { "id": "bda-es-3", "info": "Autocomplete emote commands", "implemented": false, "hidden": false, "cat": "emote"}, - "Emote Auto Capitalization": { "id": "bda-es-4", "info": "Autocapitalize emote commands", "implemented": true, "hidden": false, "cat": "emote"}, - "Show Names": { "id": "bda-es-6", "info": "Show emote names on hover", "implemented": true, "hidden": false, "cat": "emote"}, - "Show emote modifiers": { "id": "bda-es-8", "info": "Enable emote mods", "implemented": true, "hidden": false, "cat": "emote"}, - }, - links: { - "Jiiks.net": { "text": "Jiiks.net", "href": "https://jiiks.net", "target": "_blank" }, - "twitter": { "text": "Twitter", "href": "https://twitter.com/jiiksi", "target": "_blank" }, - "github": { "text": "Github", "href": "https://github.com/jiiks", "target": "_blank" }, - "betterdiscord.net": { "text": "BetterDiscord.net", "href": "https://betterdiscord.net", "target": "_blank" } - }, - changelog: { - "changes": { - "darkmode": { - "title": "v1.63 : Dark Mode", - "text": "Dark mode makes certain elements dark by default(currently only applies to emote menu)", - "img": "" - }, - "emotemenu": { - "title": "v1.62 : Brand new emote menu that fits in Discord emoji menu!", - "text": "The emote menu has been replaced by a new one that injects itself in the Discord emoji menu!", - "img": "" - }, - "cccss": { - "title": "v1.61 : New custom CSS editor", - "text": "The custom CSS editor now has options and can be detached!", - "img": "" - }, - "vdc": { - "title": "v1.61 : Voice Disconnect", - "text": "Disconnect from voice server when closing Discord!", - "img": "" - }, - "pslist": { - "title": "v1.60 : New public server list!", - "text": 'New and shiny public server list powered by DiscordServers.com!', - "img": "" - }, - "api": { - "title": "v1.59 : New plugin api callback", - "text": "Use the `observer(e)` callback instead of creating your own MutationObserver", - "img": "" - }, - "emotemods": { - "title": "v1.59 : New emote mods!", - "text": "The following emote mods have been added: :shake2, :shake3, :flap", - "img": "" - }, - "minmode": { - "title": "v1.59: Minimal mode", - "text": "Minimal mode embed fixed size has been removed", - "img": "" - } - }, - "fixes": { - "modal": { - "title": "v1.62 : Fixed modals", - "text": "Fixed broken modal introduced by 0.0.287", - "imt": "" - }, - "emotes": { - "title": "v1.59 : Native sub emote mods", - "text": "Emote mods now work with native sub emotes!", - "img": "" - }, - "emotes2": { - "title": "v1.59 : Emote mods and custom emotes", - "text": "Emote mods will no longer interfere with custom emotes using :", - "img": "" - } - } - } - } -})(); \ No newline at end of file diff --git a/dev/js/01core.js b/dev/js/01core.js index caf1f65a..23653b09 100644 --- a/dev/js/01core.js +++ b/dev/js/01core.js @@ -5,18 +5,43 @@ * Last Update: 02/04/2016 * https://github.com/Jiiks/BetterDiscordApp */ - -var BD; - var settingsPanel, emoteModule, utils, quickEmoteMenu, opublicServers, voiceMode, pluginModule, themeModule, customCssEditor; var jsVersion = 1.63; var supportedVersion = "0.2.5"; var mainObserver; +var twitchEmoteUrlStart = "https://static-cdn.jtvnw.net/emoticons/v1/"; +var twitchEmoteUrlEnd = "/1.0"; +var ffzEmoteUrlStart = "https://cdn.frankerfacez.com/emoticon/"; +var ffzEmoteUrlEnd = "/1"; +var bttvEmoteUrlStart = "https://cdn.betterttv.net/emote/"; +var bttvEmoteUrlEnd = "/1x"; + var mainCore; +var settings = { + "Save logs locally": { "id": "bda-gs-0", "info": "Saves chat logs locally", "implemented": false, "hidden": false, "cat": "core"}, + "Public Servers": { "id": "bda-gs-1", "info": "Display public servers button", "implemented": true, "hidden": false, "cat": "core"}, + "Minimal Mode": { "id": "bda-gs-2", "info": "Hide elements and reduce the size of elements.", "implemented": true, "hidden": false, "cat": "core"}, + "Voice Mode": { "id": "bda-gs-4", "info": "Only show voice chat", "implemented": true, "hidden": false, "cat": "core"}, + "Hide Channels": { "id": "bda-gs-3", "info": "Hide channels in minimal mode", "implemented": true, "hidden": false, "cat": "core"}, + "Dark Mode": { "id": "bda-gs-5", "info": "Make certain elements dark by default(wip)", "implemented": true, "hidden": false, "cat": "core"}, + "Override Default Emotes": { "id": "bda-es-5", "info": "Override default emotes", "implemented": false, "hidden": false, "cat": "core"}, + "Voice Disconnect": { "id": "bda-dc-0", "info": "Disconnect from voice server when closing Discord", "implemented": true, "hidden": false, "cat": "core"}, + "Custom css live update": { "id": "bda-css-0", "info": "", "implemented": true, "hidden": true , "cat": "core"}, + "Custom css auto udpate": { "id": "bda-css-1", "info": "", "implemented": true, "hidden": true , "cat": "core"}, + "Show Emotes": { "id": "bda-es-7", "info": "Show any emotes", "implemented": true, "hidden": false, "cat": "emote"}, + "FrankerFaceZ Emotes": { "id": "bda-es-1", "info": "Show FrankerFaceZ Emotes", "implemented": true, "hidden": false, "cat": "emote"}, + "BetterTTV Emotes": { "id": "bda-es-2", "info": "Show BetterTTV Emotes", "implemented": true, "hidden": false, "cat": "emote"}, + "Emote Menu": { "id": "bda-es-0", "info": "Show Twitch/Favourite emotes in emote menu", "implemented": true, "hidden": false, "cat": "emote"}, + "Emoji Menu": { "id": "bda-es-9", "info": "Show Discord emoji menu", "implemented": true, "hidden": false, "cat": "emote"}, + "Emote Autocomplete": { "id": "bda-es-3", "info": "Autocomplete emote commands", "implemented": false, "hidden": false, "cat": "emote"}, + "Emote Auto Capitalization": { "id": "bda-es-4", "info": "Autocapitalize emote commands", "implemented": true, "hidden": false, "cat": "emote"}, + "Show Names": { "id": "bda-es-6", "info": "Show emote names on hover", "implemented": true, "hidden": false, "cat": "emote"}, + "Show emote modifiers": { "id": "bda-es-8", "info": "Enable emote mods", "implemented": true, "hidden": false, "cat": "emote"}, +}; var links = { "Jiiks.net": { "text": "Jiiks.net", "href": "http://jiiks.net", "target": "_blank" }, @@ -24,94 +49,6 @@ var links = { "github": { "text": "Github", "href": "http://github.com/jiiks", "target": "_blank" } }; - -var bdConfig = (function() { - - return { - versionInfo: { - version: 1.63, - supportedVersion: "0.2.5" - }, - defaults: { - "version": 1.63, - "bda-gs-0": false, - "bda-gs-1": true, - "bda-gs-2": false, - "bda-gs-3": false, - "bda-gs-4": false, - "bda-gs-5": true, - "bda-es-0": true, - "bda-es-1": true, - "bda-es-2": true, - "bda-es-3": false, - "bda-es-4": false, - "bda-es-5": true, - "bda-es-6": true, - "bda-es-7": true, - "bda-es-8": true, - "bda-jd": true, - "bda-es-8": true, - "bda-dc-0": false, - "bda-css-0": false, - "bda-css-1": false, - "bda-es-9": true - }, - options: { - "Save logs locally": { "id": "bda-gs-0", "info": "Saves chat logs locally", "implemented": false, "hidden": false, "cat": "core"}, - "Public Servers": { "id": "bda-gs-1", "info": "Display public servers button", "implemented": true, "hidden": false, "cat": "core"}, - "Minimal Mode": { "id": "bda-gs-2", "info": "Hide elements and reduce the size of elements.", "implemented": true, "hidden": false, "cat": "core"}, - "Voice Mode": { "id": "bda-gs-4", "info": "Only show voice chat", "implemented": true, "hidden": false, "cat": "core"}, - "Hide Channels": { "id": "bda-gs-3", "info": "Hide channels in minimal mode", "implemented": true, "hidden": false, "cat": "core"}, - "Dark Mode": { "id": "bda-gs-5", "info": "Make certain elements dark by default(wip)", "implemented": true, "hidden": false, "cat": "core"}, - "Override Default Emotes": { "id": "bda-es-5", "info": "Override default emotes", "implemented": false, "hidden": false, "cat": "core"}, - "Voice Disconnect": { "id": "bda-dc-0", "info": "Disconnect from voice server when closing Discord", "implemented": true, "hidden": false, "cat": "core"}, - "Custom css live update": { "id": "bda-css-0", "info": "", "implemented": true, "hidden": true , "cat": "core"}, - "Custom css auto udpate": { "id": "bda-css-1", "info": "", "implemented": true, "hidden": true , "cat": "core"}, - - "Show Emotes": { "id": "bda-es-7", "info": "Show any emotes", "implemented": true, "hidden": false, "cat": "emote"}, - "FrankerFaceZ Emotes": { "id": "bda-es-1", "info": "Show FrankerFaceZ Emotes", "implemented": true, "hidden": false, "cat": "emote"}, - "BetterTTV Emotes": { "id": "bda-es-2", "info": "Show BetterTTV Emotes", "implemented": true, "hidden": false, "cat": "emote"}, - "Emote Menu": { "id": "bda-es-0", "info": "Show Twitch/Favourite emotes in emote menu", "implemented": true, "hidden": false, "cat": "emote"}, - "Emoji Menu": { "id": "bda-es-9", "info": "Show Discord emoji menu", "implemented": true, "hidden": false, "cat": "emote"}, - "Emote Autocomplete": { "id": "bda-es-3", "info": "Autocomplete emote commands", "implemented": false, "hidden": false, "cat": "emote"}, - "Emote Auto Capitalization": { "id": "bda-es-4", "info": "Autocapitalize emote commands", "implemented": true, "hidden": false, "cat": "emote"}, - "Show Names": { "id": "bda-es-6", "info": "Show emote names on hover", "implemented": true, "hidden": false, "cat": "emote"}, - "Show emote modifiers": { "id": "bda-es-8", "info": "Enable emote mods", "implemented": true, "hidden": false, "cat": "emote"}, - }, - links: { - "Jiiks.net": { "text": "Jiiks.net", "href": "https://jiiks.net", "target": "_blank" }, - "twitter": { "text": "Twitter", "href": "https://twitter.com/jiiksi", "target": "_blank" }, - "github": { "text": "Github", "href": "https://github.com/jiiks", "target": "_blank" }, - "betterdiscord.net": { "text": "BetterDiscord.net", "href": "https://betterdiscord.net", "target": "_blank" } - }, - urls: { - twitch: { - home: "https://twitch.tv/", - emotes: { - start: "https://static-cdn.jtvnw.net/emoticons/v1/", - end: "/1.0" - } - }, - bttv: { - home: "https://betterttv.net", - emotes: { - start: "https://cdn.betterttv.net/emote/", - end: "/1x" - } - }, - ffz: { - home: "https://frankerfacez.com/", - emotes: { - start: "https://cdn.frankerfacez.com/emoticon/", - end: "/1" - } - } - } - } - -})(); - - var defaultCookie = { "version": jsVersion, "bda-gs-0": false, @@ -129,7 +66,7 @@ var defaultCookie = { "bda-es-6": true, "bda-es-7": true, "bda-es-8": true, - "bda-jd": true, + "bda-jd": true, "bda-es-8": true, "bda-dc-0": false, "bda-css-0": false, @@ -201,22 +138,19 @@ var bdchangelog = { var settingsCookie = {}; -function Core() { - BD = this; -} +function Core() {} Core.prototype.init = function () { var self = this; - this.version = version; - this.jsVersion = jsVersion; - if (this.version < supportedVersion) { - this.alert("Not Supported", "BetterDiscord v" + this.version + "(your version)" + " is not supported by the latest js(" + this.jsVersion + ").

Please download the latest version from BetterDiscord.net"); + + if (version < supportedVersion) { + this.alert("Not Supported", "BetterDiscord v" + version + "(your version)" + " is not supported by the latest js(" + jsVersion + ").

Please download the latest version from BetterDiscord.net"); return; } - this.utils = new Utils(); - utils = new Utils(); + var sock = new BdWSocket(); + sock.start(); utils.getHash(); emoteModule = new EmoteModule(); quickEmoteMenu = new QuickEmoteMenu(); @@ -327,6 +261,7 @@ Core.prototype.loadSettings = function () { settingsCookie = JSON.parse($.cookie("better-discord")); }; +var botlist = ["119598467310944259"]; //Temp Core.prototype.initObserver = function () { mainObserver = new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { @@ -456,8 +391,4 @@ Core.prototype.alert = function (title, text) { ' ' + ' ' + ''); -}; - -Core.prototype.getUtils = function() { - return this.utils; }; \ No newline at end of file diff --git a/dev/js/01emoteModule.js b/dev/js/01emoteModule.js deleted file mode 100644 index 1816e6b7..00000000 --- a/dev/js/01emoteModule.js +++ /dev/null @@ -1,274 +0,0 @@ -/* BetterDiscordApp EmoteModule JavaScript - * Version: 1.5 - * Author: Jiiks | http://jiiks.net - * Date: 26/08/2015 - 15:29 - * Last Update: 14/10/2015 - 09:48 - * https://github.com/Jiiks/BetterDiscordApp - * Note: Due to conflicts autocapitalize only supports global emotes - */ - -/* - * =Changelog= - * -v1.5 - * --Twitchemotes.com api - */ - -function EmoteModule() { - this.blacklist = []; - this.spoilered = []; - this.emotes = { - twitchGlobal: emotesTwitch, - twitchSub: subEmotesTwitch, - bttvGlobal: emotesBTTV, - bttvUser: emotesBTTV2, - ffz: emotesFfz - }; -} - -EmoteModule.prototype.init = function () { - this.config = { - twitch: { - url: { - start: "https://static-cdn.jtvnw.net/emoticons/v1/", - end: "/1.0" - } - }, - ffz: { - url: { - start: "https://cdn.frankerfacez.com/emoticon/", - end: "/1" - } - }, - bttv: { - url: { - start: "https://cdn.betterttv.net/emote/", - end: "/1x" - } - } - } -}; - -EmoteModule.prototype.getBlacklist = function () { - var self = this; - $.getJSON("https://cdn.rawgit.com/Jiiks/betterDiscordApp/" + _hash + "/data/emotefilter.json", function (data) { - self.blacklist = data.blacklist; - }); -}; - -EmoteModule.prototype.obsCallback = function (mutation) { - var self = this; - - if (!BD.settingsCookie["bda-es-7"]) return; - - $(".emoji").each(function () { - var t = $(this); - if (t.attr("src").indexOf(".png") != -1) { - - var next = t.next(); - var newText = t.attr("alt"); - if(next.size() > 0) { - if(next.prop("tagName") == "SPAN") { - newText += next.text(); - next.remove(); - } - } - - if(t.parent().prop("tagName") != "SPAN") { - t.replaceWith("" + newText + ""); - } else { - t.replaceWith(newText); - } - } - }); - - for (var i = 0; i < mutation.addedNodes.length; ++i) { - var next = mutation.addedNodes.item(i); - if (next) { - var nodes = self.getNodes(next); - for (var node in nodes) { - if (nodes.hasOwnProperty(node)) { - self.injectEmote(nodes[node]); - } - } - } - } -}; - -EmoteModule.prototype.getNodes = function (node) { - var next; - var nodes = []; - - var treeWalker = document.createTreeWalker(node, NodeFilter.SHOW_TEXT, null, false); - - while (next = treeWalker.nextNode()) { - nodes.push(next); - } - - return nodes; -}; - -EmoteModule.prototype.injectEmote = function (node) { - - var self = this; - - if (typeof emotesTwitch === 'undefined') return; - - if (!node.parentElement) return; - - var parent = node.parentElement; - - 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; - edited = true; - } - - function inject() { - var parentInnerHTML = parent.innerHTML; - var words = parentInnerHTML.split(/\s+/g); - - if (!words) return; - - words.some(function (word) { - if (word.slice(0, 4) == "[!s]") { - - parentInnerHTML = parentInnerHTML.replace("[!s]", ""); - var markup = $(parent).parent(); - var reactId = markup.attr("data-reactid"); - - if (self.spoilered.indexOf(reactId) > -1) { - return; - } - - markup.addClass("spoiler"); - markup.on("click", function () { - $(this).removeClass("spoiler"); - self.spoilered.push($(this).attr("data-reactid")); - }); - - return; - } - - if (word.length < 4) { - return; - } - - if (word == "ClauZ") { - parentInnerHTML = parentInnerHTML.replace("ClauZ", ''); - return; - } - - var useEmoteCss = false; - var sWord = word; - var emoteClass = ""; - var allowedClasses = ["emoteflip", "emotespin", "emotepulse", "emotespin2", "emotespin3", "emote1spin", "emote2spin", "emote3spin", "emotetr", "emotebl", "emotebr", "emoteshake", "emoteshake2", "emoteshake3", "emoteflap"]; - if(word.indexOf(":") > -1) { - var split = word.split(/:(?!.*:)/); - if (split[0] != "" && split[1] != "") { - userEmoteCss = true; - sWord = split[0]; - if(BD.settingsCookie["bda-es-8"]) { - emoteClass = "emote" + split[1]; - if(allowedClasses.indexOf(emoteClass) < 0) { - emoteClass = ""; - } - } - } - } - if ($.inArray(sWord, self.blacklist) != -1) return; - - var len = Math.round(sWord.length / 4); - var name = sWord.substr(0, len) + "\uFDD9" + sWord.substr(len, len) + "\uFDD9" + sWord.substr(len * 2, len) + "\uFDD9" + sWord.substr(len * 3); - var cfg = self.config; - if (self.emotes.twitchGlobal.emotes.hasOwnProperty(sWord)) { - var url = cfg.twitch.url.start + self.emotes.twitchGlobal.emotes[sWord].image_id + cfg.twitch.url.end; - parentInnerHTML = parentInnerHTML.replace(word, '
' + name + '
'); - return; - } - - if (self.emotes.twitchSub.hasOwnProperty(sWord)) { - var url = cfg.twitch.url.start + self.emotes.twitchSub[sWord] + cfg.twitch.url.end; - parentInnerHTML = parentInnerHTML.replace(word, '
' + name + '
'); - return; - } - - if (typeof self.emotes.bttvGlobal !== 'undefined' && BD.settingsCookie["bda-es-2"]) { - if (self.emotes.bttvGlobal.hasOwnProperty(sWord)) { - var url = self.emotes.bttvGlobal[sWord]; - parentInnerHTML = parentInnerHTML.replace(word, '
' + name + '
'); - return; - } - } - - if (typeof self.emotes.bttvUser !== 'undefined' && BD.settingsCookie["bda-es-2"]) { - if (self.emotes.bttvUser.hasOwnProperty(sWord)) { - var url = cfg.bttv.url.start + self.emotes.bttvUser[sWord] + cfg.bttv.url.end; - parentInnerHTML = parentInnerHTML.replace(word, '
' + name + '
'); - return; - } - } - - if (typeof self.emotes.ffz !== 'undefined' && BD.settingsCookie["bda-es-1"]) { - if (self.emotes.ffz.hasOwnProperty(sWord)) { - var url = cfg.ffz.url.start + self.emotes.ffz[sWord] + cfg.ffz.url.end; - parentInnerHTML = parentInnerHTML.replace(word, '
' + name + '
'); - 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 (!BD.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 = this.emotes.twitchGlobal.emotes; - for (var p in res) { - if (res.hasOwnProperty(p) && value == (p + '').toLowerCase()) { - return p; - } - } -}; \ No newline at end of file diff --git a/dev/js/02emoteModule.js b/dev/js/02emoteModule.js index 7a566065..f5724e33 100644 --- a/dev/js/02emoteModule.js +++ b/dev/js/02emoteModule.js @@ -26,28 +26,7 @@ var subEmotesTwitch = {}; function EmoteModule() {} -EmoteModule.prototype.init = function () { - this.config = { - twitch: { - url: { - start: "https://static-cdn.jtvnw.net/emoticons/v1/", - end: "/1.0" - } - }, - ffz: { - url: { - start: "https://cdn.frankerfacez.com/emoticon/", - end: "/1" - } - }, - bttv: { - url: { - start: "https://cdn.betterttv.net/emote/", - end: "/1x" - } - } - } -}; +EmoteModule.prototype.init = function () {}; EmoteModule.prototype.getBlacklist = function () { $.getJSON("https://cdn.rawgit.com/Jiiks/betterDiscordApp/" + _hash + "/data/emotefilter.json", function (data) { @@ -112,8 +91,6 @@ var spoilered = []; EmoteModule.prototype.injectEmote = function (node) { - var self = this; - if (typeof emotesTwitch === 'undefined') return; if (!node.parentElement) return; @@ -186,23 +163,36 @@ EmoteModule.prototype.injectEmote = function (node) { } if ($.inArray(sWord, bemotes) != -1) return; - var len = Math.round(sWord.length / 4); - var name = sWord.substr(0, len) + "\uFDD9" + sWord.substr(len, len) + "\uFDD9" + sWord.substr(len * 2, len) + "\uFDD9" + sWord.substr(len * 3); - var cfg = self.config; if (emotesTwitch.emotes.hasOwnProperty(sWord)) { - var url = cfg.twitch.url.start + emotesTwitch.emotes[sWord].image_id + cfg.twitch.url.end; + var len = Math.round(sWord.length / 4); + var name = sWord.substr(0, len) + "\uFDD9" + sWord.substr(len, len) + "\uFDD9" + sWord.substr(len * 2, len) + "\uFDD9" + sWord.substr(len * 3); + var url = twitchEmoteUrlStart + emotesTwitch.emotes[sWord].image_id + twitchEmoteUrlEnd; parentInnerHTML = parentInnerHTML.replace(word, '
' + name + '
'); return; } if (subEmotesTwitch.hasOwnProperty(sWord)) { - var url = cfg.twitch.url.start + subEmotesTwitch[sWord] + cfg.twitch.url.end; + var len = Math.round(sWord.length / 4); + var name = sWord.substr(0, len) + "\uFDD9" + sWord.substr(len, len) + "\uFDD9" + sWord.substr(len * 2, len) + "\uFDD9" + sWord.substr(len * 3); + var url = twitchEmoteUrlStart + subEmotesTwitch[sWord] + twitchEmoteUrlEnd; parentInnerHTML = parentInnerHTML.replace(word, '
' + name + '
'); return; } + if (typeof emotesFfz !== 'undefined' && settingsCookie["bda-es-1"]) { + if (emotesFfz.hasOwnProperty(sWord)) { + var len = Math.round(sWord.length / 4); + var name = sWord.substr(0, len) + "\uFDD9" + sWord.substr(len, len) + "\uFDD9" + sWord.substr(len * 2, len) + "\uFDD9" + sWord.substr(len * 3); + var url = ffzEmoteUrlStart + emotesFfz[sWord] + ffzEmoteUrlEnd; + parentInnerHTML = parentInnerHTML.replace(word, '
' + name + '
'); + return; + } + } + if (typeof emotesBTTV !== 'undefined' && settingsCookie["bda-es-2"]) { if (emotesBTTV.hasOwnProperty(sWord)) { + var len = Math.round(sWord.length / 4); + var name = sWord.substr(0, len) + "\uFDD9" + sWord.substr(len, len) + "\uFDD9" + sWord.substr(len * 2, len) + "\uFDD9" + sWord.substr(len * 3); var url = emotesBTTV[sWord]; parentInnerHTML = parentInnerHTML.replace(word, '
' + name + '
'); return; @@ -211,15 +201,9 @@ EmoteModule.prototype.injectEmote = function (node) { if (typeof emotesBTTV2 !== 'undefined' && settingsCookie["bda-es-2"]) { if (emotesBTTV2.hasOwnProperty(sWord)) { - var url = cfg.bttv.url.start + emotesBTTV2[sWord] + cfg.bttv.url.end; - parentInnerHTML = parentInnerHTML.replace(word, '
' + name + '
'); - return; - } - } - - if (typeof emotesFfz !== 'undefined' && settingsCookie["bda-es-1"]) { - if (emotesFfz.hasOwnProperty(sWord)) { - var url = cfg.ffz.url.start + emotesFfz[sWord] + cfg.ffz.url.end; + var len = Math.round(sWord.length / 4); + var name = sWord.substr(0, len) + "\uFDD9" + sWord.substr(len, len) + "\uFDD9" + sWord.substr(len * 2, len) + "\uFDD9" + sWord.substr(len * 3); + var url = bttvEmoteUrlStart + emotesBTTV2[sWord] + bttvEmoteUrlEnd; parentInnerHTML = parentInnerHTML.replace(word, '
' + name + '
'); return; } diff --git a/dev/js/03publicServers.js b/dev/js/03publicServers.js index 94d87cad..1eef4824 100644 --- a/dev/js/03publicServers.js +++ b/dev/js/03publicServers.js @@ -222,4 +222,4 @@ PublicServers.prototype.joinServer = function (code) { $(".action.join .btn").click(); $(".create-guild-container input").val(code); $(".form.join-server .btn-primary").click(); -}; +}; \ No newline at end of file diff --git a/dev/js/04quickEmoteMenu.js b/dev/js/04quickEmoteMenu.js index 23c562ae..88e4b1ab 100644 --- a/dev/js/04quickEmoteMenu.js +++ b/dev/js/04quickEmoteMenu.js @@ -15,7 +15,7 @@ QuickEmoteMenu.prototype.init = function() { $(document).on("mousedown", function(e) { if(e.target.id != "rmenu") $("#rmenu").remove(); }); - + this.favoriteEmotes = {}; var fe = localStorage["bdfavemotes"]; if (fe != undefined) { this.favoriteEmotes = JSON.parse(atob(fe)); diff --git a/dev/js/06settingsPanel.js b/dev/js/06settingsPanel.js index cdf73e27..49d62b8e 100644 --- a/dev/js/06settingsPanel.js +++ b/dev/js/06settingsPanel.js @@ -2,10 +2,13 @@ * Version: 2.0 * Author: Jiiks | http://jiiks.net * Date: 26/08/2015 - 11:54 - * Last Update: 10/04/2016 + * Last Update: 27/11/2015 - 00:50 * https://github.com/Jiiks/BetterDiscordApp */ +var settingsButton = null; +var panel = null; + function SettingsPanel() { utils.injectJs("https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.9.0/codemirror.min.js"); utils.injectJs("https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.9.0/mode/css/css.min.js"); @@ -14,7 +17,7 @@ function SettingsPanel() { SettingsPanel.prototype.init = function () { var self = this; - self.constructPanel(); + self.construct(); var body = $("body"); if (settingsCookie["bda-es-0"]) { @@ -45,7 +48,7 @@ SettingsPanel.prototype.init = function () { if (settingsCookie["bda-es-6"]) { //Pretty emote titles emoteNamePopup = $("
"); - $(document).off("mouseover.etitles").on("mouseover.etitles", ".emote", function () { + $(document).on("mouseover", ".emote", function () { var x = $(this).offset(); var title = $(this).attr("alt"); $(emoteNamePopup).find(".tipsy-inner").text(title); @@ -53,40 +56,110 @@ SettingsPanel.prototype.init = function () { $(emoteNamePopup).css('top', x.top - 32); $("div[data-reactid='.0.1.1']").append($(emoteNamePopup)); }); - $(document).off("mouseleave.etitles").on("mouseleave.etitles", ".emote", function () { + $(document).on("mouseleave", ".emote", function () { $(".tipsy").remove(); }); } else { - $(document).off("mouseover.etitles"); - $(document).off("mouseleave.etitles"); + $(document).off('mouseover', '.emote'); } }; -SettingsPanel.prototype.changeTab = function(tab) { - this.lastTab = tab; - tab = $(tab).prop("id"); +var customCssInitialized = false; +var lastTab = ""; + +SettingsPanel.prototype.changeTab = function (tab) { + + var self = this; + + lastTab = tab; + + var controlGroups = $("#bd-control-groups"); $(".bd-tab").removeClass("selected"); $(".bd-pane").hide(); $("#" + tab).addClass("selected"); $("#" + tab.replace("tab", "pane")).show(); - switch(tab) { + switch (tab) { + case "bd-settings-tab": + break; case "bd-customcss-tab": - if(!this.customCssInitialized) { + if (!customCssInitialized) { customCssEditor.init(); - this.customCssInitialized = true; + customCssInitialized = true; } - break; + break; } }; -SettingsPanel.prototype.updateSetting = function(checkbox) { - console.log("Working?"); +SettingsPanel.prototype.updateSetting = function (checkbox) { + var cb = $(checkbox).children().find('input[type="checkbox"]'); + var enabled = !cb.is(":checked"); + var id = cb.attr("id"); + cb.prop("checked", enabled); + + if(id == "bda-css-2") { + $("#app-mount").removeClass("bd-hide-bd"); + customCssEditor.hideBackdrop = enabled; + if(enabled) { + $("#app-mount").addClass("bd-hide-bd") + } + } + + settingsCookie[id] = enabled; + + if (settingsCookie["bda-es-0"]) { + $("#twitchcord-button-container").show(); + } else { + $("#twitchcord-button-container").hide(); + } + + if (settingsCookie["bda-gs-2"]) { + $("body").addClass("bd-minimal"); + } else { + $("body").removeClass("bd-minimal"); + } + if (settingsCookie["bda-gs-3"]) { + $("body").addClass("bd-minimal-chan"); + } else { + $("body").removeClass("bd-minimal-chan"); + } + if (settingsCookie["bda-gs-1"]) { + $("#bd-pub-li").show(); + } else { + $("#bd-pub-li").hide(); + } + if (settingsCookie["bda-gs-4"]) { + voiceMode.enable(); + } else { + voiceMode.disable(); + } + $("#app-mount").removeClass("bda-dark"); + if(settingsCookie["bda-gs-5"]) { + $("#app-mount").addClass("bda-dark"); + } + if (settingsCookie["bda-es-6"]) { + //Pretty emote titles + emoteNamePopup = $("
"); + $(document).on("mouseover", ".emote", function () { + 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(); }; -SettingsPanel.prototype.constructPanel = function() { +SettingsPanel.prototype.construct = function () { var self = this; - self.lastTab = ""; panel = $("
", { id: "bd-pane", @@ -96,138 +169,164 @@ SettingsPanel.prototype.constructPanel = function() { } }); - var panelHtml = '\ -
\ -
\ -
\ -
Core
\ -
Emotes
\ -
Custom CSS
\ -
Plugins
\ -
Themes
\ -
\ -
\ -
\ -
    \ - '; + var settingsInner = '' + + '
    ' + + '
    ' + + '
    ' + + '
    Core
    ' + + '
    Emotes
    ' + + '
    Custom CSS
    ' + + '
    Plugins
    ' + + '
    Themes
    ' + + '
    ' + + '
    ' + + ' \ - '; - //Emote settings - for(var setting in bdConfig.options) { - var sett = bdConfig.options[setting]; + + settingsInner += ''; + + var ccss = atob(localStorage.getItem("bdcustomcss")); customCssEditor.applyCustomCss(ccss, true, false); - panelHtml += '\ -
\ -
\ - \ - \ - \ -
\ -
\ -
BetterDiscord v'+BdApi.getCore().version+'(JSv'+BdApi.getCore().jsVersion+') by Jiiks BetterDiscord.net
\ -
\ - '; - panel.html(panelHtml); + if (typeof (themesupport2) === "undefined") { + settingsInner += '' + + ' Your version does not support themes. Download the latest version.'; + } else { + settingsInner += '' + + ' ' + + ' '; + $.each(bdthemes, function () { + settingsInner += '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ''; + }); + settingsInner += '
NameDescriptionAuthorVersion
' + this["name"].replace(/_/g, " ") + '' + this["author"] + '' + this["version"] + '' + + '
' + + '
' + + ' ' + + ' ' + + '
' + + '
' + + '
'; + } + + + settingsInner += '' + + '
' + + '' + + ' ' + + ' ' + + '
' + + ' BetterDiscord v' + version + '(JSv' + jsVersion + ') by Jiiks' + + ' BetterDiscord.net' + + '
' + + ''; function showSettings() { $(".tab-bar-item").removeClass("selected"); settingsButton.addClass("selected"); $(".form .settings-right .settings-inner").first().hide(); panel.show(); - if (self.lastTab == "") { - self.changeTab({id:"bd-settings-tab"}); + if (lastTab == "") { + self.changeTab("bd-settings-tab"); } else { - self.changeTab(self.lastTab); + self.changeTab(lastTab); } } @@ -238,34 +337,36 @@ SettingsPanel.prototype.constructPanel = function() { click: showSettings }); + panel.html(settingsInner); - (function defer() { - if($(".btn.btn-settings").length < 1) { + function defer() { + if ($(".btn.btn-settings").length < 1) { setTimeout(defer, 100); - return; - } + } else { + $(".btn.btn-settings").first().on("click", function () { - $(".btn.btn-settings").first().off("click.bda").on("click.bda", function() { - (function defer() { - if(!$(".modal-inner").first().is(":visible")) { - setTimeout(defer, 100); - return; + function innerDefer() { + if ($(".modal-inner").first().is(":visible")) { + + panel.hide(); + var tabBar = $(".tab-bar.SIDE").first(); + + $(".tab-bar.SIDE .tab-bar-item").click(function () { + $(".form .settings-right .settings-inner").first().show(); + $("#bd-settings-new").removeClass("selected"); + panel.hide(); + }); + + tabBar.append(settingsButton); + $(".form .settings-right .settings-inner").last().after(panel); + $("#bd-settings-new").removeClass("selected"); + } else { + setTimeout(innerDefer, 100); + } } - - panel.hide(); - var tabBar = $(".tab-bar.SIDE").first(); - - $(".tab-bar.SIDE .tab-bar-item").click(function () { - $(".form .settings-right .settings-inner").first().show(); - $("#bd-settings-new").removeClass("selected"); - panel.hide(); - }); - - tabBar.append(settingsButton); - $(".form .settings-right .settings-inner").last().after(panel); - $("#bd-settings-new").removeClass("selected"); - - })(); - }); - })(); + innerDefer(); + }); + } + } + defer(); }; \ No newline at end of file diff --git a/dev/js/07utils.js b/dev/js/07utils.js index fd05e58d..2a40688f 100644 --- a/dev/js/07utils.js +++ b/dev/js/07utils.js @@ -64,17 +64,4 @@ Utils.prototype.log = function (message) { Utils.prototype.err = function (message) { console.info("%c[BetterDiscord]%c " + message, "color:red; font-weight:bold;", ""); -}; - -//Html generation utils -Utils.prototype.getDiscordCheckbox = function(data) { - return '\ -
\ -
\ - \ - \ -
\ - '+data.text+'\ -
\ - '; }; \ No newline at end of file diff --git a/dev/js/10themeModule.js b/dev/js/10themeModule.js index a7c16293..12f33a5f 100644 --- a/dev/js/10themeModule.js +++ b/dev/js/10themeModule.js @@ -61,4 +61,4 @@ ThemeModule.prototype.saveThemeData = function () { expires: 365, path: '/' }); -}; \ No newline at end of file +};