From fc7a85a79cff549b70c4346400efac4f3cc1a4c4 Mon Sep 17 00:00:00 2001 From: Alexei Stukov Date: Tue, 2 May 2017 18:15:35 +0300 Subject: [PATCH] minify --- js/main.min.js | 5151 ++++-------------------------------------------- 1 file changed, 367 insertions(+), 4784 deletions(-) diff --git a/js/main.min.js b/js/main.min.js index 6f35a42..8715ee0 100644 --- a/js/main.min.js +++ b/js/main.min.js @@ -1,494 +1,24 @@ - -/* BetterDiscordApp Core JavaScript - * Version: 1.78 - * Author: Jiiks | http://jiiks.net - * Date: 27/08/2015 - 16:36 - * Last Update: 01/05/2016 - * https://github.com/Jiiks/BetterDiscordApp - */ - -/*Localstorage fix*/ -(function() { - - let __fs = window.require("fs"); - let __process = window.require("process"); - let __platform = __process.platform; - let __dataPath = (__platform === 'win32' ? __process.env.APPDATA : __platform === 'darwin' ? __process.env.HOME + '/Library/Preferences' : process.env.HOME + '/.config') + '/BetterDiscord/'; - - - let __data = {}; - if(__fs.existsSync(`${__dataPath}localStorage.json`)) { - try { - __data = JSON.parse(__fs.readFileSync(`${__dataPath}localStorage.json`)) - }catch(err) { - console.log(err); - } - } else if(__fs.existsSync("localStorage.json")) { - try { - __data = JSON.parse(__fs.readFileSync("localStorage.json")); - }catch(err) { - console.log(err); - } - } - - var __ls = __data; - __ls.setItem = function(i, v) { - __ls[i] = v; - this.save(); - }; - __ls.getItem = function(i) { - return __ls[i] || null; - }; - __ls.save = function() { - __fs.writeFileSync(`${__dataPath}/localStorage.json`, JSON.stringify(this), null, 4); - }; - - var __proxy = new Proxy(__ls, { - set: function(target, name, val, receiver) { - __ls[name] = val; - __ls.save(); - }, - get: function(target, name, receiver) { - return __ls[name] || null; - } - }); - - window.localStorage = __proxy; - -})(); - -(() => { - let v2Loader = document.createElement('div'); - v2Loader.className = "bd-loaderv2"; - v2Loader.title = "BetterDiscord is loading..."; - document.body.appendChild(v2Loader); -})(); - -window.bdStorage = {}; -window.bdStorage.get = function(i) { - return betterDiscordIPC.sendSync('synchronous-message', { 'arg': 'storage', 'cmd': 'get', 'var': i }); -}; -window.bdStorage.set = function(i, v) { - betterDiscordIPC.sendSync('synchronous-message', { 'arg': 'storage', 'cmd': 'set', 'var': i, 'data': v }); -}; -window.bdPluginStorage = {}; -window.bdPluginStorage.get = function(pn, i) { - return betterDiscordIPC.sendSync('synchronous-message', { 'arg': 'pluginstorage', 'cmd': 'get', 'pn': pn, 'var': i }); -}; -window.bdPluginStorage.set = function(pn, i, v) { - betterDiscordIPC.sendSync('synchronous-message', { 'arg': 'pluginstorage', 'cmd': 'set', 'pn': pn, 'var': i, 'data': v }); -}; - -betterDiscordIPC.on('asynchronous-reply', (event, arg) => { - console.log(event); - console.log(arg); -}); - -var settingsPanel, emoteModule, utils, quickEmoteMenu, opublicServers, voiceMode, pluginModule, themeModule, customCssEditor, dMode; -var jsVersion = 1.79; -var supportedVersion = "0.2.81"; - -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"}, - "24 Hour Timestamps": { "id": "bda-gs-6", "info": "Replace 12hr timestamps with proper ones", "implemented": true, "hidden": false, "cat": "core"}, - "Coloured Text": { "id": "bda-gs-7", "info": "Make text colour the same as role colour", "implemented": true, "hidden": false, "cat": "core"}, - "BetterDiscord Blue": { "id": "bda-gs-b", "info": "Replace Discord blue with BD Blue", "implemented": true, "hidden": false, "cat": "core"}, - "Developer Mode": { "id": "bda-gs-8", "info": "Developer Mode", "implemented": true, "hidden": false, "cat": "core"}, - - "Twitch Emotes": { "id": "bda-es-7", "info": "Show Twitch 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": "thtp://jiiks.net", "target": "_blank" }, - "twitter": { "text": "Twitter", "href": "http://twitter.com/jiiksi", "target": "_blank" }, - "github": { "text": "Github", "href": "http://github.com/jiiks", "target": "_blank" } -}; - -var defaultCookie = { - "version": jsVersion, - "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-gs-6": false, - "bda-gs-7": false, - "bda-gs-8": false, - "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-gs-b": 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 -}; - -var bdchangelog = { - "changes": { - "0a": { - "title": "1.78 : Temp support for new settingspanel", - "text": "Added temp support for Discord's new settingspanel until v2.", - "img": "" - }, - "0b": { - "title": "1.78 : Public Servers", - "text": "New look and flow for public servers", - "img": "" - }, - "0c": { - "title": "1.78 : New loading icon", - "text": "New loading icon will now display in bottom right when BD is loading.", - "img": "" - }, - "0d": { - "title": "1.78 : New CustomCSS editor look", - "text": "Updated CustomCSS editor with dark theme", - "img": "" - }, - "0e": { - "title": "1.78 : BetterDiscord Blue", - "text": "Replace Discord blue with BetterDiscord blue!", - "img": "" - } - }, - "fixes": { - "0a": { - "title": "1.79 : Settings Saving", - "text": "Fixed settings not saving with new settings panel", - "img": "" - } - } -}; - -var settingsCookie = {}; - -function Core() {} - -Core.prototype.init = function () { - var self = this; - - var lVersion = (typeof(version) === "undefined") ? bdVersion : version; - - if (lVersion < supportedVersion) { - this.alert("Not Supported", "BetterDiscord v" + lVersion + "(your version)" + " is not supported by the latest js(" + jsVersion + ").

Please download the latest version from BetterDiscord.net"); - return; - } - - utils = new Utils(); - var sock = new BdWSocket(); - sock.start(); - utils.getHash(); - emoteModule = new EmoteModule(); - quickEmoteMenu = new QuickEmoteMenu(); - voiceMode = new VoiceMode(); - dMode = new devMode(); - - emoteModule.init(); - - this.initSettings(); - this.initObserver(); - - //Incase were too fast - function gwDefer() { - console.log(new Date().getTime() + " Defer"); - if ($(".guilds-wrapper .guilds").children().length > 0) { - console.log(new Date().getTime() + " Defer Loaded"); - var guilds = $(".guilds>li:first-child"); - - var showChannelsButton = $("' + - ' ' + - '
' + - '
'; - - if (bdchangelog.changes != null) { - changeLog += '' + - '

' + - ' New Stuff' + - '

