From f95ecc12e342c3e0c293bc6d21c64d013d38bed2 Mon Sep 17 00:00:00 2001 From: Jiiks Date: Sun, 1 Nov 2015 13:37:04 +0200 Subject: [PATCH 1/3] Get latest commit hash --- js/main.js | 10 ++++++++++ js/utils.js | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/js/main.js b/js/main.js index 8e79dbc5..08c37392 100644 --- a/js/main.js +++ b/js/main.js @@ -70,6 +70,7 @@ Core.prototype.init = function() { } utils = new Utils(); + utils.getHash(); emoteModule = new EmoteModule(); quickEmoteMenu = new QuickEmoteMenu(); voiceMode = new VoiceMode(); @@ -694,6 +695,8 @@ SettingsPanel.prototype.handler = function(e){ * https://github.com/Jiiks/BetterDiscordApp */ +var _hash; + function Utils() { } @@ -706,6 +709,13 @@ Utils.prototype.jqDefer = function(fnc) { if(window.jQuery) { fnc(); } else { setTimeout(function() { this.jqDefer(fnc) }, 100) } }; +Utils.prototype.getHash = function() { + $.getJson("https://api.github.com/repos/Jiiks/BetterDiscordApp/commits/master", function(data) { + _hash = data.sha; + }); + +}; + /* BetterDiscordApp VoiceMode JavaScript * Version: 1.0 * Author: Jiiks | http://jiiks.net diff --git a/js/utils.js b/js/utils.js index 2e61cf67..cde135da 100644 --- a/js/utils.js +++ b/js/utils.js @@ -5,6 +5,8 @@ * https://github.com/Jiiks/BetterDiscordApp */ +var _hash; + function Utils() { } @@ -15,4 +17,11 @@ Utils.prototype.getTextArea = function() { Utils.prototype.jqDefer = function(fnc) { if(window.jQuery) { fnc(); } else { setTimeout(function() { this.jqDefer(fnc) }, 100) } +}; + +Utils.prototype.getHash = function() { + $.getJson("https://api.github.com/repos/Jiiks/BetterDiscordApp/commits/master", function(data) { + _hash = data.sha; + }); + }; \ No newline at end of file From 2ebf47f5a368ac29f80bb125997192a753b0f2f9 Mon Sep 17 00:00:00 2001 From: Jiiks Date: Sun, 1 Nov 2015 13:38:59 +0200 Subject: [PATCH 2/3] Emotefilter --- emotefilter.json | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 emotefilter.json diff --git a/emotefilter.json b/emotefilter.json new file mode 100644 index 00000000..23560dfb --- /dev/null +++ b/emotefilter.json @@ -0,0 +1,9 @@ +{ + "blacklist": [ + "double", + "triple", + "quadra", + "penta", + "snap" + ] +} \ No newline at end of file From 692ecc345201bd8d62edde64468631333f81e035 Mon Sep 17 00:00:00 2001 From: Jiiks Date: Sun, 1 Nov 2015 13:44:25 +0200 Subject: [PATCH 3/3] Load emote blacklist from github --- js/main.js | 9 ++++++--- js/main.min.js | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/js/main.js b/js/main.js index 08c37392..7431c03a 100644 --- a/js/main.js +++ b/js/main.js @@ -179,9 +179,12 @@ var subEmotesTwitch = {}; //TODO Use emotesTwitch for autocap var twitchAc = {"4head":"4Head","anele":"ANELE","argieb8":"ArgieB8","arsonnosexy":"ArsonNoSexy","asianglow":"AsianGlow","atgl":"AtGL","athenapms":"AthenaPMS","ativy":"AtIvy","atww":"AtWW","babyrage":"BabyRage","batchest":"BatChest","bcwarrior":"BCWarrior","biblethump":"BibleThump","bigbrother":"BigBrother","bionicbunion":"BionicBunion","blargnaut":"BlargNaut","bloodtrail":"BloodTrail","bort":"BORT","brainslug":"BrainSlug","brokeback":"BrokeBack","buddhabar":"BuddhaBar","coolcat":"CoolCat","corgiderp":"CorgiDerp","cougarhunt":"CougarHunt","daesuppy":"DAESuppy","dansgame":"DansGame","dathass":"DatHass","datsheffy":"DatSheffy","dbstyle":"DBstyle","deexcite":"deExcite","deilluminati":"deIlluminati","dendiface":"DendiFace","dogface":"DogFace","doomguy":"DOOMGuy","eagleeye":"EagleEye","elegiggle":"EleGiggle","evilfetus":"EvilFetus","failfish":"FailFish","fpsmarksman":"FPSMarksman","frankerz":"FrankerZ","freakinstinkin":"FreakinStinkin","fungineer":"FUNgineer","funrun":"FunRun","fuzzyotteroo":"FuzzyOtterOO","gasjoker":"GasJoker","gingerpower":"GingerPower","grammarking":"GrammarKing","hassanchop":"HassanChop","heyguys":"HeyGuys","hotpokket":"HotPokket","humblelife":"HumbleLife","itsboshytime":"ItsBoshyTime","jebaited":"Jebaited","jkanstyle":"JKanStyle","joncarnage":"JonCarnage","kapow":"KAPOW","kappa":"Kappa","kappapride":"KappaPride","keepo":"Keepo","kevinturtle":"KevinTurtle","kippa":"Kippa","kreygasm":"Kreygasm","kzskull":"KZskull","mau5":"Mau5","mcat":"mcaT","mechasupes":"MechaSupes","mrdestructoid":"MrDestructoid","mvgame":"MVGame","nightbat":"NightBat","ninjatroll":"NinjaTroll","nonospot":"NoNoSpot","notatk":"NotATK","notlikethis":"NotLikeThis","omgscoots":"OMGScoots","onehand":"OneHand","opieop":"OpieOP","optimizeprime":"OptimizePrime","osbeaver":"OSbeaver","osbury":"OSbury","osdeo":"OSdeo","osfrog":"OSfrog","oskomodo":"OSkomodo","osrob":"OSrob","ossloth":"OSsloth","panicbasket":"panicBasket","panicvis":"PanicVis","pazpazowitz":"PazPazowitz","peopleschamp":"PeoplesChamp","permasmug":"PermaSmug","picomause":"PicoMause","pipehype":"PipeHype","pjharley":"PJHarley","pjsalt":"PJSalt","pmstwin":"PMSTwin","pogchamp":"PogChamp","poooound":"Poooound","praiseit":"PraiseIt","prchase":"PRChase","punchtrees":"PunchTrees","puppeyface":"PuppeyFace","raccattack":"RaccAttack","ralpherz":"RalpherZ","redcoat":"RedCoat","residentsleeper":"ResidentSleeper","ritzmitz":"RitzMitz","rulefive":"RuleFive","shadylulu":"ShadyLulu","shazam":"Shazam","shazamicon":"shazamicon","shazbotstix":"ShazBotstix","shibez":"ShibeZ","smorc":"SMOrc","smskull":"SMSkull","sobayed":"SoBayed","soonerlater":"SoonerLater","srihead":"SriHead","ssssss":"SSSsss","stonelightning":"StoneLightning","strawbeary":"StrawBeary","supervinlin":"SuperVinlin","swiftrage":"SwiftRage","tbbaconbiscuit":"tbBaconBiscuit","tbchickenbiscuit":"tbChickenBiscuit","tbquesarito":"tbQuesarito","tbsausagebiscuit":"tbSausageBiscuit","tbspicy":"tbSpicy","tbsriracha":"tbSriracha","tf2john":"TF2John","theking":"TheKing","theringer":"TheRinger","thetarfu":"TheTarFu","thething":"TheThing","thunbeast":"ThunBeast","tinyface":"TinyFace","toospicy":"TooSpicy","trihard":"TriHard","ttours":"TTours","uleetbackup":"UleetBackup","unclenox":"UncleNox","unsane":"UnSane","vaultboy":"VaultBoy","volcania":"Volcania","wholewheat":"WholeWheat","winwaker":"WinWaker","wtruck":"WTRuck","wutface":"WutFace","youwhy":"YouWHY"}; -function EmoteModule() {} +function EmoteModule() { +} -EmoteModule.prototype.init = function() {}; +EmoteModule.prototype.init = function() { + $.getJson("https://cdn.rawgit.com/Jiiks/betterDiscordApp/"+_hash+"/emotefilter.json", function(data) { bemotes = data.blacklist; }); +}; EmoteModule.prototype.obsCallback = function(mutation) { var self = this; @@ -213,7 +216,7 @@ EmoteModule.prototype.getNodes = function(node) { return nodes; }; -var bemotes = [ "double", "triple", "quadra", "penta" ]; +var bemotes = []; //TODO Functional titles EmoteModule.prototype.injectEmote = function(node) { diff --git a/js/main.min.js b/js/main.min.js index 607c2c3b..0f092291 100644 --- a/js/main.min.js +++ b/js/main.min.js @@ -1 +1 @@ -function Core(){}function EmoteModule(){}function PublicServers(){}function QuickEmoteMenu(){}function SettingsPanel(){}function Utils(){}function VoiceMode(){}var settingsPanel,emoteModule,utils,quickEmoteMenu,opublicServers,voiceMode,jsVersion=1.3,supportedVersion="0.1.5",mainObserver,twitchEmoteUrlStart="https://static-cdn.jtvnw.net/emoticons/v1/",twitchEmoteUrlEnd="/1.0",ffzEmoteUrlStart="https://cdn.frankerfacez.com/emoticon/",ffzEmoteUrlEnd="/1",bttvEmoteUrlStart="",bttvEmoteUrlEnd="",mainCore,settings={"Save logs locally":{id:"bda-gs-0",info:"Saves chat logs locally",implemented:!1},"Public Servers":{id:"bda-gs-1",info:"BETA : Display public servers button",implemented:!0},"Minimal Mode":{id:"bda-gs-2",info:"Hide elements and reduce the size of elements.",implemented:!0},"Voice Mode":{id:"bda-gs-4",info:"Only show voice chat",implemented:!0},"Hide Channels":{id:"bda-gs-3",info:"Hide channels in minimal mode",implemented:!0},"Quick Emote Menu":{id:"bda-es-0",info:"Show quick emote menu for adding emotes",implemented:!0},"FrankerFaceZ Emotes":{id:"bda-es-1",info:"Show FrankerFaceZ Emotes",implemented:!0},"BetterTTV Emotes":{id:"bda-es-2",info:"Show BetterTTV Emotes",implemented:!0},"Emote Autocomplete":{id:"bda-es-3",info:"Autocomplete emote commands",implemented:!1},"Emote Auto Capitalization":{id:"bda-es-4",info:"Autocapitalize emote commands",implemented:!0},"Override Default Emotes":{id:"bda-es-5",info:"Override default emotes",implemented:!1}},defaultCookie={version:jsVersion,"bda-gs-0":!1,"bda-gs-1":!0,"bda-gs-2":!1,"bda-gs-3":!1,"bda-gs-4":!1,"bda-es-0":!0,"bda-es-1":!1,"bda-es-2":!1,"bda-es-3":!1,"bda-es-4":!1,"bda-es-5":!0},settingsCookie={};Core.prototype.init=function(){function e(){if(console.log((new Date).getTime()+" Defer"),$(".guilds-wrapper .guilds").children().length>0){console.log((new Date).getTime()+" Defer Loaded");var t=$(".guilds li:first-child");t.after($("
  • ",{id:"bd-pub-li",css:{height:"20px",display:1==settingsCookie["bda-gs-1"]?"":"none"}}).append($("
    ",{"class":"guild-inner",css:{height:"20px","border-radius":"4px"}}).append($("").append($("
    ",{css:{"line-height":"20px","font-size":"12px"},text:"public",id:"bd-pub-button"}))))),t.after($("
  • ",{id:"tc-settings-li"}).append($("
    ",{"class":"guild-inner"}).append($("").append($("
    ",{"class":"avatar-small",id:"tc-settings-button"}))))),settingsPanel=new SettingsPanel,settingsPanel.init(),quickEmoteMenu.init(!1),$("#tc-settings-button").on("click",function(){settingsPanel.show()}),$("#bd-pub-button").on("click",function(){opublicServers.show()}),opublicServers=new PublicServers,opublicServers.init(),emoteModule.autoCapitalize()}else setTimeout(e,100)}return version")):"undefined"!=typeof emotesFfz&&settingsCookie["bda-es-1"]&&emotesFfz.hasOwnProperty(e)?void(i=i.replace(e,"")):"undefined"!=typeof emotesBTTV&&settingsCookie["bda-es-2"]&&emotesBTTV.hasOwnProperty(e)?void(i=i.replace(e,"")):void(subEmotesTwitch.hasOwnProperty(e)&&(i=i.replace(e,"")))}),null!=t.parentElement)){var n=t.parentElement.offsetHeight;t.innerHTML=i;var a=t.parentElement.offsetHeight,s=$(".scroller.messages").first();s.scrollTop(s.scrollTop()+(a-n))}}}},EmoteModule.prototype.autoCapitalize=function(){var e=this;$("body").delegate($(".channel-textarea-inner textarea"),"keyup change paste",function(){if(settingsCookie["bda-es-4"]){var t=$(".channel-textarea-inner textarea").val();if(void 0!=t){var i=t.split(" ").pop();if(i.length>3){var o=e.capitalize(i.toLowerCase());null!=o&&$(".channel-textarea-inner textarea").val(t.replace(i,o))}}}})},EmoteModule.prototype.capitalize=function(e){return twitchAc.hasOwnProperty(e)?twitchAc[e]:null};var publicServers={servers:{server:{code:0,icon:null,title:"title",language:"EN",description:"description"}}};PublicServers.prototype.getPanel=function(){return this.container},PublicServers.prototype.init=function(){var e=this;this.container=$("
    ",{id:"bd-ps-container",style:"display:none"});var t=$("
    ",{id:"bd-ps-header"});$("

    ",{text:"Public Servers"}).appendTo(t),$("",{id:"bd-ps-close",style:"cursor:pointer;",text:"X"}).appendTo(t),t.appendTo(this.getPanel());var i=$("
    ",{id:"bd-ps-body"});i.appendTo(this.getPanel());var o=$("",{border:"0"}),n=$("");n.appendTo(o);var a=$("",{}).append($("",{id:"bd-ps-tbody"});s.appendTo(o),o.appendTo(i),$("body").append(this.getPanel()),$("#bd-ps-close").on("click",function(){e.show()});var r=publicServers.servers;for(var l in r)if(r.hasOwnProperty(l)){var d=r[l],c=d.code,p=d.title,u=d.language,m=d.description;this.addServer(l,c,p,u,m)}},PublicServers.prototype.addServer=function(e,t,i,o,n){var a=this,s=$("#bd-ps-tbody"),r=$("");l.append($("
    ",{text:"Name"})).append($("",{text:"Code"})).append($("",{text:"Language"})).append($("",{text:"Description"})).append($("",{text:"Join"}));a.appendTo(n);var s=$("
    ").append($("
    ",{"class":"bd-ps-description",text:n})),l=$("
    ",{text:i})),l.append($("",{css:{"-webkit-user-select":"initial","user-select":"initial"},text:t})),l.append($("",{text:o})),l.append(r),l.append($("").append($("