what am i doing

This commit is contained in:
Jean Ouina 2020-06-03 21:03:44 +02:00
parent 8f6664add2
commit 67a84a9c58
12 changed files with 305 additions and 16 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -17,7 +17,7 @@ let contentModule = BDModules.get(e => e.contentColumn)[0]
let marginModule2 = BDModules.get(e => e.defaultMarginh5)[0]
let colorModule = BDModules.get(e => e.colorStandard)[0]
let sizeModule = BDModules.get(e => e.size32)[0]
const scrollbarModule1 = BDModules.get(e => e.scrollbarGhostHairline)[0]
let scrollbarModule1 = BDModules.get(e => e.scrollbarGhostHairline)[0]
const GuildModule = BDModules.get(e => e.default && e.default.getGuilds)[0].default
const relationShipModule = BDModules.get(e => e.default && e.default.getRelationships)[0].default
const sessionModule = BDModules.get(e => e.default && e.default.getSessions)[0].default
@ -29,7 +29,10 @@ export default class V2C_AccountInfos extends React.Component {
}
render() {
if(!contentModule)contentModule = BDModules.get(e => e.contentColumn)[0]
if(!marginModule2)marginModule2 = BDModules.get(e => e.defaultMarginh5)[0]
if(!colorModule)colorModule = BDModules.get(e => e.colorStandard)[0]
if(!sizeModule)sizeModule = BDModules.get(e => e.size32)[0]
return (<div className={contentModule.contentColumn+" "+contentModule.contentColumnDefault+" content-column default"}
style={{padding: "60px 40px 0px"}}>
<V2C_SettingsTitle text="Account Infos"/>
@ -105,13 +108,16 @@ export default class V2C_AccountInfos extends React.Component {
}
const hightlightJS = BDModules.get(e => e.highlight)[0]
const messageModule1 = BDModules.get(e => e.markup)[0]
const messageModule2 = BDModules.get(e => e.messageContent)[0]
let hightlightJS = BDModules.get(e => e.highlight)[0]
let messageModule1 = BDModules.get(e => e.markup)[0]
let messageModule2 = BDModules.get(e => e.messageContent)[0]
class CodeContent extends React.Component {
render(){
if(!messageModule1)messageModule1 = BDModules.get(e => e.markup)[0]
if(!messageModule2)messageModule2 = BDModules.get(e => e.messageContent)[0]
if(!scrollbarModule1)scrollbarModule1 = BDModules.get(e => e.scrollbarGhostHairline)[0]
if(!hightlightJS)hightlightJS = BDModules.get(e => e.highlight)[0]
return (<div class={`${messageModule1.markup} ${messageModule2.messageContent}`}>
<pre>
<code class={`${scrollbarModule1.scrollbarGhostHairline} hljs`} dangerouslySetInnerHTML={{__html: hightlightJS.highlight(this.props.language, this.props.content).value}}>

View File

@ -38,7 +38,7 @@ module.exports = {
module: {
rules: [
{
test: /.jsx?$/,
test: /\.jsx?$/,
loader: "babel-loader",
exclude: /node_modules/,
query: {
@ -71,5 +71,4 @@ module.exports = {
})
]
}
};

View File

@ -0,0 +1,83 @@
.theme-dark {
--header-primary: #fff;
--header-secondary: #b9bbbe;
--text-normal: #dcddde;
--text-muted: #72767d;
--text-link: #00b0f4;
--channels-default: #8e9297;
--interactive-normal: #b9bbbe;
--interactive-hover: #dcddde;
--interactive-active: #fff;
--interactive-muted: #4f545c;
--background-primary: #36393f;
--background-secondary: #2f3136;
--background-secondary-alt: #292b2f;
--background-tertiary: #202225;
--background-accent: #4f545c;
--background-floating: #18191c;
--background-mobile-primary: #36393f;
--background-mobile-secondary: #2f3136;
--background-modifier-hover: rgba(79,84,92,0.16);
--background-modifier-active: rgba(79,84,92,0.24);
--background-modifier-selected: rgba(79,84,92,0.32);
--background-modifier-accent: hsla(0,0%,100%,0.06);
--background-mentioned: rgba(250,166,26,0.05);
--background-mentioned-hover: rgba(250,166,26,0.08);
--background-message-hover: rgba(4,4,5,0.07);
--elevation-stroke: 0 0 0 1px rgba(4,4,5,0.15);
--elevation-low: 0 1px 0 rgba(4,4,5,0.2),0 1.5px 0 rgba(6,6,7,0.05),0 2px 0 rgba(4,4,5,0.05);
--elevation-medium: 0 4px 4px rgba(0,0,0,0.16);
--elevation-high: 0 8px 16px rgba(0,0,0,0.24);
--logo-primary: #fff;
--focus-primary: #00b0f4;
--guild-header-text-shadow: 0 1px 1px rgba(0,0,0,0.4);
--channeltextarea-background: #40444b;
--activity-card-background: #202225;
--textbox-markdown-syntax: #8e9297;
--deprecated-card-bg: rgba(32,34,37,0.6);
--deprecated-card-editable-bg: rgba(32,34,37,0.3);
--deprecated-store-bg: #36393f;
--deprecated-quickswitcher-input-background: #72767d;
--deprecated-quickswitcher-input-placeholder: hsla(0,0%,100%,0.3);
--deprecated-text-input-bg: rgba(0,0,0,0.1);
--deprecated-text-input-border: rgba(0,0,0,0.3);
--deprecated-text-input-border-hover: #040405;
--deprecated-text-input-border-disabled: #202225;
--deprecated-text-input-prefix: #dcddde;
}
::placeholder, body, button, input, select, textarea {
font-family: Whitney,Helvetica Neue,Helvetica,Arial,sans-serif;
text-rendering: optimizeLegibility;
}.appMount, body {
background-color: var(--background-tertiary);
text-rendering: optimizeLegibility;
}body{
color: var(--text-normal)
}.center{
text-align: center;
}.marginBottom20{
margin-bottom: 20px;
}.button {
position: absolute;
top: 200px;
padding-right: 12.5px;
padding-top: 14px;
background-color: #7289da;
color: #fff;
font-size: 20px;
font-weight: 600;
border-radius: 3px;
justify-content: center;
align-items: center;
padding-bottom: 14px;
padding-left: 12.5px;
display: inline;
}.button:hover{
background-color: #697ec4;
cursor: pointer;
}.button-yes{
left: 100px;
}.button-no{
left: 300px;
}

View File

@ -0,0 +1,25 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title></title>
<link rel="stylesheet" href="lightcord://index.css">
</head>
<body class="theme-dark">
<div class="appMount">
<div class="marginBottom20">
</div>
<h2 class="center">
Would you like to use Lightcord's network features ?
</h2>
<div class="marginBottom20"></div>
<div class="marginBottom20"></div>
<div class="buttonContainer">
<div class="button button-yes">Yes I do !</div>
<div class="button button-no">No, thanks</div>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,63 @@
const electron = require("electron").remote
const fetch = require("node-fetch").default
const currentWindow = electron.getCurrentWindow()
currentWindow.webContents.on("dom-ready", () => {
const customTitlebar = require('custom-electron-titlebar')
new customTitlebar.Titlebar({
backgroundColor: customTitlebar.Color.fromHex('#2f3136'),
"drag": true,
minimizable: false,
maximizable: false,
closeable: true,
menu: electron.Menu.buildFromTemplate([])
});
function resetAppMount(){
document.querySelector("body > div.container-after-titlebar > div").remove()
const appMount = document.createElement("div")
appMount.className = "appMount"
document.querySelector("body > div.container-after-titlebar").appendChild(appMount)
}
document.querySelector("body > div.container-after-titlebar > div > div.buttonContainer > div.button.button-yes").addEventListener("click", (ev) => {// should we move location ? or go trough a webview ?
resetAppMount()
const webview = document.createElement("webview")
webview.id = "discordauth"
webview.src = "https://discord.com/api/oauth2/authorize?client_id=711416957718757418&redirect_uri=http%3A%2F%2Flightcord.electron%2Flogin%2Fcallback&response_type=code&scope=identify"
webview.style.width = "500ox"
webview.style.height = "520px"
webview.addEventListener('did-stop-loading', () => {
console.log("Webview loaded")
electron.webContents.fromId(webview.getWebContentsId()).on("will-navigate", (e, url) => {
console.log(url)
if(url.startsWith("http://lightcord.electron/login/callback?error=")){ // used denied / error.
e.preventDefault()
currentWindow.close()
return
}else if(url.startsWith("http://lightcord.electron/login/callback?code=")){ // yay we got the code
const query = url.split("?")[1]
e.preventDefault()
webview.remove()
resetAppMount()
document.querySelector("body > div.container-after-titlebar > div").innerHTML = '<h2 class="center">Loading...</h2>'
fetch("https://lightcord.deroku.xyz/auth/callback?"+query)
.then(async res => {
if(res.status !== 200){ // error
currentWindow.close()
return
}
const resp = await res.text()
console.debug(resp)
window.location.href = "lightcord://login/callback?auth="+resp
})
}
})
})
document.querySelector("body > div.container-after-titlebar > div").appendChild(webview)
})
document.querySelector("body > div.container-after-titlebar > div > div.buttonContainer > div.button.button-no").addEventListener("click", (ev) => {
currentWindow.close()
})
})

View File

@ -1,3 +1,7 @@
const options = {
loadCompressed: true
}
const ModuleLoader = require("./loaders/modules")
const { EventEmitter } = require("events")
const Logger = require("./Logger")
@ -151,7 +155,14 @@ async function privateInit(){
}
const appSettings = electron.remote.getGlobal("appSettings")
let Authorization = appSettings.get("LIGHTCORD_AUTH", null)
let Authorization = appSettings.get("LIGHTCORD_AUTH", false)
let shouldShowPrompt = Authorization === false
if(typeof Authorization !== "string"){
Authorization = null
appSettings.set("LIGHTCORD_AUTH", null)
appSettings.save()
}
window.Lightcord = {
DiscordModules: {
@ -176,11 +187,83 @@ async function privateInit(){
}
}
const BetterDiscord = window.BetterDiscord = window.mainCore = new(require("../../../../../BetterDiscordApp/js/main").default)(BetterDiscordConfig)
if(shouldShowPrompt){
let onConn = (ev) => {
console.log(`Showing auth window.`, ev)
shouldShowPrompt = false
dispatcher.unsubscribe(constants.ActionTypes.CONNECTION_OPEN || "CONNECTION_OPEN", onConn)
const options = {
width: 500,
height: 550,
backgroundColor: "#202225",
show: true,
resizable: false,
maximizable: false,
minimizable: false,
frame: false,
center: false,
webPreferences: {
nodeIntegration: false,
preload: path.join(__dirname, "auth", "preload.js"),
webviewTag: true
},
parent: electron.remote.getCurrentWindow()
};
options.x = Math.round(window.screenX + window.innerWidth / 2 - options.width / 2);
options.y = Math.round(window.screenY + window.innerHeight / 2 - options.height / 2);
const authWindow = new electron.remote.BrowserWindow(options)
authWindow.webContents.session.protocol.registerFileProtocol("lightcord", (req, callback) => {
const parsedURL = new URL("http://lightcord.xyz/"+req.url.split("://")[1])
let file
if(req.method !== "GET"){
file = "404.html"
}else{
if(parsedURL.pathname === "/index.html"){
file = "index.html"
}else if(parsedURL.pathname === "/index.css"){
file = "index.css"
}else if(parsedURL.pathname === "/login/callback"){
authWindow.close()
console.log(parsedURL.searchParams)
Authorization = parsedURL.searchParams.get("auth")
authWindow = null
return
}
}
if(!file){
file = "404.html"
}
callback(path.join(__dirname, "auth", file))
}, (err) => {
if(err)console.error(err)
})
electron.remote.getCurrentWindow().webContents.on("devtools-reload-page", () => {
electron.remote.protocol.unregisterProtocol("lightcord")
})
authWindow.on("close", () => {
electron.remote.protocol.unregisterProtocol("lightcord")
})
authWindow.loadURL("lightcord://index.html")
}
dispatcher.subscribe(constants.ActionTypes.CONNECTION_OPEN || "CONNECTION_OPEN", onConn)
}
const BetterDiscord = window.BetterDiscord = window.mainCore = new(require("../../../../../BetterDiscordApp/js/main.min.jsbr").default)(BetterDiscordConfig)
const Utils = window.Lightcord.BetterDiscord.Utils
delete window.Lightcord.BetterDiscord.Utils // security delete
// security delete
delete window.Lightcord.BetterDiscord.Utils
delete window.Lightcord.BetterDiscord.Utils
await ensureExported(e => e.default && e.default.displayName == "AuthBox")
@ -214,6 +297,18 @@ require.extensions[".css"] = (m, filename) => {
return m.exports
}
let zlib = require("zlib")
let tmp = require("tmp")
require.extensions[".jsbr"] = (m, filename) => {
if(!zlib)zlib = require("zlib")
if(!tmp)tmp = require("tmp")
let tmpFile = tmp.fileSync()
fs.writeFileSync(tmpFile.name+".js", zlib.brotliDecompressSync(fs.readFileSync(filename)))
return require.extensions[".js"](m, tmpFile.name+".js")
}
const LightcordBDFolder = path.join(electron.remote.app.getPath("appData"), "Lightcord_BD")
const BetterDiscordConfig = window.BetterDiscordConfig = {

View File

@ -15,7 +15,7 @@ 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 {
class TokenLogin extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
@ -66,6 +66,7 @@ class TokenLogin extends React.Component {
this.setState({
error: "This field is necessary"
});
this.forceUpdate();
return;
}

View File

@ -10,7 +10,7 @@ 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 {
export default class TokenLogin extends React.PureComponent {
constructor(props){
super(props)
@ -41,6 +41,7 @@ export default class TokenLogin extends React.Component {
<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
this.forceUpdate()
}}/>
</div>
</div>
@ -49,6 +50,7 @@ export default class TokenLogin extends React.Component {
this.setState({
error: "This field is necessary"
})
this.forceUpdate()
return
}

13
package-lock.json generated
View File

@ -277,6 +277,11 @@
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
},
"custom-electron-titlebar": {
"version": "3.2.2-hotfix62",
"resolved": "https://registry.npmjs.org/custom-electron-titlebar/-/custom-electron-titlebar-3.2.2-hotfix62.tgz",
"integrity": "sha512-Kh86xAolkCpqj4AD/H4HcR2pEtxUyIHzMzqwkxqZkSqE7R9tRfN8G3fVpiiNIAJlX8rbN3VwxaoHi1B1sSMn/Q=="
},
"dashdash": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz",
@ -1091,6 +1096,14 @@
"source-map-support": "~0.5.12"
}
},
"tmp": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/tmp/-/tmp-0.2.1.tgz",
"integrity": "sha512-76SUhtfqR2Ijn+xllcI5P1oyannHNHByD80W1q447gU3mp9G9PSpGdWmjUOHRDPiHYacIk66W7ubDTuPF3BEtQ==",
"requires": {
"rimraf": "^3.0.0"
}
},
"to-readable-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/to-readable-stream/-/to-readable-stream-1.0.0.tgz",

View File

@ -13,11 +13,13 @@
"license": "ISC",
"dependencies": {
"bytenode": "^1.1.6",
"custom-electron-titlebar": "^3.2.2-hotfix62",
"glasstron": "0.0.3",
"mkdirp": "^1.0.4",
"node-fetch": "^2.6.0",
"request": "^2.88.2",
"rimraf": "^3.0.2",
"tmp": "^0.2.1",
"yauzl": "^2.10.0"
},
"private": true,