diff --git a/gulpfile.js b/gulpfile.js index f04400f0..70d7b2f2 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,30 +1,13 @@ const gulp = require("gulp"); const rename = require("gulp-rename"); -const minify = require("gulp-babel-minify"); const csso = require("gulp-csso"); -gulp.task("minify-js", minifyJS); gulp.task("minify-css", minifyCSS); -gulp.task("watch-js", function() { - return gulp.watch(["./js/main.js"], minifyJS); -}); - gulp.task("watch-css", function() { return gulp.watch(["./css/main.css"], minifyCSS); }); -gulp.task("watch", function() { - return gulp.watch(["./js/main.js", "./css/main.css"], gulp.series(minifyJS, minifyCSS)); -}); - -function minifyJS() { - return gulp.src("./js/main.js") - .pipe(minify({mangle: {keepClassName: true}})) - .pipe(rename("main.min.js")) - .pipe(gulp.dest("./js")); -} - function minifyCSS() { return gulp.src("./css/main.css") .pipe(csso({restructure: false})) diff --git a/js/main.js b/js/main.js index e057ad86..f7795008 100644 --- a/js/main.js +++ b/js/main.js @@ -3080,20 +3080,37 @@ const releaseChannel = DiscordNative.globals.releaseChannel; // Schema 1 /* harmony default export */ __webpack_exports__["default"] = (new class DataStore { constructor() { - this.data = {}; + this.data = { + misc: {} + }; this.pluginData = {}; } initialize() { - if (!fs.existsSync(path.resolve(this.BDFile, ".."))) fs.mkdirSync(path.resolve(this.BDFile, "..")); - if (!fs.existsSync(this.BDFile)) fs.writeFileSync(this.BDFile, JSON.stringify(this.data, null, 4)); - this.data = require(this.BDFile); // if (data.hasOwnProperty("settings")) this.data = data; + if (!fs.existsSync(this.baseFolder)) fs.mkdirSync(this.baseFolder); + if (!fs.existsSync(this.dataFolder)) fs.mkdirSync(this.dataFolder); + if (!fs.existsSync(this.BDFile)) fs.writeFileSync(this.BDFile, JSON.stringify(this.data.misc, null, 4)); + const dataFiles = fs.readdirSync(this.dataFolder).filter(f => !fs.statSync(path.resolve(this.dataFolder, f)).isDirectory() && f.endsWith(".json")); + + for (const file of dataFiles) { + this.data[file.split(".")[0]] = require(path.resolve(this.dataFolder, file)); + } // this.data = __non_webpack_require__(this.BDFile); + // if (data.hasOwnProperty("settings")) this.data = data; // if (!fs.existsSync(this.settingsFile)) return; // let settings = __non_webpack_require__(this.settingsFile); // fs.unlinkSync(this.settingsFile); // if (settings.hasOwnProperty("settings")) settings = Object.assign({stable: {}, canary: {}, ptb: {}}, {[releaseChannel]: settings}); // else settings = Object.assign({stable: {}, canary: {}, ptb: {}}, settings); // this.setBDData("settings", settings); + + } + + get baseFolder() { + return this._baseFolder || (this._baseFolder = path.resolve(data__WEBPACK_IMPORTED_MODULE_0__["Config"].dataPath, "data")); + } + + get dataFolder() { + return this._dataFolder || (this._dataFolder = path.resolve(this.baseFolder, `${releaseChannel}`)); } get BDFile() { @@ -3112,22 +3129,28 @@ const releaseChannel = DiscordNative.globals.releaseChannel; // Schema 1 // } + _getFile(key) { + if (key == "settings" || key == "plugins" || key == "themes") return path.resolve(this.dataFolder, `${key}.json`); + return path.resolve(this.dataFolder, `misc.json`); + } + getBDData(key) { - return this.data[key] || ""; + return this.data.misc[key] || ""; } setBDData(key, value) { - this.data[key] = value; - fs.writeFileSync(this.BDFile, JSON.stringify(this.data, null, 4)); + this.data.misc[key] = value; + fs.writeFileSync(path.resolve(this.dataFolder, `misc.json`), JSON.stringify(this.data.misc, null, 4)); } getData(key) { - return this.data[key] || ""; + return this.data[key] || ""; // return JSON.parse(fs.readFileSync(path.resolve(this.dataFolder, `${file}.json`))); } setData(key, value) { - this.data[key] = value; - fs.writeFileSync(this.BDFile, JSON.stringify(this.data, null, 4)); + this.data[key] = value; // fs.writeFileSync(this.BDFile, JSON.stringify(this.data, null, 4)); + + fs.writeFileSync(path.resolve(this.dataFolder, `${key}.json`), JSON.stringify(value, null, 4)); } getPluginData(pluginName, key) { @@ -3814,7 +3837,20 @@ PluginModule.prototype.rawObserver = function (e) { } }; -/* harmony default export */ __webpack_exports__["default"] = (new PluginModule()); +/* harmony default export */ __webpack_exports__["default"] = (new PluginModule()); // makePlaceholderPlugin(data) { +// return {plugin: { +// start: () => {}, +// getName: () => {return data.name || data.filename;}, +// getAuthor: () => {return "???";}, +// getDescription: () => {return data.message ? data.message : "This plugin was unable to be loaded. Check the author's page for updates.";}, +// getVersion: () => {return "???";} +// }, +// name: data.name || data.filename, +// filename: data.filename, +// source: data.source ? data.source : "", +// website: data.website ? data.website : "" +// }; +// } /***/ }), @@ -4028,7 +4064,6 @@ __webpack_require__.r(__webpack_exports__); onSettingChange(collection, category, id, value) { const before = this.config.filter(c => c.disabled).length; this.state[collection][category][id] = value; - console.log(this.state); _emitter__WEBPACK_IMPORTED_MODULE_4__["default"].dispatch("setting-updated", collection, category, id, value); const after = this.config.filter(c => c.disabled).length; this.saveSettings(); diff --git a/js/main.min.js b/js/main.min.js index 83746ad9..fe04bd0e 100644 --- a/js/main.min.js +++ b/js/main.min.js @@ -1 +1 @@ -var Core=function(e){var t={};function n(s){if(t[s])return t[s].exports;var o=t[s]={i:s,l:!1,exports:{}};return e[s].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,s){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(s,o,function(t){return e[t]}.bind(null,o));return s},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t){e.exports=require("fs")},function(e,t){e.exports=require("path")},function(e,t){e.exports=require("electron")},function(e,t){e.exports=require("module")},function(e,t){e.exports=require("events")},function(e,t){e.exports=require("request")},function(e,t,n){"use strict";n.r(t);var s={};n.r(s),n.d(s,"Menu",function(){return be}),n.d(s,"Card",function(){return fe}),n.d(s,"Layer",function(){return ye});var o={};n.r(o),n.d(o,"VoiceMode",function(){return $e}),n.d(o,"ClassNormalizer",function(){return Ne}),n.d(o,"DeveloperMode",function(){return je}),n.d(o,"PublicServers",function(){return Fe}),n.d(o,"DarkMode",function(){return Oe}),n.d(o,"MinimalMode",function(){return Ae}),n.d(o,"TwentyFourHour",function(){return Ie}),n.d(o,"ColoredText",function(){return Re}),n.d(o,"VoiceDisconnect",function(){return Ge}),n.d(o,"EmoteMenu",function(){return He}),n.d(o,"EmoteAutocaps",function(){return ze}),n.d(o,"EmoteModule",function(){return Ue});var r={emotesLoaded:!1},i={"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"},"BetterDiscord Blue":{id:"bda-gs-b",info:"Replace Discord blue with BD Blue",implemented:!1,hidden:!1,cat:"core"},"Public Servers":{id:"bda-gs-1",info:"Display public servers button",implemented:!0,hidden:!1,cat:"core",category:"modules"},"Minimal Mode":{id:"bda-gs-2",info:"Hide elements and reduce the size of elements.",implemented:!0,hidden:!1,cat:"core",category:"modules"},"Voice Mode":{id:"bda-gs-4",info:"Only show voice chat",implemented:!0,hidden:!1,cat:"core",category:"modules"},"Hide Channels":{id:"bda-gs-3",info:"Hide channels in minimal mode",implemented:!0,hidden:!1,cat:"core",category:"modules"},"Dark Mode":{id:"bda-gs-5",info:"Make certain elements dark by default(wip)",implemented:!0,hidden:!1,cat:"core",category:"modules"},"Voice Disconnect":{id:"bda-dc-0",info:"Disconnect from voice server when closing Discord",implemented:!0,hidden:!1,cat:"core",category:"modules"},"24 Hour Timestamps":{id:"bda-gs-6",info:"Replace 12hr timestamps with proper ones",implemented:!0,hidden:!1,cat:"core",category:"modules"},"Coloured Text":{id:"bda-gs-7",info:"Make text colour the same as role colour",implemented:!0,hidden:!1,cat:"core",category:"modules"},"Normalize Classes":{id:"fork-ps-4",info:"Adds stable classes to elements to help themes. (e.g. adds .da-channels to .channels-Ie2l6A)",implemented:!0,hidden:!1,cat:"core",category:"modules"},"Content Error Modal":{id:"fork-ps-1",info:"Shows a modal with plugin/theme errors",implemented:!0,hidden:!1,cat:"core",category:"content manager"},"Show Toasts":{id:"fork-ps-2",info:"Shows a small notification for important information",implemented:!0,hidden:!1,cat:"core",category:"content manager"},"Scroll To Settings":{id:"fork-ps-3",info:"Auto-scrolls to a plugin's settings when the button is clicked (only if out of view)",implemented:!0,hidden:!1,cat:"core",category:"content manager"},"Automatic Loading":{id:"fork-ps-5",info:"Automatically loads, reloads, and unloads plugins and themes",implemented:!0,hidden:!1,cat:"core",category:"content manager"},"Developer Mode":{id:"bda-gs-8",info:"Developer Mode",implemented:!0,hidden:!1,cat:"core",category:"developer settings"},"Copy Selector":{id:"fork-dm-1",info:'Adds a "Copy Selector" option to context menus when developer mode is active',implemented:!0,hidden:!1,cat:"core",category:"developer settings"},"Enable Transparency":{id:"fork-wp-1",info:"Enables the main window to be see-through (requires restart)",implemented:!0,hidden:!1,cat:"core",category:"window preferences"},"Window Frame":{id:"fork-wp-2",info:"Adds the native os window frame to the main window",implemented:!1,hidden:!0,cat:"core",category:"window preferences"},"Download Emotes":{id:"fork-es-3",info:"Download emotes when the cache is expired",implemented:!0,hidden:!1,cat:"emote"},"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 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 (flip, spin, pulse, spin2, spin3, 1spin, 2spin, 3spin, tr, bl, br, shake, shake2, shake3, flap)",implemented:!0,hidden:!1,cat:"emote"},"Animate On Hover":{id:"fork-es-2",info:"Only animate the emote modifiers on hover",implemented:!0,hidden:!1,cat:"emote"}},a={"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-4":!1,"bda-es-6":!0,"bda-es-7":!0,"bda-gs-b":!1,"bda-es-8":!0,"bda-dc-0":!1,"bda-css-0":!1,"bda-css-1":!1,"bda-es-9":!0,"fork-dm-1":!1,"fork-ps-1":!0,"fork-ps-2":!0,"fork-ps-3":!0,"fork-ps-4":!0,"fork-ps-5":!0,"fork-es-2":!1,"fork-es-3":!0,"fork-wp-1":!1,"fork-wp-2":!1},l={local:!1,localServer:"//localhost:8080",minified:!0,version:"0.3.0",branch:"master",repo:"rauenzi",minSupportedVersion:"0.3.0",bbdVersion:"0.2.17"},c={},d={},u={},h={},p={TwitchGlobal:{},TwitchSubscriber:{},BTTV:{},FrankerFaceZ:{},BTTV2:{}},m=[],g=["flip","spin","pulse","spin2","spin3","1spin","2spin","3spin","tr","bl","br","shake","shake2","shake3","flap"],f=["twitch","bttv","ffz"];class b{static get screenWidth(){return Math.max(document.documentElement.clientWidth,window.innerWidth||0)}static get screenHeight(){return Math.max(document.documentElement.clientHeight,window.innerHeight||0)}static stripBOM(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}static getTextArea(){return $(".channelTextArea-1LDbYG textarea")}static getInternalInstance(e){return e[Object.keys(e).find(e=>e.startsWith("__reactInternalInstance"))]||null}static insertText(e,t){e.focus(),e.selectionStart=0,e.selectionEnd=e.value.length,document.execCommand("insertText",!1,t)}static injectCss(e){$("",{type:"text/css",rel:"stylesheet",href:e}).appendTo($("head"))}static injectJs(e){return new Promise(t=>{$("