diff --git a/js/main.js b/js/main.js index aff0601..0b59397 100644 --- a/js/main.js +++ b/js/main.js @@ -119,7 +119,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _0gl /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _0globals__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./0globals */ \"./src/0globals.js\");\n/* harmony import */ var _core__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./core */ \"./src/core.js\");\n/* harmony import */ var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./utils */ \"./src/utils.js\");\n/* harmony import */ var _v2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./v2 */ \"./src/v2.js\");\n/* harmony import */ var _dataStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./dataStore */ \"./src/dataStore.js\");\n\n\n\n\n\nconst BdApi = {\n get React() {\n return _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].react;\n },\n\n get ReactDOM() {\n return _v2__WEBPACK_IMPORTED_MODULE_3__[\"default\"].reactDom;\n },\n\n get WindowConfigFile() {\n if (this._windowConfigFile) return this._windowConfigFile;\n\n const electron = __webpack_require__(/*! electron */ \"electron\").remote.app;\n\n const path = __webpack_require__(/*! path */ \"path\");\n\n const base = electron.getAppPath();\n const roamingBase = electron.getPath(\"userData\");\n const roamingLocation = path.resolve(roamingBase, electron.getVersion(), \"modules\", \"discord_desktop_core\", \"injector\", \"config.json\");\n const location = path.resolve(base, \"..\", \"app\", \"config.json\");\n\n const fs = __webpack_require__(/*! fs */ \"fs\");\n\n const realLocation = fs.existsSync(location) ? location : fs.existsSync(roamingLocation) ? roamingLocation : null;\n if (!realLocation) return this._windowConfigFile = null;\n return this._windowConfigFile = realLocation;\n }\n\n};\n\nBdApi.getAllWindowPreferences = function () {\n if (!this.WindowConfigFile) return {}; // Tempfix until new injection on other platforms\n\n return require(this.WindowConfigFile);\n};\n\nBdApi.getWindowPreference = function (key) {\n if (!this.WindowConfigFile) return undefined; // Tempfix until new injection on other platforms\n\n return this.getAllWindowPreferences()[key];\n};\n\nBdApi.setWindowPreference = function (key, value) {\n if (!this.WindowConfigFile) return; // Tempfix until new injection on other platforms\n\n const fs = __webpack_require__(/*! fs */ \"fs\");\n\n const prefs = this.getAllWindowPreferences();\n prefs[key] = value;\n delete require.cache[this.WindowConfigFile];\n fs.writeFileSync(this.WindowConfigFile, JSON.stringify(prefs, null, 4));\n}; //Inject CSS to document head\n//id = id of element\n//css = custom css\n\n\nBdApi.injectCSS = function (id, css) {\n $(\"head\").append($(\"'),$("#customcss").text(this.editor.session.getValue()).detach().appendTo(document.head)}saveCss(){V.setBDData("bdcustomcss",btoa(this.editor.session.getValue()))}}class Ae extends z.reactComponent{constructor(e){super(e);this.props.lines=0,this.setInitialState(),this.attach=this.attach.bind(this),this.detachedEditor=z.react.createElement(Le,{attach:this.attach}),this.onClick=this.onClick.bind(this),this.updateCss=this.updateCss.bind(this),this.saveCss=this.saveCss.bind(this),this.detach=this.detach.bind(this)}setInitialState(){this.state={detached:this.props.detached||z.editorDetached}}componentDidMount(){this.editor=ace.edit("bd-customcss-editor"),this.editor.setTheme("ace/theme/monokai"),this.editor.session.setMode("ace/mode/css"),this.editor.setShowPrintMargin(!1),this.editor.setFontSize(14),this.editor.on("change",()=>{l["bda-css-0"]&&(this.saveCss(),this.updateCss())})}componentWillUnmount(){this.editor.destroy()}componentDidUpdate(e,t){const n=this;t.detached&&!n.state.detached&&z.reactDom.unmountComponentAtNode(n.detachedRoot)}codeMirror(){}get options(){return{lineNumbers:!0,mode:"css",indentUnit:4,theme:"material",scrollbarStyle:"simple"}}get css(){const e=V.getBDData("bdcustomcss");let t="";return e&&""!==e&&(t=atob(e)),t}updateLineCount(){const e=this.refs.editor.value.split("\n").length;e!=this.props.lines&&(this.refs.lines.textContent=Array.from(new Array(e),(e,t)=>t+1).join(".\n")+".",this.props.lines=e)}render(){const e=this,{detached:t}=e.state;return z.react.createElement("div",{className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default",style:{padding:"60px 40px 0px"}},t&&z.react.createElement("div",{id:"editor-detached"},z.react.createElement(fe,{text:"Custom CSS Editor"}),z.react.createElement("h3",null,"Editor Detached"),z.react.createElement("button",{className:"btn btn-primary",onClick:()=>{e.attach()}},"Attach")),!t&&z.react.createElement("div",null,z.react.createElement(fe,{text:"Custom CSS Editor"}),z.react.createElement("div",{className:"editor-wrapper"},z.react.createElement("div",{id:"bd-customcss-editor",className:"editor",ref:"editor"},e.css)),z.react.createElement("div",{id:"bd-customcss-attach-controls"},z.react.createElement("ul",{className:"checkbox-group"},z.react.createElement(Fe,{id:"live-update",text:"Live Update",onChange:this.onChange,checked:l["bda-css-0"]})),z.react.createElement("div",{id:"bd-customcss-detach-controls-button"},z.react.createElement("button",{style:{borderRadius:"3px 0 0 3px",borderRight:"1px solid #3f4146"},className:"btn btn-primary",onClick:()=>{e.onClick("update")}},"Update"),z.react.createElement("button",{style:{borderRadius:"0",borderLeft:"1px solid #2d2d2d",borderRight:"1px solid #2d2d2d"},className:"btn btn-primary",onClick:()=>{e.onClick("save")}},"Save"),z.react.createElement("button",{style:{borderRadius:"0 3px 3px 0",borderLeft:"1px solid #3f4146"},className:"btn btn-primary",onClick:()=>{e.onClick("detach")}},"Detach"),z.react.createElement("span",{style:{fontSize:"10px",marginLeft:"5px"}},"Unsaved changes are lost on detach"),z.react.createElement("div",{className:"help-text"},"Press ",z.react.createElement("code",{className:"inline"},"ctrl"),"+",z.react.createElement("span",{className:"inline"},",")," with the editor focused to access the editor's settings.")))))}onClick(e){const t=this;switch(e){case"update":t.updateCss();break;case"save":t.saveCss();break;case"detach":t.detach()}}onChange(e,t){switch(e){case"live-update":l["bda-css-0"]=t,Re.saveSettings()}}updateCss(){0==$("#customcss").length&&$("head").append(''),$("#customcss").text(this.editor.session.getValue()).detach().appendTo(document.head)}saveCss(){V.setBDData("bdcustomcss",btoa(this.editor.session.getValue()))}detach(){this.setState({detached:!0});const e=this.detachedRoot;e?z.reactDom.render(this.detachedEditor,e):console.log("FAILED TO INJECT ROOT: .app")}get detachedRoot(){const e=$("#bd-customcss-detach-container");return e.length?e[0]:this.injectDetachedRoot()?this.detachedRoot:null}injectDetachedRoot(){return!!$(".app, .app-2rEoOp").length&&($("
",{id:"bd-customcss-detach-container"}).insertAfter($(".app, .app-2rEoOp")),!0)}attach(){this.setState({detached:!1})}}class Ie extends z.reactComponent{constructor(e){super(e)}render(){return z.react.createElement("div",{className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"},z.react.createElement("h2",{className:"ui-form-title h2 margin-reset margin-bottom-20"},this.props.title),this.props.children)}}var Re=new class{constructor(){this.sideBarOnClick=this.sideBarOnClick.bind(this),this.onChange=this.onChange.bind(this),this.updateSettings=this.updateSettings.bind(this),this.sidebar=new ne(this.sideBarOnClick)}get root(){const e=$("#bd-settingspane-container");return e.length?e[0]:this.injectRoot()?this.root:null}injectRoot(){if(!$(".layer-3QrUeG .standardSidebarView-3F1I7i, .layer-3QrUeG .ui-standard-sidebar-view").length)return!1;const e=$("
",{class:"contentRegion-3nDuYy content-region",id:"bd-settingspane-container"});return $(".layer-3QrUeG .standardSidebarView-3F1I7i, .layer-3QrUeG .ui-standard-sidebar-view").append(e),S.onRemoved(e[0],()=>{z.reactDom.unmountComponentAtNode(e[0])}),!0}get coreSettings(){const e=this.getSettings("core");return[...new Set(e.map(e=>e.category))].map(t=>({title:t,settings:e.filter(e=>e.category==t)}))}get emoteSettings(){return this.getSettings("emote")}getSettings(e){return Object.keys(i).reduce((t,n)=>{const s=i[n];return s.cat===e&&s.implemented&&!s.hidden&&(s.text=n,t.push(s)),t},[])}sideBarOnClick(e){const t=this;switch($(".contentRegion-3nDuYy, .content-region").first().hide(),$(t.root).show(),e){case"core":t.renderCoreSettings();break;case"emotes":t.renderEmoteSettings();break;case"customcss":t.renderCustomCssEditor();break;case"plugins":t.renderPluginPane();break;case"themes":t.renderThemePane()}}onClick(){}onChange(e,t){this.updateSettings(e,t)}updateSettings(e,t){if(l[e]=t,"fork-beta"==e)try{const e=n(0),s=n(2).join(DiscordNative.process.remote.resourcesPath,"app","betterdiscord","config.json"),o=require(s);o.branch=t?"modularize":"master",e.writeFileSync(s,JSON.stringify(o,null,4))}catch(e){console.error(e)}"bda-gs-2"==e&&(t?$("body").addClass("bd-minimal"):$("body").removeClass("bd-minimal")),"bda-gs-3"==e&&(t?$("body").addClass("bd-minimal-chan"):$("body").removeClass("bd-minimal-chan")),"bda-gs-1"==e&&(t?ye.addButton():ye.removeButton()),"bda-gs-4"==e&&(t?ke.enable():ke.disable()),"bda-gs-5"==e&&(t?$("#app-mount").addClass("bda-dark"):$("#app-mount").removeClass("bda-dark")),t&&"bda-gs-6"==e&&oe.inject24Hour(),"bda-gs-7"==e&&(t?se.injectColoredText():se.removeColoredText()),"bda-es-4"==e&&(t?Y.autoCapitalize():Y.disableAutoCapitalize()),"fork-ps-4"==e&&(t?Ee.start():Ee.stop()),"fork-ps-5"==e&&(t?(q.watchContent("plugin"),q.watchContent("theme")):(q.unwatchContent("plugin"),q.unwatchContent("theme"))),"bda-gs-8"==e&&(t?Se.enable(l["fork-dm-1"]):Se.disable()),"fork-dm-1"==e&&l["bda-gs-8"]&&Se.enable(t),this.saveSettings()}async initializeSettings(){l["bda-gs-2"]&&$("body").addClass("bd-minimal"),l["bda-gs-3"]&&$("body").addClass("bd-minimal-chan"),l["bda-gs-1"]&&ye.addButton(),l["bda-gs-4"]&&ke.enable(),l["bda-gs-5"]&&$("#app-mount").addClass("bda-dark"),l["bda-gs-6"]&&oe.inject24Hour(),l["bda-gs-7"]&&se.injectColoredText(),l["bda-es-4"]&&Y.autoCapitalize(),l["fork-ps-4"]&&Ee.start(),l["fork-ps-5"]&&(q.watchContent("plugin"),q.watchContent("theme")),l["bda-gs-8"]&&Se.enable(l["fork-dm-1"]),(async()=>{const e=z.WebpackModules.findByUniqueProperties(["getSortedGuilds"]),t=z.WebpackModules.findByUniqueProperties(["getMember"]),n=e.getFlattenedGuildIds().includes("292141134614888448"),s=z.UserStore.getCurrentUser().id,o=t.getMember("292141134614888448",s);!(!n||!o)&&o.roles.includes("452687773678436354")&&(i["BBD Beta"].hidden=!1)})(),this.saveSettings()}saveSettings(){V.setSettingGroup("settings",l)}loadSettings(){Object.assign(l,V.getSettingGroup("settings"))}renderSidebar(){const e=this;$("[class*='side-'] > [class*='item-']").off("click.v2settingspanel").on("click.v2settingspanel",()=>{z.reactDom.unmountComponentAtNode(e.root),$(e.root).hide(),$(".contentRegion-3nDuYy, .content-region").first().show()}),e.sidebar.render()}get coreComponent(){return z.react.createElement(me,{contentColumn:!0,fade:!0,dark:!0,children:[z.react.createElement(Oe,{key:"cspanel",onChange:this.onChange,sections:this.coreSettings}),z.react.createElement(he,{key:"tools"})]})}get emoteComponent(){return z.react.createElement(me,{contentColumn:!0,fade:!0,dark:!0,children:[z.react.createElement(je,{key:"espanel",title:"Emote Settings",onChange:this.onChange,settings:this.emoteSettings,button:{title:"Clear Emote Cache",onClick:()=>{Y.clearEmoteData(),Y.init(),J.init()}}}),z.react.createElement(he,{key:"tools"})]})}get customCssComponent(){return z.react.createElement(me,{contentColumn:!0,fade:!0,dark:!0,children:[z.react.createElement(Ae,{key:"csseditor"}),z.react.createElement(he,{key:"tools"})]})}contentComponent(e){const t="plugins"==e?this.pluginsComponent:this.themesComponent,n=e.replace("s",""),s=this;class o extends z.react.Component{constructor(e){super(e),this.onChange=this.onChange.bind(this)}componentDidMount(){D.on(`${n}-reloaded`,this.onChange),D.on(`${n}-loaded`,this.onChange),D.on(`${n}-unloaded`,this.onChange)}componentWillUnmount(){D.off(`${n}-reloaded`,this.onChange),D.off(`${n}-loaded`,this.onChange),D.off(`${n}-unloaded`,this.onChange)}onChange(){s.sideBarOnClick(e)}render(){return t}}return z.react.createElement(o)}get pluginsComponent(){const e=Object.keys(w).sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())).reduce((e,t)=>(e.push(z.react.createElement(Ne,{key:t,plugin:w[t].plugin})),e),[]),t=z.react.createElement(De,{key:"plugin-list",className:"bda-slist",children:e}),s=!l["fork-ps-5"]&&z.react.createElement(Te($e,{color:"black",side:"top",text:"Reload Plugin List"}),{className:"bd-reload-header",size:"18px",onClick:async()=>{P.updatePluginList(),this.sideBarOnClick("plugins")}}),o=z.react.createElement("button",{key:"folder-button",className:"bd-pfbtn",onClick:()=>{n(1).shell.openItem(q.pluginsFolder)}},"Open Plugin Folder"),r=z.react.createElement(Ie,{key:"pcolumn",title:"Plugins",children:[s,o,t]});return z.react.createElement(me,{contentColumn:!0,fade:!0,dark:!0,children:[r,z.react.createElement(he,{key:"tools"})]})}get themesComponent(){const e=Object.keys(k).sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())).reduce((e,t)=>(e.push(z.react.createElement(Pe,{key:t,theme:k[t]})),e),[]),t=z.react.createElement(De,{key:"theme-list",className:"bda-slist",children:e}),s=!l["fork-ps-5"]&&z.react.createElement(Te($e,{color:"black",side:"top",text:"Reload Theme List"}),{className:"bd-reload-header",size:"18px",onClick:async()=>{B.updateThemeList(),this.sideBarOnClick("themes")}}),o=z.react.createElement("button",{key:"folder-button",className:"bd-pfbtn",onClick:()=>{n(1).shell.openItem(q.themesFolder)}},"Open Theme Folder"),r=z.react.createElement(Ie,{key:"tcolumn",title:"Themes",children:[s,o,t]});return z.react.createElement(me,{contentColumn:!0,fade:!0,dark:!0,children:[r,z.react.createElement(he,{key:"tools"})]})}renderCoreSettings(){const e=this.root;e?z.reactDom.render(this.coreComponent,e):console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i")}renderEmoteSettings(){const e=this.root;e?z.reactDom.render(this.emoteComponent,e):console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i")}renderCustomCssEditor(){const e=this.root;e?z.reactDom.render(this.customCssComponent,e):console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i")}renderPluginPane(){const e=this.root;e?z.reactDom.render(this.contentComponent("plugins"),e):console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i")}renderThemePane(){const e=this.root;e?z.reactDom.render(this.contentComponent("themes"),e):console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i")}};class _e extends z.reactComponent{render(){return z.react.createElement("svg",{height:"100%",width:this.props.size||"16px",className:"bd-logo "+this.props.className,style:{fillRule:"evenodd",clipRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"},viewBox:"0 0 2000 2000"},z.react.createElement("metadata",null),z.react.createElement("defs",null,z.react.createElement("filter",{id:"shadow1"},z.react.createElement("feDropShadow",{dx:"20",dy:"0",stdDeviation:"20","flood-color":"rgba(0,0,0,0.35)"})),z.react.createElement("filter",{id:"shadow2"},z.react.createElement("feDropShadow",{dx:"15",dy:"0",stdDeviation:"20","flood-color":"rgba(255,255,255,0.15)"})),z.react.createElement("filter",{id:"shadow3"},z.react.createElement("feDropShadow",{dx:"10",dy:"0",stdDeviation:"20","flood-color":"rgba(0,0,0,0.35)"}))),z.react.createElement("g",null,z.react.createElement("path",{style:{filter:"url(#shadow3)"},d:"M1195.44+135.442L1195.44+135.442L997.6+136.442C1024.2+149.742+1170.34+163.542+1193.64+179.742C1264.34+228.842+1319.74+291.242+1358.24+365.042C1398.14+441.642+1419.74+530.642+1422.54+629.642L1422.54+630.842L1422.54+632.042C1422.54+773.142+1422.54+1228.14+1422.54+1369.14L1422.54+1370.34L1422.54+1371.54C1419.84+1470.54+1398.24+1559.54+1358.24+1636.14C1319.74+1709.94+1264.44+1772.34+1193.64+1821.44C1171.04+1837.14+1025.7+1850.54+1000+1863.54L1193.54+1864.54C1539.74+1866.44+1864.54+1693.34+1864.54+1296.64L1864.54+716.942C1866.44+312.442+1541.64+135.442+1195.44+135.442Z",fill:"#171717",opacity:"1"}),z.react.createElement("path",{style:{filter:"url(#shadow2)"},d:"M1695.54+631.442C1685.84+278.042+1409.34+135.442+1052.94+135.442L361.74+136.442L803.74+490.442L1060.74+490.442C1335.24+490.442+1335.24+835.342+1060.74+835.342L1060.74+1164.84C1150.22+1164.84+1210.53+1201.48+1241.68+1250.87C1306.07+1353+1245.76+1509.64+1060.74+1509.64L361.74+1863.54L1052.94+1864.54C1409.24+1864.54+1685.74+1721.94+1695.54+1368.54C1695.54+1205.94+1651.04+1084.44+1572.64+999.942C1651.04+915.542+1695.54+794.042+1695.54+631.442Z",fill:"#3E82E5",opacity:"1"}),z.react.createElement("path",{style:{filter:"url(#shadow1)"},d:"M1469.25+631.442C1459.55+278.042+1183.05+135.442+826.65+135.442L135.45+135.442L135.45+1004C135.45+1004+135.427+1255.21+355.626+1255.21C575.825+1255.21+575.848+1004+575.848+1004L577.45+490.442L834.45+490.442C1108.95+490.442+1108.95+835.342+834.45+835.342L664.65+835.342L664.65+1164.84L834.45+1164.84C923.932+1164.84+984.244+1201.48+1015.39+1250.87C1079.78+1353+1019.47+1509.64+834.45+1509.64L135.45+1509.64L135.45+1864.54L826.65+1864.54C1182.95+1864.54+1459.45+1721.94+1469.25+1368.54C1469.25+1205.94+1424.75+1084.44+1346.35+999.942C1424.75+915.542+1469.25+794.042+1469.25+631.442Z",fill:"#FFFFFF",opacity:"1"})))}}function qe(e){Object.assign(h,e)}qe.prototype.init=async function(){if(h.version
Please download the latest version from GitHub");if(window.ED)return void S.alert("Not Supported","BandagedBD does not work with EnhancedDiscord. Please uninstall one of them.");if(window.WebSocket&&window.WebSocket.name&&window.WebSocket.name.includes("Patched"))return void S.alert("Not Supported","BandagedBD does not work with Powercord. Please uninstall one of them.");const e=h.updater?h.updater.LatestVersion:h.latestVersion;e>h.version&&S.alert("Update Available",`\n An update for BandagedBD is available (${e})! Please Reinstall!

\n Download Installer\n `),S.log("Startup","Initializing Settings"),this.initSettings(),S.log("Startup","Initializing EmoteModule"),window.emotePromise=Y.init().then(()=>{Y.initialized=!0,S.log("Startup","Initializing QuickEmoteMenu"),J.init()}),this.injectExternals(),await this.checkForGuilds(),z.initialize(),S.log("Startup","Updating Settings"),Re.initializeSettings(),S.log("Startup","Loading Plugins"),P.loadPlugins(),S.log("Startup","Loading Themes"),B.loadThemes(),$("#customcss").detach().appendTo(document.head),window.addEventListener("beforeunload",(function(){l["bda-dc-0"]&&document.querySelector(".btn.btn-disconnect").click()})),Y.autoCapitalize(),S.log("Startup","Removing Loading Icon"),document.getElementsByClassName("bd-loaderv2").length&&document.getElementsByClassName("bd-loaderv2")[0].remove(),S.log("Startup","Initializing Main Observer"),this.initObserver(),l["fork-ps-1"]&&(S.log("Startup","Collecting Startup Errors"),S.showContentErrors({plugins:d,themes:u}));const t=V.getBDData("version");r>t&&(a&&this.showChangelogModal(a),V.setBDData("version",r)),S.suppressErrors(this.patchSocial.bind(this),"BD Social Patch")(),S.suppressErrors(this.patchGuildPills.bind(this),"BD Guild Pills Patch")(),S.suppressErrors(this.patchGuildListItems.bind(this),"BD Guild List Items Patch")(),S.suppressErrors(this.patchGuildSeparator.bind(this),"BD Guild Separator Patch")()},qe.prototype.checkForGuilds=function(){let e=0;return new Promise(t=>{const n=function(){const s=z.guildClasses.wrapper.split(" ")[0];document.querySelectorAll(`.${s}`).length>0&&e++;const o=z.guildClasses.listItem.split(" ")[0],r=z.guildClasses.blobContainer.split(" ")[0];return document.querySelectorAll(`.${s} .${o} .${r}`).length>0||e>=50?t(h.deferLoaded=!0):void setTimeout(n,100)};$(document).ready((function(){setTimeout(n,100)}))})},qe.prototype.injectExternals=async function(){await S.injectJs("https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.9/ace.js"),window.require.original&&(window.require=window.require.original)},qe.prototype.initSettings=function(){if(V.initialize(),V.getSettingGroup("settings")){Re.loadSettings(),$(''),$("#customcss").text(this.editor.session.getValue()).detach().appendTo(document.head)}saveCss(){V.setBDData("bdcustomcss",btoa(this.editor.session.getValue()))}}class Ae extends z.reactComponent{constructor(e){super(e);this.props.lines=0,this.setInitialState(),this.attach=this.attach.bind(this),this.detachedEditor=z.react.createElement(Le,{attach:this.attach}),this.onClick=this.onClick.bind(this),this.updateCss=this.updateCss.bind(this),this.saveCss=this.saveCss.bind(this),this.detach=this.detach.bind(this)}setInitialState(){this.state={detached:this.props.detached||z.editorDetached}}componentDidMount(){this.editor=ace.edit("bd-customcss-editor"),this.editor.setTheme("ace/theme/monokai"),this.editor.session.setMode("ace/mode/css"),this.editor.setShowPrintMargin(!1),this.editor.setFontSize(14),this.editor.on("change",()=>{l["bda-css-0"]&&(this.saveCss(),this.updateCss())})}componentWillUnmount(){this.editor.destroy()}componentDidUpdate(e,t){const n=this;t.detached&&!n.state.detached&&z.reactDom.unmountComponentAtNode(n.detachedRoot)}codeMirror(){}get options(){return{lineNumbers:!0,mode:"css",indentUnit:4,theme:"material",scrollbarStyle:"simple"}}get css(){const e=V.getBDData("bdcustomcss");let t="";return e&&""!==e&&(t=atob(e)),t}updateLineCount(){const e=this.refs.editor.value.split("\n").length;e!=this.props.lines&&(this.refs.lines.textContent=Array.from(new Array(e),(e,t)=>t+1).join(".\n")+".",this.props.lines=e)}render(){const e=this,{detached:t}=e.state;return z.react.createElement("div",{className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default",style:{padding:"60px 40px 0px"}},t&&z.react.createElement("div",{id:"editor-detached"},z.react.createElement(fe,{text:"Custom CSS Editor"}),z.react.createElement("h3",null,"Editor Detached"),z.react.createElement("button",{className:"btn btn-primary",onClick:()=>{e.attach()}},"Attach")),!t&&z.react.createElement("div",null,z.react.createElement(fe,{text:"Custom CSS Editor"}),z.react.createElement("div",{className:"editor-wrapper"},z.react.createElement("div",{id:"bd-customcss-editor",className:"editor",ref:"editor"},e.css)),z.react.createElement("div",{id:"bd-customcss-attach-controls"},z.react.createElement("ul",{className:"checkbox-group"},z.react.createElement(Fe,{id:"live-update",text:"Live Update",onChange:this.onChange,checked:l["bda-css-0"]})),z.react.createElement("div",{id:"bd-customcss-detach-controls-button"},z.react.createElement("button",{style:{borderRadius:"3px 0 0 3px",borderRight:"1px solid #3f4146"},className:"btn btn-primary",onClick:()=>{e.onClick("update")}},"Update"),z.react.createElement("button",{style:{borderRadius:"0",borderLeft:"1px solid #2d2d2d",borderRight:"1px solid #2d2d2d"},className:"btn btn-primary",onClick:()=>{e.onClick("save")}},"Save"),z.react.createElement("button",{style:{borderRadius:"0 3px 3px 0",borderLeft:"1px solid #3f4146"},className:"btn btn-primary",onClick:()=>{e.onClick("detach")}},"Detach"),z.react.createElement("span",{style:{fontSize:"10px",marginLeft:"5px"}},"Unsaved changes are lost on detach"),z.react.createElement("div",{className:"help-text"},"Press ",z.react.createElement("code",{className:"inline"},"ctrl"),"+",z.react.createElement("span",{className:"inline"},",")," with the editor focused to access the editor's settings.")))))}onClick(e){const t=this;switch(e){case"update":t.updateCss();break;case"save":t.saveCss();break;case"detach":t.detach()}}onChange(e,t){switch(e){case"live-update":l["bda-css-0"]=t,Re.saveSettings()}}updateCss(){0==$("#customcss").length&&$("head").append(''),$("#customcss").text(this.editor.session.getValue()).detach().appendTo(document.head)}saveCss(){V.setBDData("bdcustomcss",btoa(this.editor.session.getValue()))}detach(){this.setState({detached:!0});const e=this.detachedRoot;e?z.reactDom.render(this.detachedEditor,e):console.log("FAILED TO INJECT ROOT: .app")}get detachedRoot(){const e=$("#bd-customcss-detach-container");return e.length?e[0]:this.injectDetachedRoot()?this.detachedRoot:null}injectDetachedRoot(){return!!$(".app, .app-2rEoOp").length&&($("
",{id:"bd-customcss-detach-container"}).insertAfter($(".app, .app-2rEoOp")),!0)}attach(){this.setState({detached:!1})}}class Ie extends z.reactComponent{constructor(e){super(e)}static get displayName(){return"ContentColumn"}render(){return z.react.createElement("div",{className:"contentColumn-2hrIYH contentColumnDefault-1VQkGM content-column default"},z.react.createElement("h2",{className:"ui-form-title h2 margin-reset margin-bottom-20"},this.props.title),this.props.children)}}var Re=new class{constructor(){this.sideBarOnClick=this.sideBarOnClick.bind(this),this.onChange=this.onChange.bind(this),this.updateSettings=this.updateSettings.bind(this),this.sidebar=new ne(this.sideBarOnClick)}get root(){const e=$("#bd-settingspane-container");return e.length?e[0]:this.injectRoot()?this.root:null}injectRoot(){if(!$(".layer-3QrUeG .standardSidebarView-3F1I7i, .layer-3QrUeG .ui-standard-sidebar-view").length)return!1;const e=$("
",{class:"contentRegion-3nDuYy content-region",id:"bd-settingspane-container"});return $(".layer-3QrUeG .standardSidebarView-3F1I7i, .layer-3QrUeG .ui-standard-sidebar-view").append(e),S.onRemoved(e[0],()=>{z.reactDom.unmountComponentAtNode(e[0])}),!0}get coreSettings(){const e=this.getSettings("core");return[...new Set(e.map(e=>e.category))].map(t=>({title:t,settings:e.filter(e=>e.category==t)}))}get emoteSettings(){return this.getSettings("emote")}getSettings(e){return Object.keys(i).reduce((t,n)=>{const s=i[n];return s.cat===e&&s.implemented&&!s.hidden&&(s.text=n,t.push(s)),t},[])}sideBarOnClick(e){const t=this;switch($(".contentRegion-3nDuYy, .content-region").first().hide(),$(t.root).show(),e){case"core":t.renderCoreSettings();break;case"emotes":t.renderEmoteSettings();break;case"customcss":t.renderCustomCssEditor();break;case"plugins":t.renderPluginPane();break;case"themes":t.renderThemePane()}}onClick(){}onChange(e,t){this.updateSettings(e,t)}updateSettings(e,t){if(l[e]=t,"fork-beta"==e)try{const e=n(0),s=n(2).join(DiscordNative.process.remote.resourcesPath,"app","betterdiscord","config.json"),o=require(s);t?(o.branch="modularize",o.minified=!1):(o.branch="master",o.minified=!0),e.writeFileSync(s,JSON.stringify(o,null,4))}catch(e){console.error(e)}"bda-gs-2"==e&&(t?$("body").addClass("bd-minimal"):$("body").removeClass("bd-minimal")),"bda-gs-3"==e&&(t?$("body").addClass("bd-minimal-chan"):$("body").removeClass("bd-minimal-chan")),"bda-gs-1"==e&&(t?ye.addButton():ye.removeButton()),"bda-gs-4"==e&&(t?ke.enable():ke.disable()),"bda-gs-5"==e&&(t?$("#app-mount").addClass("bda-dark"):$("#app-mount").removeClass("bda-dark")),t&&"bda-gs-6"==e&&oe.inject24Hour(),"bda-gs-7"==e&&(t?se.injectColoredText():se.removeColoredText()),"bda-es-4"==e&&(t?Y.autoCapitalize():Y.disableAutoCapitalize()),"fork-ps-4"==e&&(t?Ee.start():Ee.stop()),"fork-ps-5"==e&&(t?(q.watchContent("plugin"),q.watchContent("theme")):(q.unwatchContent("plugin"),q.unwatchContent("theme"))),"bda-gs-8"==e&&(t?Se.enable(l["fork-dm-1"]):Se.disable()),"fork-dm-1"==e&&l["bda-gs-8"]&&Se.enable(t),this.saveSettings()}async initializeSettings(){l["bda-gs-2"]&&$("body").addClass("bd-minimal"),l["bda-gs-3"]&&$("body").addClass("bd-minimal-chan"),l["bda-gs-1"]&&ye.addButton(),l["bda-gs-4"]&&ke.enable(),l["bda-gs-5"]&&$("#app-mount").addClass("bda-dark"),l["bda-gs-6"]&&oe.inject24Hour(),l["bda-gs-7"]&&se.injectColoredText(),l["bda-es-4"]&&Y.autoCapitalize(),l["fork-ps-4"]&&Ee.start(),l["fork-ps-5"]&&(q.watchContent("plugin"),q.watchContent("theme")),l["bda-gs-8"]&&Se.enable(l["fork-dm-1"]),(async()=>{const e=z.WebpackModules.findByUniqueProperties(["getSortedGuilds"]),t=z.WebpackModules.findByUniqueProperties(["getMember"]),n=e.getFlattenedGuildIds().includes("292141134614888448"),s=z.UserStore.getCurrentUser().id,o=t.getMember("292141134614888448",s);!(!n||!o)&&o.roles.includes("452687773678436354")&&(i["BBD Beta"].hidden=!1)})(),this.saveSettings()}saveSettings(){V.setSettingGroup("settings",l)}loadSettings(){Object.assign(l,V.getSettingGroup("settings"))}renderSidebar(){const e=this;$("[class*='side-'] > [class*='item-']").off("click.v2settingspanel").on("click.v2settingspanel",()=>{z.reactDom.unmountComponentAtNode(e.root),$(e.root).hide(),$(".contentRegion-3nDuYy, .content-region").first().show()}),e.sidebar.render()}get coreComponent(){return z.react.createElement(me,{contentColumn:!0,fade:!0,dark:!0,children:[z.react.createElement(Oe,{key:"cspanel",onChange:this.onChange,sections:this.coreSettings}),z.react.createElement(he,{key:"tools"})]})}get emoteComponent(){return z.react.createElement(me,{contentColumn:!0,fade:!0,dark:!0,children:[z.react.createElement(je,{key:"espanel",title:"Emote Settings",onChange:this.onChange,settings:this.emoteSettings,button:{title:"Clear Emote Cache",onClick:()=>{Y.clearEmoteData(),Y.init(),J.init()}}}),z.react.createElement(he,{key:"tools"})]})}get customCssComponent(){return z.react.createElement(me,{contentColumn:!0,fade:!0,dark:!0,children:[z.react.createElement(Ae,{key:"csseditor"}),z.react.createElement(he,{key:"tools"})]})}contentComponent(e){const t="plugins"==e?this.pluginsComponent:this.themesComponent,n=e.replace("s",""),s=this;class o extends z.react.Component{constructor(e){super(e),this.onChange=this.onChange.bind(this)}componentDidMount(){D.on(`${n}-reloaded`,this.onChange),D.on(`${n}-loaded`,this.onChange),D.on(`${n}-unloaded`,this.onChange)}componentWillUnmount(){D.off(`${n}-reloaded`,this.onChange),D.off(`${n}-loaded`,this.onChange),D.off(`${n}-unloaded`,this.onChange)}onChange(){s.sideBarOnClick(e)}render(){return t}}return z.react.createElement(o)}get pluginsComponent(){const e=Object.keys(w).sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())).reduce((e,t)=>(e.push(z.react.createElement(Ne,{key:t,plugin:w[t].plugin})),e),[]),t=z.react.createElement(De,{key:"plugin-list",className:"bda-slist",children:e}),s=!l["fork-ps-5"]&&z.react.createElement($e(Te,{color:"black",side:"top",text:"Reload Plugin List"}),{className:"bd-reload-header",size:"18px",onClick:async()=>{P.updatePluginList(),this.sideBarOnClick("plugins")}}),o=z.react.createElement("button",{key:"folder-button",className:"bd-pfbtn",onClick:()=>{n(1).shell.openItem(q.pluginsFolder)}},"Open Plugin Folder"),r=z.react.createElement(Ie,{key:"pcolumn",title:"Plugins",children:[s,o,t]});return z.react.createElement(me,{contentColumn:!0,fade:!0,dark:!0,children:[r,z.react.createElement(he,{key:"tools"})]})}get themesComponent(){const e=Object.keys(k).sort((e,t)=>e.toLowerCase().localeCompare(t.toLowerCase())).reduce((e,t)=>(e.push(z.react.createElement(Pe,{key:t,theme:k[t]})),e),[]),t=z.react.createElement(De,{key:"theme-list",className:"bda-slist",children:e}),s=!l["fork-ps-5"]&&z.react.createElement($e(Te,{color:"black",side:"top",text:"Reload Theme List"}),{className:"bd-reload-header",size:"18px",onClick:async()=>{B.updateThemeList(),this.sideBarOnClick("themes")}}),o=z.react.createElement("button",{key:"folder-button",className:"bd-pfbtn",onClick:()=>{n(1).shell.openItem(q.themesFolder)}},"Open Theme Folder"),r=z.react.createElement(Ie,{key:"tcolumn",title:"Themes",children:[s,o,t]});return z.react.createElement(me,{contentColumn:!0,fade:!0,dark:!0,children:[r,z.react.createElement(he,{key:"tools"})]})}renderCoreSettings(){const e=this.root;e?z.reactDom.render(this.coreComponent,e):console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i")}renderEmoteSettings(){const e=this.root;e?z.reactDom.render(this.emoteComponent,e):console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i")}renderCustomCssEditor(){const e=this.root;e?z.reactDom.render(this.customCssComponent,e):console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i")}renderPluginPane(){const e=this.root;e?z.reactDom.render(this.contentComponent("plugins"),e):console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i")}renderThemePane(){const e=this.root;e?z.reactDom.render(this.contentComponent("themes"),e):console.log("FAILED TO LOCATE ROOT: .layer-3QrUeG .standardSidebarView-3F1I7i")}};class _e extends z.reactComponent{render(){return z.react.createElement("svg",{height:"100%",width:this.props.size||"16px",className:"bd-logo "+this.props.className,style:{fillRule:"evenodd",clipRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"},viewBox:"0 0 2000 2000"},z.react.createElement("metadata",null),z.react.createElement("defs",null,z.react.createElement("filter",{id:"shadow1"},z.react.createElement("feDropShadow",{dx:"20",dy:"0",stdDeviation:"20","flood-color":"rgba(0,0,0,0.35)"})),z.react.createElement("filter",{id:"shadow2"},z.react.createElement("feDropShadow",{dx:"15",dy:"0",stdDeviation:"20","flood-color":"rgba(255,255,255,0.15)"})),z.react.createElement("filter",{id:"shadow3"},z.react.createElement("feDropShadow",{dx:"10",dy:"0",stdDeviation:"20","flood-color":"rgba(0,0,0,0.35)"}))),z.react.createElement("g",null,z.react.createElement("path",{style:{filter:"url(#shadow3)"},d:"M1195.44+135.442L1195.44+135.442L997.6+136.442C1024.2+149.742+1170.34+163.542+1193.64+179.742C1264.34+228.842+1319.74+291.242+1358.24+365.042C1398.14+441.642+1419.74+530.642+1422.54+629.642L1422.54+630.842L1422.54+632.042C1422.54+773.142+1422.54+1228.14+1422.54+1369.14L1422.54+1370.34L1422.54+1371.54C1419.84+1470.54+1398.24+1559.54+1358.24+1636.14C1319.74+1709.94+1264.44+1772.34+1193.64+1821.44C1171.04+1837.14+1025.7+1850.54+1000+1863.54L1193.54+1864.54C1539.74+1866.44+1864.54+1693.34+1864.54+1296.64L1864.54+716.942C1866.44+312.442+1541.64+135.442+1195.44+135.442Z",fill:"#171717",opacity:"1"}),z.react.createElement("path",{style:{filter:"url(#shadow2)"},d:"M1695.54+631.442C1685.84+278.042+1409.34+135.442+1052.94+135.442L361.74+136.442L803.74+490.442L1060.74+490.442C1335.24+490.442+1335.24+835.342+1060.74+835.342L1060.74+1164.84C1150.22+1164.84+1210.53+1201.48+1241.68+1250.87C1306.07+1353+1245.76+1509.64+1060.74+1509.64L361.74+1863.54L1052.94+1864.54C1409.24+1864.54+1685.74+1721.94+1695.54+1368.54C1695.54+1205.94+1651.04+1084.44+1572.64+999.942C1651.04+915.542+1695.54+794.042+1695.54+631.442Z",fill:"#3E82E5",opacity:"1"}),z.react.createElement("path",{style:{filter:"url(#shadow1)"},d:"M1469.25+631.442C1459.55+278.042+1183.05+135.442+826.65+135.442L135.45+135.442L135.45+1004C135.45+1004+135.427+1255.21+355.626+1255.21C575.825+1255.21+575.848+1004+575.848+1004L577.45+490.442L834.45+490.442C1108.95+490.442+1108.95+835.342+834.45+835.342L664.65+835.342L664.65+1164.84L834.45+1164.84C923.932+1164.84+984.244+1201.48+1015.39+1250.87C1079.78+1353+1019.47+1509.64+834.45+1509.64L135.45+1509.64L135.45+1864.54L826.65+1864.54C1182.95+1864.54+1459.45+1721.94+1469.25+1368.54C1469.25+1205.94+1424.75+1084.44+1346.35+999.942C1424.75+915.542+1469.25+794.042+1469.25+631.442Z",fill:"#FFFFFF",opacity:"1"})))}}function qe(e){Object.assign(h,e)}qe.prototype.init=async function(){if(h.version
Please download the latest version from GitHub");if(window.ED)return void S.alert("Not Supported","BandagedBD does not work with EnhancedDiscord. Please uninstall one of them.");if(window.WebSocket&&window.WebSocket.name&&window.WebSocket.name.includes("Patched"))return void S.alert("Not Supported","BandagedBD does not work with Powercord. Please uninstall one of them.");const e=h.updater?h.updater.LatestVersion:h.latestVersion;e>h.version&&S.alert("Update Available",`\n An update for BandagedBD is available (${e})! Please Reinstall!

\n Download Installer\n `),S.log("Startup","Initializing Settings"),this.initSettings(),S.log("Startup","Initializing EmoteModule"),window.emotePromise=Y.init().then(()=>{Y.initialized=!0,S.log("Startup","Initializing QuickEmoteMenu"),J.init()}),this.injectExternals(),await this.checkForGuilds(),z.initialize(),S.log("Startup","Updating Settings"),Re.initializeSettings(),S.log("Startup","Loading Plugins"),P.loadPlugins(),S.log("Startup","Loading Themes"),B.loadThemes(),$("#customcss").detach().appendTo(document.head),window.addEventListener("beforeunload",(function(){l["bda-dc-0"]&&document.querySelector(".btn.btn-disconnect").click()})),Y.autoCapitalize(),S.log("Startup","Removing Loading Icon"),document.getElementsByClassName("bd-loaderv2").length&&document.getElementsByClassName("bd-loaderv2")[0].remove(),S.log("Startup","Initializing Main Observer"),this.initObserver(),l["fork-ps-1"]&&(S.log("Startup","Collecting Startup Errors"),S.showContentErrors({plugins:d,themes:u}));const t=V.getBDData("version");r>t&&(a&&this.showChangelogModal(a),V.setBDData("version",r)),S.suppressErrors(this.patchSocial.bind(this),"BD Social Patch")(),S.suppressErrors(this.patchGuildPills.bind(this),"BD Guild Pills Patch")(),S.suppressErrors(this.patchGuildListItems.bind(this),"BD Guild List Items Patch")(),S.suppressErrors(this.patchGuildSeparator.bind(this),"BD Guild Separator Patch")()},qe.prototype.checkForGuilds=function(){let e=0;return new Promise(t=>{const n=function(){const s=z.guildClasses.wrapper.split(" ")[0];document.querySelectorAll(`.${s}`).length>0&&e++;const o=z.guildClasses.listItem.split(" ")[0],r=z.guildClasses.blobContainer.split(" ")[0];return document.querySelectorAll(`.${s} .${o} .${r}`).length>0||e>=50?t(h.deferLoaded=!0):void setTimeout(n,100)};$(document).ready((function(){setTimeout(n,100)}))})},qe.prototype.injectExternals=async function(){await S.injectJs("https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.9/ace.js"),window.require.original&&(window.require=window.require.original)},qe.prototype.initSettings=function(){if(V.initialize(),V.getSettingGroup("settings")){Re.loadSettings(),$('