' + - '
    '; - - for (var change in bdchangelog.changes) { - change = bdchangelog.changes[change]; - - changeLog += '' + - '
  • ' + - ' ' + change.title + '' + - '
    ' + change.text + '
    ' + - '
  • '; - } - - changeLog += '
'; - } - - if (bdchangelog.fixes != null) { - changeLog += '' + - '

' + - ' Fixed' + - '

' + - '
    '; - - for (var fix in bdchangelog.fixes) { - fix = bdchangelog.fixes[fix]; - - changeLog += '' + - '
  • ' + - ' ' + fix.title + '' + - '
    ' + fix.text + '
    ' + - '
  • '; - } - - changeLog += '
'; - } - - if (bdchangelog.upcoming != null) { - changeLog += '' + - '

' + - ' Coming Soon' + - '

' + - '
    '; - - for (var upc in bdchangelog.upcoming) { - upc = bdchangelog.upcoming[upc]; - - changeLog += '' + - '
  • ' + - ' ' + upc.title + '' + - '
    ' + upc.text + '
    ' + - '
  • '; - } - - changeLog += '
'; - } - - changeLog += '' + - '
' + - '
' + - ' ' + - ' ' + - ' ' + - ''; - - return changeLog; -}; - -Core.prototype.alert = function (title, text) { - var id = ''; - for( var i=0; i < 5; i++ ) - id += "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(Math.random() * "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".length)); - var bdAlert = '\ +(function(){let __fs=window.require("fs");let __process=window.require("process");let __platform=__process.platform;let __dataPath=(__platform==='win32'?__process.env.APPDATA:__platform==='darwin'?__process.env.HOME+'/Library/Preferences':process.env.HOME+'/.config')+'/BetterDiscord/';let __data={};if(__fs.existsSync(`${__dataPath}localStorage.json`)){try{__data=JSON.parse(__fs.readFileSync(`${__dataPath}localStorage.json`))}catch(err){console.log(err)}}else if(__fs.existsSync("localStorage.json")){try{__data=JSON.parse(__fs.readFileSync("localStorage.json"))}catch(err){console.log(err)}} +var __ls=__data;__ls.setItem=function(i,v){__ls[i]=v;this.save()};__ls.getItem=function(i){return __ls[i]||null};__ls.save=function(){__fs.writeFileSync(`${__dataPath}/localStorage.json`,JSON.stringify(this),null,4)};var __proxy=new Proxy(__ls,{set:function(target,name,val,receiver){__ls[name]=val;__ls.save()},get:function(target,name,receiver){return __ls[name]||null}});window.localStorage=__proxy})();(()=>{let v2Loader=document.createElement('div');v2Loader.className="bd-loaderv2";v2Loader.title="BetterDiscord is loading...";document.body.appendChild(v2Loader)})();window.bdStorage={};window.bdStorage.get=function(i){return betterDiscordIPC.sendSync('synchronous-message',{'arg':'storage','cmd':'get','var':i})};window.bdStorage.set=function(i,v){betterDiscordIPC.sendSync('synchronous-message',{'arg':'storage','cmd':'set','var':i,'data':v})};window.bdPluginStorage={};window.bdPluginStorage.get=function(pn,i){return betterDiscordIPC.sendSync('synchronous-message',{'arg':'pluginstorage','cmd':'get','pn':pn,'var':i})};window.bdPluginStorage.set=function(pn,i,v){betterDiscordIPC.sendSync('synchronous-message',{'arg':'pluginstorage','cmd':'set','pn':pn,'var':i,'data':v})};betterDiscordIPC.on('asynchronous-reply',(event,arg)=>{console.log(event);console.log(arg)});var settingsPanel,emoteModule,utils,quickEmoteMenu,opublicServers,voiceMode,pluginModule,themeModule,customCssEditor,dMode;var jsVersion=1.79;var supportedVersion="0.2.81";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":!1,"hidden":!1,"cat":"core"},"Public Servers":{"id":"bda-gs-1","info":"Display public servers button","implemented":!0,"hidden":!1,"cat":"core"},"Minimal Mode":{"id":"bda-gs-2","info":"Hide elements and reduce the size of elements.","implemented":!0,"hidden":!1,"cat":"core"},"Voice Mode":{"id":"bda-gs-4","info":"Only show voice chat","implemented":!0,"hidden":!1,"cat":"core"},"Hide Channels":{"id":"bda-gs-3","info":"Hide channels in minimal mode","implemented":!0,"hidden":!1,"cat":"core"},"Dark Mode":{"id":"bda-gs-5","info":"Make certain elements dark by default(wip)","implemented":!0,"hidden":!1,"cat":"core"},"Override Default Emotes":{"id":"bda-es-5","info":"Override default emotes","implemented":!1,"hidden":!1,"cat":"core"},"Voice Disconnect":{"id":"bda-dc-0","info":"Disconnect from voice server when closing Discord","implemented":!0,"hidden":!1,"cat":"core"},"Custom css live update":{"id":"bda-css-0","info":"","implemented":!0,"hidden":!0,"cat":"core"},"Custom css auto udpate":{"id":"bda-css-1","info":"","implemented":!0,"hidden":!0,"cat":"core"},"24 Hour Timestamps":{"id":"bda-gs-6","info":"Replace 12hr timestamps with proper ones","implemented":!0,"hidden":!1,"cat":"core"},"Coloured Text":{"id":"bda-gs-7","info":"Make text colour the same as role colour","implemented":!0,"hidden":!1,"cat":"core"},"BetterDiscord Blue":{"id":"bda-gs-b","info":"Replace Discord blue with BD Blue","implemented":!0,"hidden":!1,"cat":"core"},"Developer Mode":{"id":"bda-gs-8","info":"Developer Mode","implemented":!0,"hidden":!1,"cat":"core"},"Twitch Emotes":{"id":"bda-es-7","info":"Show Twitch emotes","implemented":!0,"hidden":!1,"cat":"emote"},"FrankerFaceZ Emotes":{"id":"bda-es-1","info":"Show FrankerFaceZ Emotes","implemented":!0,"hidden":!1,"cat":"emote"},"BetterTTV Emotes":{"id":"bda-es-2","info":"Show BetterTTV Emotes","implemented":!0,"hidden":!1,"cat":"emote"},"Emote Menu":{"id":"bda-es-0","info":"Show Twitch/Favourite emotes in emote menu","implemented":!0,"hidden":!1,"cat":"emote"},"Emoji Menu":{"id":"bda-es-9","info":"Show Discord emoji menu","implemented":!0,"hidden":!1,"cat":"emote"},"Emote Autocomplete":{"id":"bda-es-3","info":"Autocomplete emote commands","implemented":!1,"hidden":!1,"cat":"emote"},"Emote Auto Capitalization":{"id":"bda-es-4","info":"Autocapitalize emote commands","implemented":!0,"hidden":!1,"cat":"emote"},"Show Names":{"id":"bda-es-6","info":"Show emote names on hover","implemented":!0,"hidden":!1,"cat":"emote"},"Show emote modifiers":{"id":"bda-es-8","info":"Enable emote mods","implemented":!0,"hidden":!1,"cat":"emote"},};var links={"Jiiks.net":{"text":"Jiiks.net","href":"thtp://jiiks.net","target":"_blank"},"twitter":{"text":"Twitter","href":"http://twitter.com/jiiksi","target":"_blank"},"github":{"text":"Github","href":"http://github.com/jiiks","target":"_blank"}};var defaultCookie={"version":jsVersion,"bda-gs-0":!1,"bda-gs-1":!0,"bda-gs-2":!1,"bda-gs-3":!1,"bda-gs-4":!1,"bda-gs-5":!0,"bda-gs-6":!1,"bda-gs-7":!1,"bda-gs-8":!1,"bda-es-0":!0,"bda-es-1":!0,"bda-es-2":!0,"bda-es-3":!1,"bda-es-4":!1,"bda-es-5":!0,"bda-es-6":!0,"bda-es-7":!0,"bda-gs-b":!0,"bda-es-8":!0,"bda-jd":!0,"bda-es-8":!0,"bda-dc-0":!1,"bda-css-0":!1,"bda-css-1":!1,"bda-es-9":!0};var bdchangelog={"changes":{"0a":{"title":"1.78 : Temp support for new settingspanel","text":"Added temp support for Discord's new settingspanel until v2.","img":""},"0b":{"title":"1.78 : Public Servers","text":"New look and flow for public servers","img":""},"0c":{"title":"1.78 : New loading icon","text":"New loading icon will now display in bottom right when BD is loading.","img":""},"0d":{"title":"1.78 : New CustomCSS editor look","text":"Updated CustomCSS editor with dark theme","img":""},"0e":{"title":"1.78 : BetterDiscord Blue","text":"Replace Discord blue with BetterDiscord blue!","img":""}},"fixes":{"0a":{"title":"1.79 : Settings Saving","text":"Fixed settings not saving with new settings panel","img":""}}};var settingsCookie={};function Core(){} +Core.prototype.init=function(){var self=this;var lVersion=(typeof(version)==="undefined")?bdVersion:version;if(lVersion
Please download the latest version from BetterDiscord.net");return} +utils=new Utils();var sock=new BdWSocket();sock.start();utils.getHash();emoteModule=new EmoteModule();quickEmoteMenu=new QuickEmoteMenu();voiceMode=new VoiceMode();dMode=new devMode();emoteModule.init();this.initSettings();this.initObserver();function gwDefer(){console.log(new Date().getTime()+" Defer");if($(".guilds-wrapper .guilds").children().length>0){console.log(new Date().getTime()+" Defer Loaded");var guilds=$(".guilds>li:first-child");var showChannelsButton=$("'+' '+'
'+'
';if(bdchangelog.changes!=null){changeLog+=''+'

