mirror of
https://github.com/Lightcord/Lightcord.git
synced 2025-04-12 00:55:40 +02:00
je sais pas ce que j'ai fait, donc je push
This commit is contained in:
parent
81294fc794
commit
d37bac0f10
File diff suppressed because one or more lines are too long
@ -2,8 +2,8 @@ import Utils from "./utils"
|
||||
|
||||
const dispatcher = window.Lightcord.DiscordModules.dispatcher
|
||||
const ChannelModule = BDModules.get(e => e.default && e.default.getChannel && e.default.hasChannel)[0].default
|
||||
const relationShipModule = BDModules.get(e => e.default && e.default.addRelationship)[0].default
|
||||
const DMModule = BDModules.get(e => e.default && e.default.closePrivateChannel)[0].default
|
||||
let relationShipModule = BDModules.get(e => e.default && e.default.addRelationship)[0].default
|
||||
let DMModule = BDModules.get(e => e.default && e.default.closePrivateChannel)[0].default
|
||||
|
||||
const blocked = {}
|
||||
|
||||
@ -43,9 +43,11 @@ export default new class AntiBotDM {
|
||||
Utils.showToast(`[AdBlock]: Blocked ${ev.message.author.username}#${ev.message.author.discriminator}`, {
|
||||
"type": "warning"
|
||||
})
|
||||
if(!relationShipModule)relationShipModule = BDModules.get(e => e.default && e.default.addRelationship)[0].default
|
||||
relationShipModule.addRelationship(ev.message.author.id, {
|
||||
location: "ContextMenu"
|
||||
}, 2)
|
||||
if(!DMModule)DMModule = BDModules.get(e => e.default && e.default.closePrivateChannel)[0].default
|
||||
DMModule.closePrivateChannel(channel.id, false)
|
||||
}
|
||||
}
|
||||
|
@ -54,12 +54,12 @@ export default new class ContentManager {
|
||||
if (this.timeCache[filename] == stats.mtime.getTime()) return;
|
||||
this.timeCache[filename] = stats.mtime.getTime();
|
||||
if (eventType == "rename") {
|
||||
if (isPlugin) pluginModule.loadPlugin(filename);
|
||||
else themeModule.loadTheme(filename);
|
||||
if (isPlugin) await pluginModule.loadPlugin(filename);
|
||||
else await themeModule.loadTheme(filename);
|
||||
}
|
||||
if (eventType == "change") {
|
||||
if (isPlugin) pluginModule.reloadPlugin(filename);
|
||||
else themeModule.reloadTheme(filename);
|
||||
if (isPlugin) await pluginModule.reloadPlugin(filename);
|
||||
else await themeModule.reloadTheme(filename);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -167,7 +167,7 @@ export default new class ContentManager {
|
||||
};
|
||||
}
|
||||
|
||||
loadContent(filename, type) {
|
||||
async loadContent(filename, type) {
|
||||
if (typeof(filename) === "undefined" || typeof(type) === "undefined") return;
|
||||
const isPlugin = type === "plugin";
|
||||
const baseFolder = isPlugin ? this.pluginsFolder : this.themesFolder;
|
||||
@ -209,10 +209,10 @@ export default new class ContentManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
reloadContent(filename, type) {
|
||||
async reloadContent(filename, type) {
|
||||
const cantUnload = this.unloadContent(filename, type);
|
||||
if (cantUnload) return cantUnload;
|
||||
return this.loadContent(filename, type);
|
||||
return await this.loadContent(filename, type);
|
||||
}
|
||||
|
||||
loadNewContent(type) {
|
||||
@ -226,7 +226,7 @@ export default new class ContentManager {
|
||||
return {added, removed};
|
||||
}
|
||||
|
||||
loadAllContent(type) {
|
||||
async loadAllContent(type) {
|
||||
const isPlugin = type === "plugin";
|
||||
const fileEnding = isPlugin ? ".plugin.js" : ".theme.css";
|
||||
const basedir = isPlugin ? this.pluginsFolder : this.themesFolder;
|
||||
@ -235,7 +235,7 @@ export default new class ContentManager {
|
||||
|
||||
for (const filename of files) {
|
||||
if (!fs.statSync(path.resolve(basedir, filename)).isFile() || !filename.endsWith(fileEnding)) continue;
|
||||
const error = this.loadContent(filename, type);
|
||||
const error = await this.loadContent(filename, type);
|
||||
if (error) errors.push(error);
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ import TooltipWrap from "../ui/tooltipWrap";
|
||||
import LightcordLogo from "../svg/lightcord";
|
||||
import PluginCertifier from "./pluginCertifier";
|
||||
import distant, { uuidv4 } from "./distant";
|
||||
import EmojiModule from "./emojiModule"
|
||||
|
||||
function Core() {
|
||||
// Object.assign(bdConfig, __non_webpack_require__(DataStore.configFile));
|
||||
@ -75,10 +76,10 @@ Core.prototype.init = async function() {
|
||||
settingsPanel.initializeSettings();
|
||||
|
||||
Utils.log("Startup", "Loading Plugins");
|
||||
pluginModule.loadPlugins();
|
||||
await pluginModule.loadPlugins();
|
||||
|
||||
Utils.log("Startup", "Loading Themes");
|
||||
themeModule.loadThemes();
|
||||
await themeModule.loadThemes();
|
||||
|
||||
DOM.addStyle("customcss", atob(DataStore.getBDData("bdcustomcss")));
|
||||
|
||||
@ -105,6 +106,8 @@ Core.prototype.init = async function() {
|
||||
DataStore.setBDData("version", bbdVersion);
|
||||
}
|
||||
|
||||
await EmojiModule.init()
|
||||
|
||||
Utils.suppressErrors(this.patchSocial.bind(this), "BD Social Patch")();
|
||||
Utils.suppressErrors(this.patchGuildPills.bind(this), "BD Guild Pills Patch")();
|
||||
Utils.suppressErrors(this.patchGuildListItems.bind(this), "BD Guild List Items Patch")();
|
||||
@ -118,7 +121,15 @@ Core.prototype.init = async function() {
|
||||
await new Promise((resolve) => {
|
||||
alert.onClose(resolve)
|
||||
})
|
||||
}
|
||||
}
|
||||
const logo = document.querySelector("#app-mount > div.typeWindows-1za-n7.withFrame-haYltI.titleBar-AC4pGV.horizontalReverse-3tRjY7.flex-1O1GKY.directionRowReverse-m8IjIq.justifyStart-2NDFzi.alignStretch-DpGPf3.da-typeWindows.da-withFrame.da-titleBar.da-horizontalReverse.da-flex.da-directionRowReverse.da-justifyStart.da-alignStretch > div.wordmarkWindows-1v0lYD.wordmark-2iDDfm.da-wordmarkWindows.da-wordmark")
|
||||
if(logo){
|
||||
logo.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" height="10" width="70" viewBox="0 0 72.54 10" style="margin-left: -5px, margin-top: 10px">
|
||||
<path fill="currentColor" d="M44.81,9.67V6.33c0-1.21,2.13-1.49,2.78-.28l2-.81A3.53,3.53,0,0,0,46.2,3c-1.92,0-3.81,1.13-3.81,3.33V9.67c0,2.21,1.89,3.33,3.77,3.33a3.87,3.87,0,0,0,3.45-2.18l-2.12-1C47,11.17,44.81,10.85,44.81,9.67ZM10.68,12.89h2.41V3.17H10.68ZM71.76,3.14H68.19V7.23L70.57,9.4v-4h1.27c.81,0,1.21.41,1.21,1v3c0,.63-.38,1.05-1.21,1.05H68.18v2.31h3.57c1.92,0,3.72-1,3.72-3.2V6.39C75.48,4.13,73.68,3.14,71.76,3.14ZM54.22,3c-2,0-4,1.1-4,3.34V9.66c0,2.23,2,3.34,4,3.34s3.95-1.11,3.95-3.34V6.34C58.19,4.11,56.2,3,54.22,3Zm1.55,6.66c0,.7-.78,1.06-1.54,1.06s-1.55-.35-1.55-1.06V6.34c0-.72.75-1.1,1.5-1.1s1.59.35,1.59,1.1ZM66.84,6.34c0-2.29-1.58-3.2-3.55-3.2H59.46v9.73h2.45V9.77h.43l2.22,3.09h3L65,9.52C66.13,9.15,66.84,8.14,66.84,6.34ZM63.33,7.65H61.91V5.43h1.42A1.11,1.11,0,1,1,63.33,7.65ZM29.83,13h2.42V3.06H29.83V6.73l-3,0V3.09H24.7v9.78h2.14V8.68l3,0ZM17.16,9.76V6.42c0-1.21,2.13-1.49,2.78-.28l2-.81a3.55,3.55,0,0,0-3.36-2.24c-1.92,0-3.81,1.13-3.81,3.33V9.76c0,2.21,2,3.15,3.9,3.15s3.58-1,3.58-3V7.58H18.79l0,1.36H20.3v.77C20.3,10.92,17.16,10.94,17.16,9.76Z" transform="translate(-2.93 -3)"/>
|
||||
<polygon fill="currentColor" points="35.91 0.06 38.43 0.06 38.43 1.84 35.92 1.81 35.97 10 33.55 10 33.49 1.75 30.98 1.74 30.98 0.06 33.49 0.06 35.91 0.06"/>
|
||||
<polygon fill="currentColor" points="0 9.97 6.5 10 6.5 7.63 2.41 7.63 2.41 0.26 0 2.26 0 9.97"/>
|
||||
</svg>`
|
||||
}
|
||||
};
|
||||
|
||||
Core.prototype.checkForGuilds = function() {
|
||||
|
226
BetterDiscordApp/src/modules/emojiModule.js
Normal file
226
BetterDiscordApp/src/modules/emojiModule.js
Normal file
@ -0,0 +1,226 @@
|
||||
import {bdConfig, settingsCookie} from "../0globals";
|
||||
import DataStore from "./dataStore";
|
||||
import BDV2 from "./v2";
|
||||
import Utils from "./utils";
|
||||
|
||||
const Constants = {
|
||||
EmojiRegex: /<a?\.(\w+)\.(\d+)>/g
|
||||
}
|
||||
|
||||
let CustomEmojiModule = BDModules.get(e => e.CustomEmoji)[0]
|
||||
let EmojiModuleApi = BDModules.get(e => e.default && e.default.getCustomEmojiById)[0]
|
||||
let AutocompleteModule = BDModules.get(e => e.default && e.default.displayName === "Autocomplete")
|
||||
|
||||
export default new class EmojiModule {
|
||||
constructor(){}
|
||||
|
||||
async init(){
|
||||
while (!BDV2.MessageComponent) await new Promise(resolve => setTimeout(resolve, 100));
|
||||
|
||||
if (this.cancelEmojiRender) return;
|
||||
this.cancelEmoteRender = Utils.monkeyPatch(BDV2.MessageComponent, "default", {before: (data) => {
|
||||
const message = Utils.getNestedProp(data.methodArguments[0], "childrenMessageContent.props.message")
|
||||
if(!message)return
|
||||
const content = Utils.getNestedProp(data.methodArguments[0], "childrenMessageContent.props.content")
|
||||
if(!content || !content.length)return
|
||||
|
||||
/**
|
||||
* @type {{
|
||||
* raw: string,
|
||||
* name: string,
|
||||
* id: string,
|
||||
* animated: boolean
|
||||
* }[]}
|
||||
*/
|
||||
let emojis = []
|
||||
|
||||
const newContent = []
|
||||
for(let node of content){
|
||||
if (typeof(node) !== "string") {
|
||||
newContent.push(node)
|
||||
continue
|
||||
};
|
||||
let parsed;
|
||||
let hasParsed = false
|
||||
|
||||
do {
|
||||
parsed = Constants.EmojiRegex.exec(node);
|
||||
if (parsed) {
|
||||
hasParsed = true
|
||||
if(!EmojiModuleApi)EmojiModuleApi = BDModules.get(e => e.default && e.default.getCustomEmojiById)[0]
|
||||
const emoji = EmojiModuleApi.default.getCustomEmojiById(parsed[2])
|
||||
if(emoji){
|
||||
emojis.push({
|
||||
animated: emoji.animated,
|
||||
name: emoji.name,
|
||||
id: emoji.id,
|
||||
raw: parsed[0]
|
||||
})
|
||||
}else{
|
||||
emojis.push({
|
||||
animated: parsed[0].startsWith("<a"),
|
||||
name: parsed[1],
|
||||
id: parsed[2],
|
||||
raw: parsed[0]
|
||||
})
|
||||
}
|
||||
}
|
||||
} while (parsed);
|
||||
|
||||
if(hasParsed){
|
||||
const words = node.split(" ").map((word, index, arr) => {
|
||||
if(!word)return ""
|
||||
const emoji = emojis.find(e => e.raw == word)
|
||||
if(!emoji)return word
|
||||
if(!CustomEmojiModule)CustomEmojiModule = BDModules.get(e => e.CustomEmoji)[0]
|
||||
return React.createElement(CustomEmojiModule.CustomEmoji, {
|
||||
emoji: {
|
||||
name: `.${emoji.name}.`,
|
||||
emojiId: emoji.id,
|
||||
animated: emoji.animated,
|
||||
jumboable: arr.length === 1 && content.length === 1
|
||||
}
|
||||
})
|
||||
}).reduce((previous, current) => {
|
||||
if(previous.length === 0)return [current]
|
||||
if(typeof current === "string"){
|
||||
if(typeof previous[previous.length - 1] === "string"){
|
||||
previous[previous.length - 1] += ` ${current}`
|
||||
return previous
|
||||
}
|
||||
previous.push(" "+current)
|
||||
return previous
|
||||
}
|
||||
previous.push(" ", current)
|
||||
return previous
|
||||
}, [])
|
||||
newContent.push(...words)
|
||||
}else{
|
||||
newContent.push(node)
|
||||
}
|
||||
}
|
||||
while(data.methodArguments[0].childrenMessageContent.props.content[0]){
|
||||
data.methodArguments[0].childrenMessageContent.props.content.shift()
|
||||
}
|
||||
while(newContent[0]){
|
||||
data.methodArguments[0].childrenMessageContent.props.content.push(newContent.shift())
|
||||
}
|
||||
}});
|
||||
|
||||
if(!AutocompleteModule)AutocompleteModule = BDModules.get(e => e.default && e.default.displayName === "Autocomplete")
|
||||
|
||||
}
|
||||
|
||||
disable(){
|
||||
if (this.cancelEmoteRender) return;
|
||||
this.cancelEmoteRender();
|
||||
this.cancelEmoteRender = null;
|
||||
}
|
||||
}
|
||||
/*
|
||||
let loadImageModule = BDModules.get(e => e.loadImage)[0]
|
||||
let getEmojiModule = BDModules.get(e => e.default && e.default.getEmojiURL)[0]
|
||||
|
||||
class Emoji extends React.PureComponent {
|
||||
constructor(props){
|
||||
super(props)
|
||||
this.state = {
|
||||
hover: false
|
||||
}
|
||||
this.key = undefined
|
||||
this.cancelLoadImage = null
|
||||
this.onError = function() {
|
||||
}
|
||||
}
|
||||
|
||||
onError() {
|
||||
var src = this.getSrc();
|
||||
if(src !== null){
|
||||
if(!loadImageModule)loadImageModule = BDModules.get(e => e.loadImage)[0] // lazy load
|
||||
this.cancelLoadImage = loadImageModule.loadImage(src, (e) => {
|
||||
if(!e){
|
||||
this.key = Date.now()
|
||||
this.forceUpdate()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
onMouseEnter(ev) {
|
||||
this.setState({
|
||||
hover: true
|
||||
});
|
||||
var onMouseEnter = this.props.onMouseEnter;
|
||||
if(onMouseEnter)onMouseEnter(ev)
|
||||
}
|
||||
|
||||
onMouseLeave(ev) {
|
||||
this.setState({
|
||||
hover: false
|
||||
});
|
||||
var onMouseLeave = t.props.onMouseLeave;
|
||||
if(onMouseLeave)onMouseLeave(ev)
|
||||
}
|
||||
|
||||
|
||||
componentWillUnmount() {
|
||||
if(this.cancelLoadImage)this.cancelLoadImage()
|
||||
}
|
||||
|
||||
getSrc(defaultProps) {
|
||||
if(!defaultProps)defaultProps = this.props
|
||||
const props = defaultProps
|
||||
const src = props.src
|
||||
const emojiId = props.emojiId
|
||||
const emojiName = props.emojiName
|
||||
const animated = props.animated
|
||||
const shouldAnimate = props.shouldAnimate
|
||||
const isFocused = props.isFocused
|
||||
const hover = this.state.hover
|
||||
|
||||
if(src)return src
|
||||
if(emojiId){
|
||||
if(!getEmojiModule)getEmojiModule = BDModules.get(e => e.default && e.default.getEmojiURL)[0]
|
||||
return getEmojiModule.default.getEmojiURL({
|
||||
id: emojiId,
|
||||
animated: isFocused && animated && (shouldAnimate || hover)
|
||||
})
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
render() {
|
||||
var props = this.props,
|
||||
emojiName = props.emojiName,
|
||||
animated = props.animated,
|
||||
jumboable = props.jumboable,
|
||||
imgProps = {
|
||||
|
||||
}(props.shouldAnimate, props.isFocused, props.emojiId, props.autoplay, y(props, ["emojiName", "animated", "className", "jumboable", "shouldAnimate", "isFocused", "emojiId", "autoplay"])),
|
||||
src = this.getSrc();
|
||||
if(src){
|
||||
return React.createElement("img", Object.assign({}, imgProps, {
|
||||
key: this.key,
|
||||
src,
|
||||
alt: emojiName || undefined,
|
||||
draggable: false
|
||||
}, animated ? {
|
||||
onMouseEnter: this.onMouseEnter,
|
||||
onMouseLeave: this.onMouseLeave
|
||||
} : {}, {
|
||||
className: `emoji${jumboable ? " jumboable" : ""}`,
|
||||
onError: this.onError
|
||||
}))
|
||||
}
|
||||
return React.createElement("span", {
|
||||
className: "emoji emoji-text"
|
||||
}, undefined, emojiName)
|
||||
}
|
||||
}
|
||||
Emoji.displayName = "Emoji";
|
||||
|
||||
function createEmojiComponent(){
|
||||
return React.createElement(Emoji, Object.assign({}, t, {
|
||||
shouldAnimate: t.animated
|
||||
}))
|
||||
}*/
|
@ -187,6 +187,7 @@ function checkViruses(hash, data, id){
|
||||
const hashToUrl = {}
|
||||
|
||||
function processAttachment(attachment, id){
|
||||
if(!document.getElementById(id))return
|
||||
if(!attachment.url.startsWith("https://cdn.discordapp.com/"))return document.getElementById(id).remove()
|
||||
if(!attachment.filename.endsWith(".plugin.js") && !attachment.filename.endsWith(".theme.css"))return document.getElementById(id).remove()
|
||||
|
||||
@ -236,8 +237,8 @@ function processAttachment(attachment, id){
|
||||
}).catch(()=>{})
|
||||
}
|
||||
|
||||
const flowerStarModule = BDModules.get(e => e.flowerStarContainer)[0]
|
||||
const childModule = BDModules.get(e => e.childContainer)[0]
|
||||
let flowerStarModule = BDModules.get(e => e.flowerStarContainer)[0]
|
||||
let childModule = BDModules.get(e => e.childContainer)[0]
|
||||
|
||||
/**
|
||||
*
|
||||
@ -246,8 +247,11 @@ const childModule = BDModules.get(e => e.childContainer)[0]
|
||||
*/
|
||||
function renderToElements(id, result, filename){
|
||||
const div = document.getElementById(id)
|
||||
if(!div || div.childNodes.length > 0)return // already certified, so don't do it.
|
||||
if(!div || div.childNodes.length > 0)return // already certified/div does not exist anymore.
|
||||
// TODO: implements suspect plugins.
|
||||
|
||||
if(!flowerStarModule)flowerStarModule = BDModules.get(e => e.flowerStarContainer)[0]
|
||||
if(!childModule)childModule = BDModules.get(e => e.childContainer)[0]
|
||||
|
||||
if(result.suspect){
|
||||
try{
|
||||
|
@ -8,9 +8,9 @@ class PluginModule {
|
||||
get folder() {return ContentManager.pluginsFolder;}
|
||||
}
|
||||
|
||||
PluginModule.prototype.loadPlugins = function () {
|
||||
PluginModule.prototype.loadPlugins = async function () {
|
||||
this.loadPluginData();
|
||||
bdpluginErrors.splice(0, 0, ...ContentManager.loadPlugins());
|
||||
bdpluginErrors.splice(0, 0, ...(await ContentManager.loadPlugins()));
|
||||
const plugins = Object.keys(bdplugins);
|
||||
for (let i = 0; i < plugins.length; i++) {
|
||||
let plugin, name;
|
||||
@ -19,8 +19,7 @@ PluginModule.prototype.loadPlugins = function () {
|
||||
plugin = bdplugins[plugins[i]].plugin;
|
||||
name = plugin.getName();
|
||||
if (plugin.load && typeof(plugin.load) == "function") plugin.load();
|
||||
}
|
||||
catch (err) {
|
||||
} catch (err) {
|
||||
pluginCookie[name] = false;
|
||||
Utils.err("Plugins", name + " could not be loaded.", err);
|
||||
bdpluginErrors.push({name: name, file: bdplugins[plugins[i]].filename, message: "load() could not be fired.", error: {message: err.message, stack: err.stack}});
|
||||
@ -33,8 +32,7 @@ PluginModule.prototype.loadPlugins = function () {
|
||||
try {
|
||||
plugin.start();
|
||||
if (settingsCookie["fork-ps-2"]) Utils.showToast(`${plugin.getName()} v${plugin.getVersion()} has started.`);
|
||||
}
|
||||
catch (err) {
|
||||
} catch (err) {
|
||||
pluginCookie[name] = false;
|
||||
Utils.err("Plugins", name + " could not be started.", err);
|
||||
bdpluginErrors.push({name: name, file: bdplugins[plugins[i]].filename, message: "start() could not be fired.", error: {message: err.message, stack: err.stack}});
|
||||
@ -102,8 +100,8 @@ PluginModule.prototype.toggle = function (plugin, reload = false) {
|
||||
return this.togglePlugin(plugin, reload);
|
||||
};
|
||||
|
||||
PluginModule.prototype.loadPlugin = function(filename) {
|
||||
const error = ContentManager.loadContent(filename, "plugin");
|
||||
PluginModule.prototype.loadPlugin = async function(filename) {
|
||||
const error = await ContentManager.loadContent(filename, "plugin");
|
||||
if (error) {
|
||||
if (settingsCookie["fork-ps-1"]) Utils.showContentErrors({plugins: [error]});
|
||||
if (settingsCookie["fork-ps-2"]) Utils.showToast(`${filename} could not be loaded.`, {type: "error"});
|
||||
@ -142,13 +140,13 @@ PluginModule.prototype.delete = function(filenameOrName) {
|
||||
require("fs").unlinkSync(fullPath);
|
||||
};
|
||||
|
||||
PluginModule.prototype.reloadPlugin = function(filenameOrName) {
|
||||
PluginModule.prototype.reloadPlugin = async function(filenameOrName) {
|
||||
const bdplugin = Object.values(bdplugins).find(p => p.filename == filenameOrName) || bdplugins[filenameOrName];
|
||||
if (!bdplugin) return this.loadPlugin(filenameOrName);
|
||||
const plugin = bdplugin.plugin.getName();
|
||||
const enabled = pluginCookie[plugin];
|
||||
if (enabled) this.stopPlugin(plugin, true);
|
||||
const error = ContentManager.reloadContent(bdplugins[plugin].filename, "plugin");
|
||||
const error = await ContentManager.reloadContent(bdplugins[plugin].filename, "plugin");
|
||||
if (error) {
|
||||
if (settingsCookie["fork-ps-1"]) Utils.showContentErrors({plugins: [error]});
|
||||
if (settingsCookie["fork-ps-2"]) Utils.showToast(`${plugin} could not be reloaded.`, {type: "error"});
|
||||
|
@ -214,7 +214,15 @@ export default new class V2_SettingsPanel {
|
||||
else window.Lightcord.Settings.callRingingBeat = false
|
||||
}
|
||||
if (id === "lightcord-presence-1") {
|
||||
if (enabled) CustomRichPresence.enable()
|
||||
if (enabled) {
|
||||
CustomRichPresence.enable()
|
||||
const settingsStore = BDModules.get(e => e.default && typeof e.default === "object" && "showCurrentGame" in e.default)[0]
|
||||
if(settingsStore && !settingsStore.default.showCurrentGame){
|
||||
BDModules.get(e => e.default && e.default.updateRemoteSettings)[0].default.updateRemoteSettings({
|
||||
showCurrentGame: true
|
||||
})
|
||||
}
|
||||
}
|
||||
else CustomRichPresence.disable()
|
||||
}
|
||||
if (id === "lightcord-3") {
|
||||
|
@ -9,9 +9,9 @@ class ThemeModule {
|
||||
get folder() {return ContentManager.themesFolder;}
|
||||
}
|
||||
|
||||
ThemeModule.prototype.loadThemes = function () {
|
||||
ThemeModule.prototype.loadThemes = async function () {
|
||||
this.loadThemeData();
|
||||
bdthemeErrors.splice(0, 0, ...ContentManager.loadThemes());
|
||||
bdthemeErrors.splice(0, 0, ...(await ContentManager.loadThemes()));
|
||||
const themes = Object.keys(bdthemes);
|
||||
|
||||
for (let i = 0; i < themes.length; i++) {
|
||||
@ -59,8 +59,8 @@ ThemeModule.prototype.toggle = function (name, reload = false) {
|
||||
return this.toggleTheme(name, reload);
|
||||
};
|
||||
|
||||
ThemeModule.prototype.loadTheme = function(filename) {
|
||||
const error = ContentManager.loadContent(filename, "theme");
|
||||
ThemeModule.prototype.loadTheme = async function(filename) {
|
||||
const error = await ContentManager.loadContent(filename, "theme");
|
||||
if (error) {
|
||||
if (settingsCookie["fork-ps-1"]) Utils.showContentErrors({themes: [error]});
|
||||
if (settingsCookie["fork-ps-2"]) Utils.showToast(`${filename} could not be loaded. It may not have been loaded.`, {type: "error"});
|
||||
@ -97,11 +97,11 @@ ThemeModule.prototype.delete = function(filenameOrName) {
|
||||
require("fs").unlinkSync(fullPath);
|
||||
};
|
||||
|
||||
ThemeModule.prototype.reloadTheme = function(filenameOrName) {
|
||||
ThemeModule.prototype.reloadTheme = async function(filenameOrName) {
|
||||
const bdtheme = Object.values(bdthemes).find(p => p.filename == filenameOrName) || bdthemes[filenameOrName];
|
||||
if (!bdtheme) return this.loadTheme(filenameOrName);
|
||||
const theme = bdtheme.name;
|
||||
const error = ContentManager.reloadContent(bdthemes[theme].filename, "theme");
|
||||
const error = await ContentManager.reloadContent(bdthemes[theme].filename, "theme");
|
||||
if (themeCookie[theme]) this.disableTheme(theme, true), this.enableTheme(theme, true);
|
||||
if (error) {
|
||||
if (settingsCookie["fork-ps-1"]) Utils.showContentErrors({themes: [error]});
|
||||
|
@ -452,4 +452,6 @@ export default class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
Utils.showToast = Utils.suppressErrors(Utils.showToast, "Could not show toast.");
|
||||
Utils.showToast = Utils.suppressErrors(Utils.showToast, "Could not show toast.");
|
||||
|
||||
window.Lightcord.BetterDiscord.Utils = Utils
|
@ -26,12 +26,20 @@ import WebpackModules from "../modules/webpackModules";
|
||||
// Changelog
|
||||
// </div>
|
||||
//</div>
|
||||
const TooltipClasses = WebpackModules.findByProps("tooltip", "tooltipBlack");
|
||||
const TooltipLayers = WebpackModules.findByProps("layer", "layerContainer");
|
||||
let TooltipClasses
|
||||
function getTooltipClasses(){
|
||||
if(TooltipClasses)return TooltipClasses
|
||||
return TooltipClasses = WebpackModules.findByProps("tooltip", "tooltipBlack");
|
||||
}
|
||||
let TooltipLayers
|
||||
function getTooltipLayers(){
|
||||
if(TooltipLayers)return TooltipLayers
|
||||
return TooltipLayers = WebpackModules.findByProps("layer", "layerContainer");
|
||||
}
|
||||
|
||||
const getClass = function(sideOrColor) {
|
||||
const upperCase = sideOrColor[0].toUpperCase() + sideOrColor.slice(1);
|
||||
const tooltipClass = TooltipClasses[`tooltip${upperCase}`];
|
||||
const tooltipClass = getTooltipClasses()[`tooltip${upperCase}`];
|
||||
if (tooltipClass) return tooltipClass;
|
||||
return null;
|
||||
};
|
||||
@ -76,16 +84,16 @@ export default class EmulatedTooltip {
|
||||
if (!classExists(this.style)) return Utils.err("EmulatedTooltip", `Style ${this.style} does not exist.`);
|
||||
|
||||
this.element = document.createElement("div");
|
||||
this.element.className = TooltipLayers.layer + " " + TooltipLayers.disabledPointerEvents;
|
||||
this.element.className = getTooltipLayers().layer + " " + getTooltipLayers().disabledPointerEvents;
|
||||
|
||||
this.tooltipElement = document.createElement("div");
|
||||
this.tooltipElement.className = `${TooltipClasses.tooltip} ${getClass(this.style)}`;
|
||||
this.tooltipElement.className = `${getTooltipClasses().tooltip} ${getClass(this.style)}`;
|
||||
|
||||
this.labelElement = document.createElement("div");
|
||||
this.labelElement.className = TooltipClasses.tooltipContent
|
||||
this.labelElement.className = getTooltipClasses().tooltipContent
|
||||
|
||||
const pointerElement = document.createElement("div");
|
||||
pointerElement.className = TooltipClasses.tooltipPointer;
|
||||
pointerElement.className = getTooltipClasses().tooltipPointer;
|
||||
|
||||
this.tooltipElement.append(pointerElement);
|
||||
this.tooltipElement.append(this.labelElement);
|
||||
@ -134,7 +142,7 @@ export default class EmulatedTooltip {
|
||||
|
||||
/** Shows the tooltip. Automatically called on mouseenter. Will attempt to flip if position was wrong. */
|
||||
show() {
|
||||
this.tooltipElement.className = `${TooltipClasses.tooltip} ${getClass(this.style)}`;
|
||||
this.tooltipElement.className = `${getTooltipClasses().tooltip} ${getClass(this.style)}`;
|
||||
this.labelElement.textContent = this.label;
|
||||
this.container.append(this.element);
|
||||
|
||||
|
5
assets/title.svg
Normal file
5
assets/title.svg
Normal file
@ -0,0 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="16" width="100%" viewBox="0 0 72.54 10">
|
||||
<path d="M44.81,9.67V6.33c0-1.21,2.13-1.49,2.78-.28l2-.81A3.53,3.53,0,0,0,46.2,3c-1.92,0-3.81,1.13-3.81,3.33V9.67c0,2.21,1.89,3.33,3.77,3.33a3.87,3.87,0,0,0,3.45-2.18l-2.12-1C47,11.17,44.81,10.85,44.81,9.67ZM10.68,12.89h2.41V3.17H10.68ZM71.76,3.14H68.19V7.23L70.57,9.4v-4h1.27c.81,0,1.21.41,1.21,1v3c0,.63-.38,1.05-1.21,1.05H68.18v2.31h3.57c1.92,0,3.72-1,3.72-3.2V6.39C75.48,4.13,73.68,3.14,71.76,3.14ZM54.22,3c-2,0-4,1.1-4,3.34V9.66c0,2.23,2,3.34,4,3.34s3.95-1.11,3.95-3.34V6.34C58.19,4.11,56.2,3,54.22,3Zm1.55,6.66c0,.7-.78,1.06-1.54,1.06s-1.55-.35-1.55-1.06V6.34c0-.72.75-1.1,1.5-1.1s1.59.35,1.59,1.1ZM66.84,6.34c0-2.29-1.58-3.2-3.55-3.2H59.46v9.73h2.45V9.77h.43l2.22,3.09h3L65,9.52C66.13,9.15,66.84,8.14,66.84,6.34ZM63.33,7.65H61.91V5.43h1.42A1.11,1.11,0,1,1,63.33,7.65ZM29.83,13h2.42V3.06H29.83V6.73l-3,0V3.09H24.7v9.78h2.14V8.68l3,0ZM17.16,9.76V6.42c0-1.21,2.13-1.49,2.78-.28l2-.81a3.55,3.55,0,0,0-3.36-2.24c-1.92,0-3.81,1.13-3.81,3.33V9.76c0,2.21,2,3.15,3.9,3.15s3.58-1,3.58-3V7.58H18.79l0,1.36H20.3v.77C20.3,10.92,17.16,10.94,17.16,9.76Z" transform="translate(-2.93 -3)"/>
|
||||
<polygon points="35.91 0.06 38.43 0.06 38.43 1.84 35.92 1.81 35.97 10 33.55 10 33.49 1.75 30.98 1.74 30.98 0.06 33.49 0.06 35.91 0.06"/>
|
||||
<polygon points="0 9.97 6.5 10 6.5 7.63 2.41 7.63 2.41 0.26 0 2.26 0 9.97"/>
|
||||
</svg>
|
After Width: | Height: | Size: 1.4 KiB |
@ -9,4 +9,4 @@
|
||||
* @invite sSeBYs
|
||||
**/
|
||||
|
||||
@import url(https://zzzmario.github.io/dark-discord/src/source.css);
|
||||
@import url(https://cdn.jsdelivr.net/gh/hellbound1337/dark-discord/src/source.min.css);
|
@ -169,12 +169,25 @@ async function privateInit(){
|
||||
appSettings.set("LIGHTCORD_AUTH", Authorization = data)
|
||||
appSettings.save()
|
||||
}
|
||||
},
|
||||
BetterDiscord: { // Global BetterDiscord's exported modules
|
||||
|
||||
}
|
||||
}
|
||||
const BetterDiscord = window.BetterDiscord = window.mainCore = new(require("../../../../../BetterDiscordApp/js/main").default)(BetterDiscordConfig)
|
||||
|
||||
const Utils = window.Lightcord.BetterDiscord.Utils
|
||||
|
||||
await ensureExported(e => e.default && e.default.displayName == "AuthBox")
|
||||
|
||||
const classs = BDModules.get(e => e.default && e.default.displayName == "AuthBox")
|
||||
|
||||
Utils.monkeyPatch(classs[0], "default", {after: (data) => {
|
||||
const children = Utils.getNestedProp(data.returnValue, "props.children.props.children.props.children")
|
||||
children.push(React.createElement(require("./tokenLogin").default, {}))
|
||||
}})
|
||||
|
||||
await ensureGuildClasses()
|
||||
|
||||
const BetterDiscord = window.BetterDiscord = window.mainCore = new(require("../../../../../BetterDiscordApp/js/main").default)(BetterDiscordConfig)
|
||||
BetterDiscord.init()
|
||||
|
||||
events.emit("ready")
|
||||
@ -223,6 +236,22 @@ function ensureGuildClasses(){
|
||||
})
|
||||
}
|
||||
|
||||
function ensureExported(filter){
|
||||
return new Promise((resolve) => {
|
||||
let classs = BDModules.get(filter)[0]
|
||||
if(classs)return resolve()
|
||||
|
||||
let intergay = setInterval(() => {
|
||||
classs = BDModules.get(filter)[0]
|
||||
if(classs){
|
||||
clearInterval(intergay)
|
||||
resolve()
|
||||
return
|
||||
}
|
||||
}, 100);
|
||||
})
|
||||
}
|
||||
|
||||
function getGuildClasses() {
|
||||
const guildsWrapper = BDModules.get(e => e.wrapper && e.unreadMentionsBar)[0];
|
||||
const guilds = BDModules.get(e => e.guildsError && e.selected)[0]
|
||||
|
@ -0,0 +1,81 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = void 0;
|
||||
const loginContainerModule = BDModules.get(e => e.mainLoginContainer)[0];
|
||||
const colors = BDModules.get(e => e.colorHeaderPrimary)[0];
|
||||
const sizes = BDModules.get(e => e.size24)[0];
|
||||
const authBoxModule = BDModules.get(e => e.title && typeof e.title === "string" && e.authBoxPadding)[0];
|
||||
const marginModule = BDModules.get(e => e.marginBottom8)[0];
|
||||
const titleModule = BDModules.get(e => e.h5)[0];
|
||||
const inputModule = BDModules.get(e => e.inputWrapper)[0];
|
||||
const contentModule = BDModules.get(e => e.contents)[0];
|
||||
const verticalSeparatorModule = BDModules.get(e => e.verticalSeparator)[0];
|
||||
const loginModule = BDModules.get(e => e.default && e.default.loginToken)[0].default;
|
||||
|
||||
class TokenLogin extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
value: "",
|
||||
error: null
|
||||
};
|
||||
}
|
||||
|
||||
render() {
|
||||
return [/*#__PURE__*/React.createElement("div", {
|
||||
class: verticalSeparatorModule.verticalSeparator
|
||||
}), /*#__PURE__*/React.createElement("div", {
|
||||
className: loginContainerModule.mainLoginContainer
|
||||
}, /*#__PURE__*/React.createElement("div", {
|
||||
className: `${colors.colorHeaderPrimary} ${sizes.size24} ${authBoxModule.title} ${marginModule.marginBottom8}`
|
||||
}, "Connect with Token"), /*#__PURE__*/React.createElement("div", {
|
||||
className: `${colors.colorHeaderSecondary} ${sizes.size16}`
|
||||
}, "Input your token below"), /*#__PURE__*/React.createElement("div", {
|
||||
className: `${authBoxModule.block} ${marginModule.marginTop20}`
|
||||
}, /*#__PURE__*/React.createElement("div", {
|
||||
className: marginModule.marginBottom20
|
||||
}, /*#__PURE__*/React.createElement("h5", {
|
||||
className: `${colors.colorStandard} ${sizes.size14} ${titleModule.h5} ${titleModule.defaultMarginh5}${this.state.error ? " " + titleModule.error : ""}`
|
||||
}, "Token", this.state.error ? /*#__PURE__*/React.createElement("span", {
|
||||
class: titleModule.errorMessage
|
||||
}, /*#__PURE__*/React.createElement("span", {
|
||||
class: titleModule.errorSeparator
|
||||
}, "-"), this.state.error) : null), /*#__PURE__*/React.createElement("div", {
|
||||
className: inputModule.inputWrapper
|
||||
}, /*#__PURE__*/React.createElement("input", {
|
||||
className: `${inputModule.inputDefault}${this.state.error ? " " + inputModule.inputError : ""}`,
|
||||
name: "token",
|
||||
type: "token",
|
||||
placeholder: true,
|
||||
"aria-label": "Token",
|
||||
autoComplete: "off",
|
||||
maxLength: 999,
|
||||
spellCheck: "false",
|
||||
value: this.state.value,
|
||||
onChange: ev => {
|
||||
this.state.value = ev.target.value;
|
||||
}
|
||||
}))), /*#__PURE__*/React.createElement("button", {
|
||||
type: "submit",
|
||||
className: `${marginModule.marginBottom8} ${authBoxModule.button} ${contentModule.button} ${contentModule.lookFilled} ${contentModule.colorBrand} ${contentModule.sizeLarge} ${contentModule.fullWidth} ${contentModule.grow}`,
|
||||
onClick: () => {
|
||||
if (!this.state.value) {
|
||||
this.setState({
|
||||
error: "This field is necessary"
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
loginModule.loginToken(this.state.value);
|
||||
}
|
||||
}, /*#__PURE__*/React.createElement("div", {
|
||||
className: contentModule.contents
|
||||
}, "Login"))))];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.default = TokenLogin;
|
@ -0,0 +1,65 @@
|
||||
const loginContainerModule = BDModules.get(e => e.mainLoginContainer)[0]
|
||||
const colors = BDModules.get(e => e.colorHeaderPrimary)[0]
|
||||
const sizes = BDModules.get(e => e.size24)[0]
|
||||
const authBoxModule = BDModules.get(e => e.title && typeof e.title === "string" && e.authBoxPadding)[0]
|
||||
const marginModule = BDModules.get(e => e.marginBottom8)[0]
|
||||
const titleModule = BDModules.get(e => e.h5)[0]
|
||||
const inputModule = BDModules.get(e => e.inputWrapper)[0]
|
||||
const contentModule = BDModules.get(e => e.contents)[0]
|
||||
const verticalSeparatorModule = BDModules.get(e => e.verticalSeparator)[0]
|
||||
|
||||
const loginModule = BDModules.get(e => e.default && e.default.loginToken)[0].default
|
||||
|
||||
export default class TokenLogin extends React.Component {
|
||||
constructor(props){
|
||||
super(props)
|
||||
|
||||
this.state = {
|
||||
value: "",
|
||||
error: null
|
||||
}
|
||||
}
|
||||
|
||||
render(){
|
||||
return ([
|
||||
<div class={verticalSeparatorModule.verticalSeparator}></div>,
|
||||
<div className={loginContainerModule.mainLoginContainer}>
|
||||
<div className={`${colors.colorHeaderPrimary} ${sizes.size24} ${authBoxModule.title} ${marginModule.marginBottom8}`}>
|
||||
Connect with Token
|
||||
</div>
|
||||
<div className={`${colors.colorHeaderSecondary} ${sizes.size16}`}>
|
||||
Input your token below
|
||||
</div>
|
||||
<div className={`${authBoxModule.block} ${marginModule.marginTop20}`}>
|
||||
<div className={marginModule.marginBottom20}>
|
||||
<h5 className={`${colors.colorStandard} ${sizes.size14} ${titleModule.h5} ${titleModule.defaultMarginh5}${this.state.error ? " "+titleModule.error : ""}`}>
|
||||
Token
|
||||
{this.state.error ? <span class={titleModule.errorMessage}>
|
||||
<span class={titleModule.errorSeparator}>-</span>{this.state.error}
|
||||
</span> : null}
|
||||
</h5>
|
||||
<div className={inputModule.inputWrapper}>
|
||||
<input className={`${inputModule.inputDefault}${this.state.error ? " "+inputModule.inputError : ""}`} name="token" type="token" placeholder aria-label="Token" autoComplete="off" maxLength={999} spellCheck="false" value={this.state.value} onChange={(ev) => {
|
||||
this.state.value = ev.target.value
|
||||
}}/>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" className={`${marginModule.marginBottom8} ${authBoxModule.button} ${contentModule.button} ${contentModule.lookFilled} ${contentModule.colorBrand} ${contentModule.sizeLarge} ${contentModule.fullWidth} ${contentModule.grow}`} onClick={() => {
|
||||
if(!this.state.value){
|
||||
this.setState({
|
||||
error: "This field is necessary"
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
loginModule.loginToken(this.state.value)
|
||||
}}>
|
||||
<div className={contentModule.contents}>
|
||||
Login
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
]);
|
||||
}
|
||||
}
|
@ -6201,8 +6201,19 @@
|
||||
id: "splash"
|
||||
}, r.default.createElement("div", {
|
||||
className: "splash-inner-dl"
|
||||
}, r.default.createElement("div", {
|
||||
}, (Math.floor(Math.random() * 1000) + 1 !== 420) ? r.default.createElement("div", {
|
||||
className: "dice-image"
|
||||
}) : r.default.createElement("iframe", {
|
||||
id: "ytplayer",
|
||||
type: "text/html",
|
||||
width: "300",
|
||||
height: "167",
|
||||
src: "https://www.youtube.com/embed/dQw4w9WgXcQ?autoplay=1", /*😳 */
|
||||
frameborder: "0",
|
||||
style: {
|
||||
marginTop: "-400px",
|
||||
paddingBottom: "10px"
|
||||
}
|
||||
}), r.default.createElement("div", {
|
||||
className: "dl-update-message"
|
||||
}, "Must be your lucky day, there’s a new update!"), r.default.createElement("div", {
|
||||
|
@ -102,13 +102,18 @@ function launchSplashWindow(startMinimized = false) {
|
||||
center: true,
|
||||
show: false,
|
||||
webPreferences: {
|
||||
nodeIntegration: true
|
||||
nodeIntegration: true,
|
||||
|
||||
},
|
||||
icon: path.join(__dirname, "..", "discord.png")
|
||||
};
|
||||
|
||||
splashWindow = new electron.BrowserWindow(windowConfig);
|
||||
|
||||
splashWindow.webContents.session.protocol.interceptFileProtocol('http', (request, callback) => {
|
||||
callback(path.join(__dirname, '..', "splash", request.url.replace('http://localhost/', '')));
|
||||
});
|
||||
|
||||
// prevent users from dropping links to navigate in splash window
|
||||
splashWindow.webContents.on('will-navigate', e => e.preventDefault());
|
||||
|
||||
@ -149,13 +154,7 @@ function launchSplashWindow(startMinimized = false) {
|
||||
launchMainWindowInternal()
|
||||
});
|
||||
|
||||
const splashUrl = url.format({
|
||||
protocol: 'file',
|
||||
slashes: true,
|
||||
pathname: path.join(__dirname, '..', "splash", 'index.html')
|
||||
});
|
||||
|
||||
splashWindow.loadURL(splashUrl);
|
||||
splashWindow.loadURL("http://localhost/index.html");
|
||||
}
|
||||
|
||||
function launchMainWindowInternal() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user