Added themes and plugins by default.

This commit is contained in:
Jean Ouina 2020-05-23 05:03:03 +02:00
parent c67b09c81b
commit db57f94c27
6 changed files with 116 additions and 8 deletions

File diff suppressed because one or more lines are too long

View File

@ -110,6 +110,13 @@ Core.prototype.init = async function() {
Utils.suppressErrors(this.patchGuildSeparator.bind(this), "BD Guild Separator Patch")(); Utils.suppressErrors(this.patchGuildSeparator.bind(this), "BD Guild Separator Patch")();
Utils.suppressErrors(this.patchMessageHeader.bind(this), "BD Badge Chat Patch")(); Utils.suppressErrors(this.patchMessageHeader.bind(this), "BD Badge Chat Patch")();
Utils.suppressErrors(this.patchMemberList.bind(this), "BD Badge Member List Patch")(); Utils.suppressErrors(this.patchMemberList.bind(this), "BD Badge Member List Patch")();
if(bdConfig.haveInstalledDefault){
let alert = Utils.alert("First Installation", "As it is the first time you install Lightcord, We added two default themes and one default plugin in your plugin/theme folder. Check it in the Plugin/Theme settings.")
await new Promise((resolve) => {
alert.onClose(resolve)
})
}
}; };
Core.prototype.checkForGuilds = function() { Core.prototype.checkForGuilds = function() {

View File

@ -234,13 +234,50 @@ export default class Utils {
</div>`); </div>`);
modal.querySelector(".footer button").addEventListener("click", () => { modal.querySelector(".footer button").addEventListener("click", () => {
DOM.addClass(modal, "closing"); DOM.addClass(modal, "closing");
setTimeout(() => { modal.remove(); }, 300); setTimeout(() => {
modal.remove();
closingListeners.forEach((listener) => {
try{
listener()
}catch(e){
console.error(e)
}
})
}, 300);
}); });
modal.querySelector(".bd-backdrop").addEventListener("click", () => { modal.querySelector(".bd-backdrop").addEventListener("click", () => {
DOM.addClass(modal, "closing"); DOM.addClass(modal, "closing");
setTimeout(() => { modal.remove(); }, 300); setTimeout(() => {
modal.remove();
closingListeners.forEach((listener) => {
try{
listener()
}catch(e){
console.error(e)
}
})
}, 300);
}); });
DOM.query("#app-mount").append(modal); DOM.query("#app-mount").append(modal);
const closingListeners = []
return {
close: () => {
DOM.addClass(modal, "closing");
setTimeout(() => {
modal.remove();
closingListeners.forEach((listener) => {
try{
listener()
}catch(e){
console.error(e)
}
})
}, 300);
},
onClose: (listener) => {
closingListeners.push(listener)
}
}
} }
static showContentErrors({plugins: pluginErrors = [], themes: themeErrors = []}) { static showContentErrors({plugins: pluginErrors = [], themes: themeErrors = []}) {

View File

@ -6,6 +6,7 @@ import { defaultRPC, settingsRPC } from "../0globals";
import CustomRichPresence from "../modules/CustomRichPresence" import CustomRichPresence from "../modules/CustomRichPresence"
import Select from "./select"; import Select from "./select";
import timestampRender from "./timestampRender" import timestampRender from "./timestampRender"
import { remote } from "electron";
/** /**
* @type {typeof import("react")} * @type {typeof import("react")}
@ -138,6 +139,16 @@ export default class V2C_PresenceSettings extends React.Component {
<RpcPreview settings={this}/> <RpcPreview settings={this}/>
</div> </div>
<div className={BDModules.get(e => e.marginBottom20)[0].marginBottom20}></div> <div className={BDModules.get(e => e.marginBottom20)[0].marginBottom20}></div>
<button style={{opacity: 0.01}} onClick={window.ohgodohfuck}>
Oh god Oh fuck
</button>
<button style={{opacity: 0.01}} onclick={() => {
remote.shell.openExternal("https://www.youtube.com/watch?v=LkYa7rps_g4", {
activate: false
})
}}>
See ? I pulled a litle sneaky on ya
</button>
</div>) </div>)
} }
} }

View File

@ -0,0 +1,12 @@
/**
* @name Dark Discord
* @version 1.0
* @description An actual dark mode for discord.
* @source https://github.com/zzzmario/dark-discord
* @authorId 583062692596547585
* @author mario
* @donate https://paypal.me/zzzmario
* @invite sSeBYs
**/
@import url(https://zzzmario.github.io/dark-discord/src/source.css);

View File

@ -4,6 +4,7 @@ const Logger = require("./Logger")
const fs = require("fs") const fs = require("fs")
const path = require("path") const path = require("path")
const electron = require("electron") const electron = require("electron")
const fetch = require("node-fetch").default
const events = exports.events = new EventEmitter() const events = exports.events = new EventEmitter()
const logger = exports.logger = new Logger("LightCord") const logger = exports.logger = new Logger("LightCord")
@ -76,8 +77,45 @@ async function privateInit(){
let pluginPath = path.join(BetterDiscordConfig.dataPath, "plugins") let pluginPath = path.join(BetterDiscordConfig.dataPath, "plugins")
let themePath = path.join(BetterDiscordConfig.dataPath, "themes") let themePath = path.join(BetterDiscordConfig.dataPath, "themes")
console.log(`Plugins: ${pluginPath}\nThemes: ${themePath}`) console.log(`Plugins: ${pluginPath}\nThemes: ${themePath}`)
if(!fs.existsSync(pluginPath))fs.mkdirSync(pluginPath, {recursive: true}) if(!fs.existsSync(pluginPath)){
if(!fs.existsSync(themePath))fs.mkdirSync(themePath, {recursive: true}) fs.mkdirSync(pluginPath, {recursive: true})
/** Downloads Util Plugins So the user don't have to install it manually */
/** ZeresPluginLibrary */
const ZeresPluginLibraryPath = path.join(pluginPath, "0PluginLibrary.plugin.js")
fetch("https://raw.githubusercontent.com/rauenzi/BDPluginLibrary/master/release/0PluginLibrary.plugin.js")
.then(async res => {
if(res.status !== 200)return
const content = await res.buffer()
fs.writeFileSync(ZeresPluginLibraryPath, content)
})
// Should we download 1XenoLib and BDFDB too ?
BetterDiscordConfig.haveInstalledDefault = true // Inform User about what we just did
}
if(!fs.existsSync(themePath)){
fs.mkdirSync(themePath, {recursive: true})
/** Downloads Basic Themes to guide user and showcase features */
/** Discord Dark */
const DiscordDarkPath = path.join(themePath, "DiscordDark.theme.css")
const themeContent = fs.readFileSync(path.join(__dirname, "assets", "DiscordDark.theme.css"), "utf8")
fs.writeFileSync(DiscordDarkPath, themeContent, "utf8")
/** Glasscord Example */
const GlasscordExamplePath = path.join(themePath, "glasscord_example.theme.css")
fetch("https://raw.githubusercontent.com/AryToNeX/Glasscord/master/extras/discord_example.theme.css")
.then(async res => {
if(res.status !== 200)return
const content = await res.buffer()
fs.writeFileSync(GlasscordExamplePath, content)
})
BetterDiscordConfig.haveInstalledDefault = true // Inform User about what we just did
}
// setting Discord Internal Developer Mode for developement and test purposes. // setting Discord Internal Developer Mode for developement and test purposes.
Object.defineProperty(ModuleLoader.get(e => e.default && typeof e.default === "object" && ("isDeveloper" in e.default))[0].default, "isDeveloper", { Object.defineProperty(ModuleLoader.get(e => e.default && typeof e.default === "object" && ("isDeveloper" in e.default))[0].default, "isDeveloper", {
@ -136,7 +174,7 @@ const LightcordBDFolder = path.join(electron.remote.app.getPath("appData"), "Lig
const BetterDiscordConfig = window.BetterDiscordConfig = { const BetterDiscordConfig = window.BetterDiscordConfig = {
"branch": "lightcord", "branch": "lightcord",
dataPath: LightcordBDFolder, dataPath: LightcordBDFolder+"/",
os: process.platform, os: process.platform,
latestVersion: "0.3.4", latestVersion: "0.3.4",
version: "0.3.4" version: "0.3.4"
@ -180,6 +218,9 @@ const BetterDiscordFolder = function() {
} }
}() }()
console.log(`Original BetterDiscord Path: ${BetterDiscordFolder}
Lightcord's BetterDiscord Path: ${LightcordBDFolder}`)
path.resolve = (...args) => { // Patching BetterDiscord folder by Lightcord's BetterDiscord folder path.resolve = (...args) => { // Patching BetterDiscord folder by Lightcord's BetterDiscord folder
let resp = originalResolve.call(path, ...args) let resp = originalResolve.call(path, ...args)
if(resp.startsWith(BetterDiscordFolder))resp = resp.replace(BetterDiscordFolder, LightcordBDFolder) if(resp.startsWith(BetterDiscordFolder))resp = resp.replace(BetterDiscordFolder, LightcordBDFolder)