'+' New Stuff'+'

'+'
    ';for(var change in bdchangelog.changes){change=bdchangelog.changes[change];changeLog+=''+'
  • '+' '+change.title+''+'
    '+change.text+'
    '+'
  • '} +changeLog+='
'} +if(bdchangelog.fixes!=null){changeLog+=''+'

'+' Fixed'+'

'+'
    ';for(var fix in bdchangelog.fixes){fix=bdchangelog.fixes[fix];changeLog+=''+'
  • '+' '+fix.title+''+'
    '+fix.text+'
    '+'
  • '} +changeLog+='
'} +if(bdchangelog.upcoming!=null){changeLog+=''+'

'+' Coming Soon'+'

'+'
    ';for(var upc in bdchangelog.upcoming){upc=bdchangelog.upcoming[upc];changeLog+=''+'
  • '+' '+upc.title+''+'
    '+upc.text+'
    '+'
  • '} +changeLog+='
'} +changeLog+=''+'
'+'
'+' '+' '+' '+'';return changeLog};Core.prototype.alert=function(title,text){var id='';for(var i=0;i<5;i++) +id+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(Math.random()*"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".length));var bdAlert='\ \ - '; - $("body").append(bdAlert); - utils.addBackdrop(id); -}; -/* 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 - */ - -var emotesFfz = {}; -var emotesBTTV = {}; -var emotesTwitch = { - "emotes": { - "emote": { - "image_id": 0 - } - } -}; //for ide -var subEmotesTwitch = {}; - -function EmoteModule() {} - -EmoteModule.prototype.init = function () {}; - -EmoteModule.prototype.getBlacklist = function () { - $.getJSON("https://cdn.rawgit.com/Jiiks/betterDiscordApp/" + _hash + "/data/emotefilter.json", function (data) { - bemotes = data.blacklist; - }); -}; - -EmoteModule.prototype.obsCallback = function (mutation) { - var self = this; - - //if (!settingsCookie["bda-es-7"]) return; - - /*$(".emoji").each(function() { - var t = $(this); - if(t.attr("src").indexOf(".png") != -1) { - t.replaceWith(t.attr("alt")); - } - });*/ - - /*$(".emoji:not(.emote)").each(function() { - var t = $(this); - t.addClass("emote"); - t.wrap(''); - t.parent().append($("", { class: "fav", title: "Favorite!", type: "button" })); - });*/ - - - - 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)) { - var elem = nodes[node].parentElement; - if (elem && elem.classList.contains('edited')) { - self.injectEmote(elem); - } else { - 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; -}; - -var bemotes = []; -var spoilered = []; - - -EmoteModule.prototype.injectEmote = function(node) { - var self = this; - - if (!node.parentElement) return; - var parent = $(node).parent(); - - if(!parent.hasClass("markup") && !parent.hasClass("message-content")) return; - - - function inject() { - var contents = parent.contents(); - - contents.each(function(i) { - if(contents[i] == undefined) return; - var nodeValue = contents[i].nodeValue; - if(nodeValue == null) return; - //if(nodeValue.indexOf("react-") > -1) return; - - if(contents[i].nodeType == 8) return; - contents.splice(i, 1); - - var words = nodeValue.split(/([^\s]+)([\s]|$)/g).filter(function(e){ return e}); - - var splice = 0; - - var doInject = false; - var text = null; - - words.forEach(function(w, index, a) { - - if(w.indexOf("[!s]") > -1) { - w = w.replace("[!s]", ""); - parent.data("spoilered", false); - parent.addClass("spoiler"); - } - - var allowedClasses = ["flip", "spin", "pulse", "spin2", "spin3", "1spin", "2spin", "3spin", "tr", "bl", "br", "shake", "shake2", "shake3", "flap"]; - var useEmoteClass = false; - var emoteClass = ""; - var skipffz = false; - - var sw = w; - - if(w.indexOf(":") > -1) { - var split = w.split(":"); - if(split[0] != "" && split[1] != "") { - if(allowedClasses.indexOf(split[1]) > -1) { - sw = split[0]; - emoteClass = settingsCookie["bda-es-8"] ? "emote" + split[1] : ""; - } - if(split[1] == "bttv") { - sw = split[0]; - skipffz = true; - } - } - } - - if ($.inArray(sw, bemotes) == -1) { - - if(typeof emotesTwitch !== 'undefind' && settingsCookie["bda-es-7"]) { - if(emotesTwitch.emotes.hasOwnProperty(sw) && sw.length >= 4) { - if(text != null) { contents.splice(i + splice++, 0, document.createTextNode(text)); text = null;} - var url = twitchEmoteUrlStart + emotesTwitch.emotes[sw].image_id + twitchEmoteUrlEnd; - contents.splice(i + splice++, 0, self.createEmoteElement(sw, url, emoteClass)); - doInject = true; - return; - } - } - - if(typeof subEmotesTwitch !== 'undefined' && settingsCookie["bda-es-7"]) { - if(subEmotesTwitch.hasOwnProperty(sw) && sw.length >= 4) { - if(text != null) { contents.splice(i + splice++, 0, document.createTextNode(text)); text = null;} - var url = twitchEmoteUrlStart + subEmotesTwitch[sw] + twitchEmoteUrlEnd; - contents.splice(i + splice++, 0, self.createEmoteElement(sw, url, emoteClass)); - doInject = true; - return; - } - } - - if (typeof emotesBTTV !== 'undefined' && settingsCookie["bda-es-2"]) { - if(emotesBTTV.hasOwnProperty(sw) && sw.length >= 4) { - if(text != null) { contents.splice(i + splice++, 0, document.createTextNode(text)); text = null;} - var url = emotesBTTV[sw]; - contents.splice(i + splice++, 0, self.createEmoteElement(sw, url, emoteClass)); - doInject = true; - return; - } - } - - if ((typeof emotesFfz !== 'undefined' && settingsCookie["bda-es-1"]) && (!skipffz || !emotesBTTV2.hasOwnProperty(sw))) { - if(emotesFfz.hasOwnProperty(sw) && sw.length >= 4) { - if(text != null) { contents.splice(i + splice++, 0, document.createTextNode(text)); text = null;} - var url = ffzEmoteUrlStart + emotesFfz[sw] + ffzEmoteUrlEnd; - contents.splice(i + splice++, 0, self.createEmoteElement(sw, url, emoteClass)); - doInject = true; - return; - } - } - - if (typeof emotesBTTV2 !== 'undefined' && settingsCookie["bda-es-2"]) { - if(emotesBTTV2.hasOwnProperty(sw) && sw.length >= 4) { - if(text != null) { contents.splice(i + splice++, 0, document.createTextNode(text)); text = null;} - var url = bttvEmoteUrlStart + emotesBTTV2[sw] + bttvEmoteUrlEnd; - if(skipffz && emotesFfz.hasOwnProperty(sw)) sw = sw + ":bttv"; - contents.splice(i + splice++, 0, self.createEmoteElement(sw, url, emoteClass)); - doInject = true; - return; - } - } - } - - if(text == null) { - text = w; - } else { - text += "" + w; - } - - if(index === a.length - 1) { - contents.splice(i + splice, 0, document.createTextNode(text)); - } - }); - - if(doInject) { - var oldHeight = parent.outerHeight(); - parent.html(contents); - var scrollPane = $(".scroller.messages").first(); - scrollPane.scrollTop(scrollPane.scrollTop() + (parent.outerHeight() - oldHeight)); - } - - }); - } - - inject(); - if(parent.children().hasClass("edited")) { - setTimeout(inject, 250); - } - - - -}; - -EmoteModule.prototype.createEmoteElement = function(word, url, mod) { - var len = Math.round(word.length / 4); - var name = word.substr(0, len) + "\uFDD9" + word.substr(len, len) + "\uFDD9" + word.substr(len * 2, len) + "\uFDD9" + word.substr(len * 3); - var html = '' + name + ''; - return $.parseHTML(html.replace(new RegExp("\uFDD9", "g"), ""))[0]; -}; - -EmoteModule.prototype.autoCapitalize = function () { - - var self = this; - - $('body').delegate($(".channel-textarea-inner textarea:first"), 'keyup change paste', function () { - if (!settingsCookie["bda-es-4"]) return; - - var text = $(".channel-textarea-inner textarea:first").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:first").val(text.replace(lastWord, ret)); - } - } - }); -}; - -EmoteModule.prototype.capitalize = function (value) { - var res = emotesTwitch.emotes; - for (var p in res) { - if (res.hasOwnProperty(p) && value == (p + '').toLowerCase()) { - return p; - } - } -}; -/* BetterDiscordApp PublicSevers JavaScripts - * Version: 1.0 - * Author: Jiiks | http://jiiks.net - * Date: 27/08/2015 - 14:16 - * https://github.com/Jiiks/BetterDiscordApp - */ - -class PublicServers { - - constructor() { - this.v2p = new V2_PublicServers(); - } - - get endPoint() { - return 'https://search.discordservers.com'; - } - - get button() { - let self = this; - let btn = $("
", { - class: 'guild', - id: 'bd-pub-li', - css: { - 'height': '20px', - 'display': settingsCookie['bda-gs-1'] ? "" : "none" - } - }).append($("
", { - class: 'guild-inner', - css: { - 'height': '20px', - 'border-radius': '4px' - } - }).append($("", { - - }).append($("
", { - text: 'public', - id: 'bd-pub-button', - css: { - 'line-height': '20px', - 'font-size': '12px' - }, - click: () => { self.v2p.render(); } - })))); - - return btn; - } - - init() { - let self = this; - - let guilds = $(".guilds>:first-child"); - guilds.after(self.button); - - } - - get layer() { - let self = this; - let layer = `
+ ';$("body").append(bdAlert);utils.addBackdrop(id)};var emotesFfz={};var emotesBTTV={};var emotesTwitch={"emotes":{"emote":{"image_id":0}}};var subEmotesTwitch={};function EmoteModule(){} +EmoteModule.prototype.init=function(){};EmoteModule.prototype.getBlacklist=function(){$.getJSON("https://cdn.rawgit.com/Jiiks/betterDiscordApp/"+_hash+"/data/emotefilter.json",function(data){bemotes=data.blacklist})};EmoteModule.prototype.obsCallback=function(mutation){var self=this;for(var i=0;i-1){w=w.replace("[!s]","");parent.data("spoilered",!1);parent.addClass("spoiler")} +var allowedClasses=["flip","spin","pulse","spin2","spin3","1spin","2spin","3spin","tr","bl","br","shake","shake2","shake3","flap"];var useEmoteClass=!1;var emoteClass="";var skipffz=!1;var sw=w;if(w.indexOf(":")>-1){var split=w.split(":");if(split[0]!=""&&split[1]!=""){if(allowedClasses.indexOf(split[1])>-1){sw=split[0];emoteClass=settingsCookie["bda-es-8"]?"emote"+split[1]:""} +if(split[1]=="bttv"){sw=split[0];skipffz=!0}}} +if($.inArray(sw,bemotes)==-1){if(typeof emotesTwitch!=='undefind'&&settingsCookie["bda-es-7"]){if(emotesTwitch.emotes.hasOwnProperty(sw)&&sw.length>=4){if(text!=null){contents.splice(i+splice++,0,document.createTextNode(text));text=null} +var url=twitchEmoteUrlStart+emotesTwitch.emotes[sw].image_id+twitchEmoteUrlEnd;contents.splice(i+splice++,0,self.createEmoteElement(sw,url,emoteClass));doInject=!0;return}} +if(typeof subEmotesTwitch!=='undefined'&&settingsCookie["bda-es-7"]){if(subEmotesTwitch.hasOwnProperty(sw)&&sw.length>=4){if(text!=null){contents.splice(i+splice++,0,document.createTextNode(text));text=null} +var url=twitchEmoteUrlStart+subEmotesTwitch[sw]+twitchEmoteUrlEnd;contents.splice(i+splice++,0,self.createEmoteElement(sw,url,emoteClass));doInject=!0;return}} +if(typeof emotesBTTV!=='undefined'&&settingsCookie["bda-es-2"]){if(emotesBTTV.hasOwnProperty(sw)&&sw.length>=4){if(text!=null){contents.splice(i+splice++,0,document.createTextNode(text));text=null} +var url=emotesBTTV[sw];contents.splice(i+splice++,0,self.createEmoteElement(sw,url,emoteClass));doInject=!0;return}} +if((typeof emotesFfz!=='undefined'&&settingsCookie["bda-es-1"])&&(!skipffz||!emotesBTTV2.hasOwnProperty(sw))){if(emotesFfz.hasOwnProperty(sw)&&sw.length>=4){if(text!=null){contents.splice(i+splice++,0,document.createTextNode(text));text=null} +var url=ffzEmoteUrlStart+emotesFfz[sw]+ffzEmoteUrlEnd;contents.splice(i+splice++,0,self.createEmoteElement(sw,url,emoteClass));doInject=!0;return}} +if(typeof emotesBTTV2!=='undefined'&&settingsCookie["bda-es-2"]){if(emotesBTTV2.hasOwnProperty(sw)&&sw.length>=4){if(text!=null){contents.splice(i+splice++,0,document.createTextNode(text));text=null} +var url=bttvEmoteUrlStart+emotesBTTV2[sw]+bttvEmoteUrlEnd;if(skipffz&&emotesFfz.hasOwnProperty(sw))sw=sw+":bttv";contents.splice(i+splice++,0,self.createEmoteElement(sw,url,emoteClass));doInject=!0;return}}} +if(text==null){text=w}else{text+=""+w} +if(index===a.length-1){contents.splice(i+splice,0,document.createTextNode(text))}});if(doInject){var oldHeight=parent.outerHeight();parent.html(contents);var scrollPane=$(".scroller.messages").first();scrollPane.scrollTop(scrollPane.scrollTop()+(parent.outerHeight()-oldHeight))}})} +inject();if(parent.children().hasClass("edited")){setTimeout(inject,250)}};EmoteModule.prototype.createEmoteElement=function(word,url,mod){var len=Math.round(word.length/4);var name=word.substr(0,len)+"\uFDD9"+word.substr(len,len)+"\uFDD9"+word.substr(len*2,len)+"\uFDD9"+word.substr(len*3);var html=''+name+'';return $.parseHTML(html.replace(new RegExp("\uFDD9","g"),""))[0]};EmoteModule.prototype.autoCapitalize=function(){var self=this;$('body').delegate($(".channel-textarea-inner textarea:first"),'keyup change paste',function(){if(!settingsCookie["bda-es-4"])return;var text=$(".channel-textarea-inner textarea:first").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:first").val(text.replace(lastWord,ret))}}})};EmoteModule.prototype.capitalize=function(value){var res=emotesTwitch.emotes;for(var p in res){if(res.hasOwnProperty(p)&&value==(p+'').toLowerCase()){return p}}};class PublicServers{constructor(){this.v2p=new V2_PublicServers()} +get endPoint(){return 'https://search.discordservers.com'} +get button(){let self=this;let btn=$("
",{class:'guild',id:'bd-pub-li',css:{'height':'20px','display':settingsCookie['bda-gs-1']?"":"none"}}).append($("
",{class:'guild-inner',css:{'height':'20px','border-radius':'4px'}}).append($("",{}).append($("
",{text:'public',id:'bd-pub-button',css:{'line-height':'20px','font-size':'12px'},click:()=>{self.v2p.render()}}))));return btn} +init(){let self=this;let guilds=$(".guilds>:first-child");guilds.after(self.button)} +get layer(){let self=this;let layer=`
-
`; - - layer = $(layer); - - layer.on("blur", e => { - if(e.relatedTarget.id === 'bd-pubs-search') return; - layer.focus(); - console.log("blur:"); - console.log(e); - }); - - layer.on("keydown", e => { - if(e.which === 13 && e.target.id === 'bd-pubs-search') { - let category = $("#bd-pubs-layer .ui-tab-bar-item.selected").text(); - if(category === 'All') category = ''; - self.search(self.query({'term': e.target.value, 'category': category}), true); - return; - } - if(e.which !== 27) return; - self.hide(); - }); - - layer.find('.btn-close').on('click', e => { self.hide(); }); - - layer.find('.ui-tab-bar.SIDE .ui-tab-bar-item').on('click', e => { - let category = e.target.textContent; - if(category === 'All') category = ''; - self.search(self.query({'term': $("#bd-pubs-search").val(), 'category': category}), true); - }); - - return layer; - } - - serverCard(serverInfo) { - return `
+
`;layer=$(layer);layer.on("blur",e=>{if(e.relatedTarget.id==='bd-pubs-search')return;layer.focus();console.log("blur:");console.log(e)});layer.on("keydown",e=>{if(e.which===13&&e.target.id==='bd-pubs-search'){let category=$("#bd-pubs-layer .ui-tab-bar-item.selected").text();if(category==='All')category='';self.search(self.query({'term':e.target.value,'category':category}),!0);return} +if(e.which!==27)return;self.hide()});layer.find('.btn-close').on('click',e=>{self.hide()});layer.find('.ui-tab-bar.SIDE .ui-tab-bar-item').on('click',e=>{let category=e.target.textContent;if(category==='All')category='';self.search(self.query({'term':$("#bd-pubs-search").val(),'category':category}),!0)});return layer} +serverCard(serverInfo){return `
@@ -967,20 +157,8 @@ class PublicServers {
-
`; - } - - get bdServerCard() { - - let serverInfo = { - 'name': 'BetterDiscord', - 'icon': 'https://cdn.discordapp.com/icons/86004744966914048/c8d49dc02248e1f55caeb897c3e1a26e.webp', - 'online': '7500+', - 'members': '20000+', - 'description': 'Official BetterDiscord support server' - }; - - return `
+
`} +get bdServerCard(){let serverInfo={'name':'BetterDiscord','icon':'https://cdn.discordapp.com/icons/86004744966914048/c8d49dc02248e1f55caeb897c3e1a26e.webp','online':'7500+','members':'20000+','description':'Official BetterDiscord support server'};return `
@@ -1011,761 +189,55 @@ class PublicServers {
-
`; - } - - - getPanel() { - console.log("pubs get panel"); - return '
'; - } - - getPinnedServer() { - console.log("pubs get pinned server"); - return '
'; - } - - hidePinnedServer() { - console.log("pubs hide pinned server"); - } - - showPinnedServer() { - console.log("pubs show pinned server"); - } - - show() { - let self = this; - $(".layers").append(self.layer); - //self.search("", true); - } - - hide() { - $("#bd-pubs-layer").remove(); - } - - loadServers(dataset, search, clear) { - console.log("pubs load servers"); - } - - search(query, clear) { - - let self = this; - let $list = $("#bd-pubs-listing"); - if(clear) { - $list.empty(); - $("#bd-pubs-listing-container").hide(); - $("#bd-pubs-bg-spinner").show(); - } - $.ajax({ - method: 'GET', - url: `${self.endPoint}?${query}`, - success: data => { - $list.append(self.bdServerCard); - data.results.map(server => { - $list.append(self.serverCard(server)); - }); - $("#bd-pubs-listing-container").show(); - $("#bd-pubs-bg-spinner").hide(); - self.setSearchText(1, $(".bd-server-card").size(), data.total, null, $("#bd-pubs-search").val()); - } - }); - } - - setSearchText(start, end, total, category, term) { - if(!category) category = $("#bd-pubs-layer .ui-tab-bar-item.selected").text(); - let text = `Showing ${start}-${end} of ${total} results in ${category}`; - if(term && term.length) text += ` for: ${term}`; - $("#bd-pubs-results").text(text); - } - - get next() { - let self = this; - if(!self.next) return null; - } - - joinServer(code) { - console.log("pubs join"); - } - - joinServerDirect(code) { - console.log("pubs join direct"); - } - - escape(unsafe) { - console.log("pubs escape"); - } - - query(params) { - return require('querystring').stringify(params); - } - -} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -/* BetterDiscordApp QuickEmoteMenu JavaScript - * Version: 1.3 - * Author: Jiiks | http://jiiks.net - * Date: 26/08/2015 - 11:49 - * Last Update: 29/08/2015 - 11:46 - * https://github.com/Jiiks/BetterDiscordApp - */ - -function QuickEmoteMenu() { - -} - -QuickEmoteMenu.prototype.init = function() { - - $(document).on("mousedown", function(e) { - if(e.target.id != "rmenu") $("#rmenu").remove(); - }); - this.favoriteEmotes = {}; - var fe = bdStorage.get("bdfavemotes"); - if (fe !== "" && fe !== null) { - this.favoriteEmotes = JSON.parse(atob(fe)); - } - - var qmeHeader=""; - qmeHeader += "
"; - qmeHeader += " "; -attachEditor += " <\/div>"; -attachEditor += "<\/div>"; - -this.attachEditor = attachEditor; - -$("#bd-customcss-innerpane").append(attachEditor); - -$("#bd-customcss-detached-update").on("click", function() { - self.applyCustomCss(self.editor.getValue(), true, false); - return false; -}); -$("#bd-customcss-detached-save").on("click", function() { - self.applyCustomCss(self.editor.getValue(), false, true); - return false; -}); - - -var detachEditor=""; - detachEditor += "
"; - detachEditor += "
"; - detachEditor += " <\/div>"; - detachEditor += "<\/div>"; -this.detachedEditor = detachEditor; -}; - -CustomCssEditor.prototype.attach = function() { - $("#editor-detached").hide(); - $("#app-mount").removeClass("bd-detached-editor"); - $("#bd-customcss-pane").append($("#bd-customcss-innerpane")); - $("#bd-customcss-detached-detach").show(); - $("#bd-customcss-detach-container").remove(); -}; - -CustomCssEditor.prototype.detach = function() { - var self = this; - this.attach(); - $("#editor-detached").show(); - $("#bd-customcss-detached-detach").hide(); - $("#app-mount").addClass("bd-detached-editor"); - $(".app").parent().append(this.detachedEditor); - $("#bd-customcss-detach-editor").append($("#bd-customcss-innerpane")); -}; - -CustomCssEditor.prototype.applyCustomCss = function (css, forceupdate, forcesave) { - if ($("#customcss").length == 0) { - $("head").append(''); - } - - if(forceupdate || settingsCookie["bda-css-0"]) { - $("#customcss").html(css); - } - - if(forcesave) { - window.bdStorage.set("bdcustomcss", btoa(css)); - } -}; -/* BetterDiscordApp Settings Panel JavaScript - * Version: 2.0 - * Author: Jiiks | http://jiiks.net - * Date: 26/08/2015 - 11:54 - * 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.25.0/codemirror.min.js"); - utils.injectJs("https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.25.0/mode/css/css.min.js"); - utils.injectJs("https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.25.0/addon/scroll/simplescrollbars.min.js"); - utils.injectCss("https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.25.0/addon/scroll/simplescrollbars.min.css"); - utils.injectCss("https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.25.0/theme/material.min.css"); - utils.injectJs("https://cdnjs.cloudflare.com/ajax/libs/Sortable/1.4.2/Sortable.min.js"); -} - -SettingsPanel.prototype.init = function () { - var self = this; - self.v2SettingsPanel = new V2_SettingsPanel(); - self.construct(); - var body = $("body"); - - 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-4"]) { - voiceMode.enable(); - } - - 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 - 37); - $(".app").append($(emoteNamePopup)); - }); - $(document).on("mouseleave", ".emote", function () { - $(".tipsy").remove(); - }); - } else { - $(document).off('mouseover', '.emote'); - } - - if(settingsCookie["bda-gs-8"]) { - dMode.enable(); - } else { - dMode.disable(); - } - - if(settingsCookie["bda-gs-b"]) { - $("body").addClass("bd-blue"); - } else { - $("body").removeClass("bd-blue"); - } -}; - -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) { - case "bd-settings-tab": - $(".bda-slist-top").show(); - break; - case "bd-emotes-tab": - $(".bda-slist-top").show(); - break; - case "bd-customcss-tab": - $(".bda-slist-top").show(); - if (!customCssInitialized) { - customCssEditor.init(); - customCssInitialized = true; - } - break; - case "bd-themes-tab": - $(".bda-slist-top:first").hide(); - break; - case "bd-plugins-tab": - $(".bda-slist-top:first").hide(); - break; - default: - $(".bda-slist-top").show(); - break; - } -}; - -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") - } - } - if(id == "bda-gs-8" && enabled) { - mainCore.alert("Developer Mode Enabled", "Use F8 to break/resume execution
More coming soon") - } - - - settingsCookie[id] = enabled; - - this.updateSettings(); -}; - -SettingsPanel.prototype.updateSettings = function() { - if (settingsCookie["bda-es-0"]) { - $("#twitchcord-button-container").show(); - } else { - $("#twitchcord-button-container").hide(); - } - - if(settingsCookie["bda-gs-b"]) { - $("body").addClass("bd-blue"); - } else { - $("body").removeClass("bd-blue"); - } - - 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'); - } - - if(settingsCookie["bda-gs-8"]) { - dMode.enable(); - } else { - dMode.disable(); - } - - mainCore.saveSettings(); -}; - -SettingsPanel.prototype.construct = function () { - var self = this; - - panel = $("
", { - id: "bd-pane", - class: "settings-inner", - css: { - "display": "none" - } - }); - - //Panel start and core settings - - var settingsInner = '\ +
`} +getPanel(){console.log("pubs get panel");return '
'} +getPinnedServer(){console.log("pubs get pinned server");return '
'} +hidePinnedServer(){console.log("pubs hide pinned server")} +showPinnedServer(){console.log("pubs show pinned server")} +show(){let self=this;$(".layers").append(self.layer)} +hide(){$("#bd-pubs-layer").remove()} +loadServers(dataset,search,clear){console.log("pubs load servers")} +search(query,clear){let self=this;let $list=$("#bd-pubs-listing");if(clear){$list.empty();$("#bd-pubs-listing-container").hide();$("#bd-pubs-bg-spinner").show()} +$.ajax({method:'GET',url:`${self.endPoint}?${query}`,success:data=>{$list.append(self.bdServerCard);data.results.map(server=>{$list.append(self.serverCard(server))});$("#bd-pubs-listing-container").show();$("#bd-pubs-bg-spinner").hide();self.setSearchText(1,$(".bd-server-card").size(),data.total,null,$("#bd-pubs-search").val())}})} +setSearchText(start,end,total,category,term){if(!category)category=$("#bd-pubs-layer .ui-tab-bar-item.selected").text();let text=`Showing ${start}-${end} of ${total} results in ${category}`;if(term&&term.length)text+=` for: ${term}`;$("#bd-pubs-results").text(text)} +get next(){let self=this;if(!self.next)return null} +joinServer(code){console.log("pubs join")} +joinServerDirect(code){console.log("pubs join direct")} +escape(unsafe){console.log("pubs escape")} +query(params){return require('querystring').stringify(params)}} +function QuickEmoteMenu(){} +QuickEmoteMenu.prototype.init=function(){$(document).on("mousedown",function(e){if(e.target.id!="rmenu")$("#rmenu").remove()});this.favoriteEmotes={};var fe=bdStorage.get("bdfavemotes");if(fe!==""&&fe!==null){this.favoriteEmotes=JSON.parse(atob(fe))} +var qmeHeader="";qmeHeader+="
";qmeHeader+=" ";attachEditor+=" <\/div>";attachEditor+="<\/div>";this.attachEditor=attachEditor;$("#bd-customcss-innerpane").append(attachEditor);$("#bd-customcss-detached-update").on("click",function(){self.applyCustomCss(self.editor.getValue(),!0,!1);return!1});$("#bd-customcss-detached-save").on("click",function(){self.applyCustomCss(self.editor.getValue(),!1,!0);return!1});var detachEditor="";detachEditor+="
";detachEditor+="
";detachEditor+=" <\/div>";detachEditor+="<\/div>";this.detachedEditor=detachEditor};CustomCssEditor.prototype.attach=function(){$("#editor-detached").hide();$("#app-mount").removeClass("bd-detached-editor");$("#bd-customcss-pane").append($("#bd-customcss-innerpane"));$("#bd-customcss-detached-detach").show();$("#bd-customcss-detach-container").remove()};CustomCssEditor.prototype.detach=function(){var self=this;this.attach();$("#editor-detached").show();$("#bd-customcss-detached-detach").hide();$("#app-mount").addClass("bd-detached-editor");$(".app").parent().append(this.detachedEditor);$("#bd-customcss-detach-editor").append($("#bd-customcss-innerpane"))};CustomCssEditor.prototype.applyCustomCss=function(css,forceupdate,forcesave){if($("#customcss").length==0){$("head").append('')} +if(forceupdate||settingsCookie["bda-css-0"]){$("#customcss").html(css)} +if(forcesave){window.bdStorage.set("bdcustomcss",btoa(css))}};var settingsButton=null;var panel=null;function SettingsPanel(){utils.injectJs("https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.25.0/codemirror.min.js");utils.injectJs("https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.25.0/mode/css/css.min.js");utils.injectJs("https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.25.0/addon/scroll/simplescrollbars.min.js");utils.injectCss("https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.25.0/addon/scroll/simplescrollbars.min.css");utils.injectCss("https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.25.0/theme/material.min.css");utils.injectJs("https://cdnjs.cloudflare.com/ajax/libs/Sortable/1.4.2/Sortable.min.js")} +SettingsPanel.prototype.init=function(){var self=this;self.v2SettingsPanel=new V2_SettingsPanel();self.construct();var body=$("body");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-4"]){voiceMode.enable()} +if(settingsCookie["bda-gs-5"]){$("#app-mount").addClass("bda-dark")} +if(settingsCookie["bda-es-6"]){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-37);$(".app").append($(emoteNamePopup))});$(document).on("mouseleave",".emote",function(){$(".tipsy").remove()})}else{$(document).off('mouseover','.emote')} +if(settingsCookie["bda-gs-8"]){dMode.enable()}else{dMode.disable()} +if(settingsCookie["bda-gs-b"]){$("body").addClass("bd-blue")}else{$("body").removeClass("bd-blue")}};var customCssInitialized=!1;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){case "bd-settings-tab":$(".bda-slist-top").show();break;case "bd-emotes-tab":$(".bda-slist-top").show();break;case "bd-customcss-tab":$(".bda-slist-top").show();if(!customCssInitialized){customCssEditor.init();customCssInitialized=!0} +break;case "bd-themes-tab":$(".bda-slist-top:first").hide();break;case "bd-plugins-tab":$(".bda-slist-top:first").hide();break;default:$(".bda-slist-top").show();break}};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")}} +if(id=="bda-gs-8"&&enabled){mainCore.alert("Developer Mode Enabled","Use F8 to break/resume execution
More coming soon")} +settingsCookie[id]=enabled;this.updateSettings()};SettingsPanel.prototype.updateSettings=function(){if(settingsCookie["bda-es-0"]){$("#twitchcord-button-container").show()}else{$("#twitchcord-button-container").hide()} +if(settingsCookie["bda-gs-b"]){$("body").addClass("bd-blue")}else{$("body").removeClass("bd-blue")} +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"]){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')} +if(settingsCookie["bda-gs-8"]){dMode.enable()}else{dMode.disable()} +mainCore.saveSettings()};SettingsPanel.prototype.construct=function(){var self=this;panel=$("
",{id:"bd-pane",class:"settings-inner",css:{"display":"none"}});var settingsInner='\
\
\
\ @@ -1787,77 +259,43 @@ SettingsPanel.prototype.construct = function () {
\ \ - '; - //End core settings - - //Emote settings - - settingsInner += '\ + ';settingsInner+='\ \ - '; - - //End emote settings - - //Custom CSS Editor - var _ccss = window.bdStorage.get("bdcustomcss"); - var ccss = ""; - if(_ccss !== null && _ccss !== "") { - ccss = atob(_ccss); - } - customCssEditor.applyCustomCss(ccss, true, false); - - settingsInner += '\ + ';var _ccss=window.bdStorage.get("bdcustomcss");var ccss="";if(_ccss!==null&&_ccss!==""){ccss=atob(_ccss)} +customCssEditor.applyCustomCss(ccss,!0,!1);settingsInner+='\ \ - '; - - //End Custom CSS Editor - - //Plugin pane - - settingsInner += '\ + ';settingsInner+='\
\
\ \ \
\
    \ - '; - - $.each(bdplugins, function() { - var plugin = this["plugin"]; - var hasSettings = false; - if(typeof(plugin.getSettingsPanel) == "function") { - hasSettings = plugin.getSettingsPanel() != null && plugin.getSettingsPanel() != ""; - } - - settingsInner += '\ + ';$.each(bdplugins,function(){var plugin=this["plugin"];var hasSettings=!1;if(typeof(plugin.getSettingsPanel)=="function"){hasSettings=plugin.getSettingsPanel()!=null&&plugin.getSettingsPanel()!=""} +settingsInner+='\
  • \
    \ '+plugin.getName()+' v'+plugin.getVersion()+' by '+plugin.getAuthor()+'\ @@ -1900,44 +324,29 @@ SettingsPanel.prototype.construct = function () {
    \
    \
    \ - \ + \ \
    \ \
    \ \ - \ + \
    \
  • \ - '; - }); - - settingsInner += '\ + '});settingsInner+='\
\
\ - '; - - //End plugin pane - - //Theme pane - - settingsInner += '\ + ';settingsInner+='\ \ - '; - - //End theme panel - - //Footer - - settingsInner += '\ + ';settingsInner+='\
\ - BetterDiscord v' + ((typeof(version) == "undefined") ? bdVersion : version) + '(JSv' + jsVersion + ') by Jiiks\ + BetterDiscord v'+((typeof(version)=="undefined")?bdVersion:version)+'(JSv'+jsVersion+') by Jiiks\ BetterDiscord.net\ changelog\
\
\ - '; - - - function showSettings() { - $(".tab-bar-item").removeClass("selected"); - settingsButton.addClass("selected"); - $(".form .settings-right .settings-inner").first().hide(); - panel.show(); - if (lastTab == "") { - self.changeTab("bd-settings-tab"); - } else { - self.changeTab(lastTab); - } - } - - settingsButton = $("
", { - class: "tab-bar-item", - text: "BetterDiscord", - id: "bd-settings-new", - click: showSettings - }); - - panel.html(settingsInner); - this.panel = panel; -}; - -SettingsPanel.prototype.inject = function(mutation) { - if(this.injectNew(mutation)) return; - if(mutation.type != "childList") return; - if(mutation.addedNodes.length <= 0) return; - if($(mutation.addedNodes[0]).find(".user-settings-modal").length <= 0) return; - - var self = this; - this.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"); - self.panel.hide(); - }); - - tabBar.append(settingsButton); - $(".form .settings-right .settings-inner").last().after(self.panel); - $("#bd-settings-new").removeClass("selected"); -}; - -/*New settingspanel temp until v2*/ - -SettingsPanel.prototype.injectNew = function(mutation) { - let self = this; - if(!mutation.target.classList.contains("layers")) return; - if(!$(".ui-tab-bar-header:contains('App Settings')").length) return; - if($("#bd-settings-sidebar").length) return; - self.v2SettingsPanel.renderSidebar(); - /*$(".ui-tab-bar-item").off("click.bd").on("click.bd", e => { - $(".ui-tab-bar-item").removeClass("selected"); - $(e.target).addClass("selected"); - self.hideBdSettingsPane(); - }); - let changeLogBtn = $(".ui-tab-bar-item:contains('Change Log')"); - let bdBtn = $("
", { - class: 'ui-tab-bar-item', - text: 'BetterDiscord', - click: function() { - $(".ui-tab-bar-item").removeClass("selected"); - $(this).addClass("selected"); - self.showBdSettingsPane(); - } - }); - let separator = $("
", { - class: 'ui-tab-bar-separator margin-top-8 margin-bottom-8' - }); - separator.insertBefore(changeLogBtn.prev()); - bdBtn.insertBefore(changeLogBtn.prev()); - - $(".ui-standard-sidebar-view").last().append(self.settingsPaneNew()); - $(".bd-pane").hide(); - $(".bd-pane").first().show(); - $(".bd-tab").removeClass("selected"); - $("#bd-core").addClass("selected"); - $("#bd-settingspane").hide(); - - $(".ui-standard-sidebar-view>.sidebar-region").append(self.versionInfo());*/ - - return true; -}; - -SettingsPanel.prototype.versionInfo = function() { - let self = this; - let element = $("
", { - class: 'bd-versioninfo-wrapper' - }).append($("", { - text: `BetterDiscord v${(typeof(version) === "undefined" ? bdVersion : version)}:${jsVersion} by ` - })).append($("", { - text: 'Jiiks', - href: 'https://google.com', - target: '_blank' - })); - return element; -} - -SettingsPanel.prototype.tabBarNew = function() { - let self = this; - let _tabBar = $("
", { - class: 'tab-bar TOP', - style: 'border-bottom:none' - }); - - let items = [ - { 'id': 'bd-core', 'text': 'Core' }, - { 'id': 'bd-emotes', 'text': 'Emotes' }, - { 'id': 'bd-customcss', 'text': 'Custom CSS' }, - { 'id': 'bd-plugins', 'text': 'Plugins' }, - { 'id': 'bd-themes', 'text': 'Themes' } - ]; - - items.map(value => { - _tabBar.append($("
", { - class: 'tab-bar-item bd-tab', - text: value.text, - id: value.id, - click: () => self.changeTabNew(value.id) - })); - }); - - return _tabBar; -} - -SettingsPanel.prototype.changeTabNew = function(id) { - $(".bd-tab").removeClass("selected"); - $(`#${id}`).addClass("selected"); - $(".bd-pane").hide(); - $(`#${id}-pane`).show(); - - if(id === 'bd-customcss') { - if (!customCssInitialized) { - customCssEditor.init(); - customCssInitialized = true; - } - } - -} - -SettingsPanel.prototype.updateSettingNew = function (id, checked) { - - if(id == "bda-css-2") { - $("#app-mount").removeClass("bd-hide-bd"); - customCssEditor.hideBackdrop = checked; - if(checked) { - $("#app-mount").addClass("bd-hide-bd") - } - } - if(id == "bda-gs-8" && checked) { - mainCore.alert("Developer Mode Enabled", "Use F8 to break/resume execution
More coming soon") - } - - settingsCookie[id] = checked; - - this.updateSettings(); -}; - -SettingsPanel.prototype.settingsSwitch = function(key) { - let self = this; - let setting = settings[key]; - return $("
", { - class: 'ui-flex flex-vertical flex-justify-start flex-align-stretch flex-nowrap ui-switch-item' - }).append($("
", { - class: 'ui-flex flex-horizontal flex-justify-start flex-align-stretch flex-nowrap' - }).append($("

", { - class: 'ui-form-title h3 margin-reset margin-reset ui-flex-child', - text: key - })).append($("