option to not use remote server
This commit is contained in:
parent
259cbf26d1
commit
09127bbeeb
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -93,7 +93,7 @@ export const settings = {
|
|||
"Calling Ring Beat": {id: "lightcord-2", info: "Enable Discord's special calling beat.", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
|
||||
"Developer Options": {id: "lightcord-1", info: "Enable Discord's Internal Developer Options. This allow the \"Experiments\" tab and the \"Developer Options\" tab. (must close and reopen settings)", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
|
||||
"Ad Block": {id: "lightcord-4", info: "Block any BOT that dm you with an invite link. Even in an embed.", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
|
||||
"Enable Lightcord Servers": {id: "lightcord-5", info: "Disabling it erase any informations about you in our servers. But you won't see anything like custom badges.", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
|
||||
"Enable Lightcord Servers": {id: "lightcord-5", info: "Enable Lightcord's servers. Disabling this will disable custom badges.", implemented: true, hidden: false, cat: "lightcord", category: "Lightcord"},
|
||||
|
||||
/** Lightcord Window */
|
||||
"Always-on-Top": {id: "lightcord-3", info: "Enable window's Always-on-Top mode, where Lightcord stays on top of other applications.", implemented: true, hidden: false, cat: "lightcord", category: "Window"},
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
import {settingsCookie, settingsRPC, defaultRPC} from "../0globals";
|
||||
import BDV2 from "./v2";
|
||||
import Utils from "./utils";
|
||||
import {settingsRPC, defaultRPC} from "../0globals";
|
||||
|
||||
const dispatcher = BDModules.get(m=>m.Dispatcher&&m.default&&m.default.dispatch)[0].default
|
||||
const ActionTypes = BDModules.get(m=>m.ActionTypes)[0].ActionTypes
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import BugHunterBadge from "../svg/bug_hunter"
|
||||
import LightcordUserBadge from "../svg/LightcordUser";
|
||||
import nodeFetch from "node-fetch"
|
||||
import { settingsCookie } from "../0globals";
|
||||
|
||||
export function uuidv4() { // Generate UUID (No crypto rng)
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
||||
|
@ -67,7 +68,7 @@ export default new class DistantServer {
|
|||
}
|
||||
const fetchedBadges = await new Promise((resolve) => {
|
||||
badgesToFetch.push([user, resolve])
|
||||
setImmediate(() => {
|
||||
setTimeout(() => {
|
||||
let users = badgesToFetch
|
||||
if(users.length === 0)return
|
||||
badgesToFetch = []
|
||||
|
@ -90,7 +91,7 @@ export default new class DistantServer {
|
|||
data[1]([])// resolve no badge fetched
|
||||
})
|
||||
})
|
||||
})
|
||||
}, 0)
|
||||
})
|
||||
for(let badge of fetchedBadges){
|
||||
if(!Constants.badges.find(e => e.id === badge))continue // We do not have the Component, skip it.
|
||||
|
@ -111,6 +112,10 @@ export default new class DistantServer {
|
|||
}
|
||||
|
||||
const handleRequest = function(route, method, data){
|
||||
if(!settingsCookie["lightcord-5"]){
|
||||
console.warn(`Canceling request on ${route} with method ${method} and body`, data, "because of settings.")
|
||||
return Promise.reject(new LightcordError("The current settings blocked the request."))
|
||||
}
|
||||
console.log(`Sending request on ${route} with method ${method} and body`, data)
|
||||
return nodeFetch(`${Constants.SERVER_URL}/api/v1${route}`, {
|
||||
method,
|
||||
|
@ -124,6 +129,14 @@ const handleRequest = function(route, method, data){
|
|||
})
|
||||
}
|
||||
|
||||
class LightcordError extends Error {
|
||||
constructor(){
|
||||
super(...arguments)
|
||||
this.name = "LightcordError"
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
export const Constants = {
|
||||
SERVER_URL: "http://127.0.0.1",
|
||||
badges: [
|
||||
|
|
|
@ -194,6 +194,7 @@ async function privateInit(){
|
|||
|
||||
require("../../../../../LightcordApi/js/main")
|
||||
|
||||
/*
|
||||
if(shouldShowPrompt){
|
||||
let onConn = (ev) => {
|
||||
console.log(`Showing auth window.`, ev)
|
||||
|
@ -262,7 +263,7 @@ async function privateInit(){
|
|||
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.js").default)(BetterDiscordConfig)
|
||||
|
||||
|
|
Loading…
Reference in New Issue