Base connectivity stuff
This commit is contained in:
parent
520366c4ac
commit
7c02a51a46
|
@ -9,3 +9,5 @@ tests/log.txt
|
|||
# User data
|
||||
tests/data
|
||||
user.config.json
|
||||
/.vs
|
||||
/npm-debug.log
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
import { DOM, BdUI, BdMenu, Modals, Reflection, Toasts } from 'ui';
|
||||
import BdCss from './styles/index.scss';
|
||||
import { Events, CssEditor, Globals, Settings, Database, Updater, ModuleManager, PluginManager, ThemeManager, ExtModuleManager, Vendor, WebpackModules, Patcher, MonkeyPatch, ReactComponents, ReactHelpers, ReactAutoPatcher, DiscordApi } from 'modules';
|
||||
import { Events, CssEditor, Globals, Settings, Database, Updater, ModuleManager, PluginManager, ThemeManager, ExtModuleManager, Vendor, WebpackModules, Patcher, MonkeyPatch, ReactComponents, ReactHelpers, ReactAutoPatcher, DiscordApi, BdWebApi, Connectivity } from 'modules';
|
||||
import { ClientLogger as Logger, ClientIPC, Utils } from 'common';
|
||||
import { EmoteModule } from 'builtin';
|
||||
import electron from 'electron';
|
||||
|
@ -35,7 +35,8 @@ class BetterDiscord {
|
|||
|
||||
WebpackModules, Patcher, MonkeyPatch, ReactComponents, ReactHelpers, ReactAutoPatcher, DiscordApi,
|
||||
EmoteModule,
|
||||
|
||||
BdWebApi,
|
||||
Connectivity,
|
||||
Logger, ClientIPC, Utils,
|
||||
|
||||
plugins: PluginManager.localContent,
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* BetterDiscord Web Apis
|
||||
* Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks
|
||||
* All rights reserved.
|
||||
* https://betterdiscord.net
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import { request } from 'vendor';
|
||||
|
||||
const APIBASE = 'ifyouareinwebtestthenyouknowwhatthisshouldbe'; // Do not push
|
||||
const ENDPOINTS = {
|
||||
'themes': `${APIBASE}/themes`,
|
||||
'users': `${APIBASE}/users`,
|
||||
'statistics': `${APIBASE}/statistics`
|
||||
};
|
||||
|
||||
export default class BdWebApi {
|
||||
|
||||
static async getThemes() {
|
||||
const get = await request.get(ENDPOINTS.themes);
|
||||
return JSON.parse(get);
|
||||
}
|
||||
|
||||
static async getUsers() {
|
||||
const get = await request.get(ENDPOINTS.users);
|
||||
return get;
|
||||
}
|
||||
|
||||
static async patchStatistics(json) {
|
||||
return await request({ method: 'PATCH', url: ENDPOINTS.statistics, json });
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
/**
|
||||
* BetterDiscord Connectivity Module
|
||||
* Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks
|
||||
* All rights reserved.
|
||||
* https://betterdiscord.net
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import BdWebApi from './bdwebapi';
|
||||
import { ClientLogger as Logger } from 'common';
|
||||
|
||||
const APIBASE = 'ifyouareinwebtestthenyouknowwhatthisshouldbe'; // Do not push
|
||||
const ENDPOINTS = {
|
||||
'themes': `${APIBASE}/themes`,
|
||||
'users': `${APIBASE}/users`
|
||||
};
|
||||
|
||||
export default class Connectivity {
|
||||
|
||||
static start() {
|
||||
Logger.info('Connectivity', `Patching anonymous statistics`);
|
||||
BdWebApi.patchStatistics({ themes: [], plugins: [] });
|
||||
setInterval(() => {
|
||||
Logger.info('Connectivity', `Patching anonymous statistics`);
|
||||
BdWebApi.patchStatistics({ themes: [], plugins: [] });
|
||||
}, 15*60*1000);
|
||||
}
|
||||
|
||||
}
|
|
@ -22,3 +22,5 @@ export { default as EventListener } from './eventlistener';
|
|||
export { default as SocketProxy } from './socketproxy';
|
||||
export { default as EventHook } from './eventhook';
|
||||
export { default as DiscordApi, Modules as DiscordApiModules } from './discordapi';
|
||||
export { default as BdWebApi } from './bdwebapi';
|
||||
export { default as Connectivity } from './connectivity';
|
||||
|
|
|
@ -46,6 +46,77 @@
|
|||
}
|
||||
}
|
||||
|
||||
.bd-settingswrap-item {
|
||||
.bd-settingswrap-button-big {
|
||||
width: 150px;
|
||||
height: 50px;
|
||||
border-radius: 5px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.bd-settingswrap-item-desc {
|
||||
color: #72767d;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.bd-settingswrap-infobox {
|
||||
display: flex;
|
||||
align-items: stretch;
|
||||
background: rgba(32,34,37,.6);
|
||||
border-color: #202225;
|
||||
padding: 20px;
|
||||
border-radius: 5px;
|
||||
border-style: solid;
|
||||
border-width: 1px;
|
||||
position: relative;
|
||||
margin-bottom: 20px;
|
||||
|
||||
.bd-settingswrap-infobox-child {
|
||||
background-size: 100% 100%;
|
||||
|
||||
.bd-wrapper {
|
||||
margin-bottom: 20px;
|
||||
|
||||
h5 {
|
||||
color: hsla(210,3%,87%,.3);
|
||||
letter-spacing: .5px;
|
||||
font-size: 12px;
|
||||
text-transform: uppercase;
|
||||
font-weight: 600;
|
||||
line-height: 16px;
|
||||
}
|
||||
|
||||
> span {
|
||||
color: #b9bbbe;
|
||||
font-size: 12px;
|
||||
line-height: 16px;
|
||||
font-weight: 600;
|
||||
margin-left: 5px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
> div {
|
||||
color: #b9bbbe;
|
||||
|
||||
> span {
|
||||
color: #b9bbbe;
|
||||
opacity: 0.5;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.bd-settingswrap-subheader {
|
||||
color: #f6f6f7;
|
||||
text-transform: uppercase;
|
||||
margin-bottom: 20px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.bd-settingswrap-contents {
|
||||
padding: 0 20px;
|
||||
margin-bottom: 84px;
|
||||
|
|
|
@ -37,6 +37,8 @@ export const BdMenuItems = new class {
|
|||
Events.on('update-check-end', () => updater.hidden = true);
|
||||
Events.on('updates-available', () => updater.hidden = false);
|
||||
|
||||
this.add({ category: 'Internal', contentid: 'connectivity', text: 'Connectivity' });
|
||||
|
||||
this.addSettingsSet('Internal', 'core', 'Core');
|
||||
this.addSettingsSet('Internal', 'ui', 'UI');
|
||||
this.addSettingsSet('Internal', 'emotes', 'Emotes');
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
<SettingsPanel :settings="item.set" :schemes="item.set.schemes" />
|
||||
</SettingsWrapper>
|
||||
|
||||
<ConnectivityView v-if="item.contentid === 'connectivity'"/>
|
||||
<CssEditorView v-if="item.contentid === 'css'" />
|
||||
<PluginsView v-if="item.contentid === 'plugins'" />
|
||||
<ThemesView v-if="item.contentid === 'themes'" />
|
||||
|
@ -62,7 +63,7 @@
|
|||
import { BdMenuItems } from 'ui';
|
||||
import { shell } from 'electron';
|
||||
import { SidebarView, Sidebar, SidebarItem, ContentColumn } from './sidebar';
|
||||
import { SettingsWrapper, SettingsPanel, CssEditorView, PluginsView, ThemesView, UpdaterView } from './bd';
|
||||
import { SettingsWrapper, SettingsPanel, CssEditorView, PluginsView, ThemesView, UpdaterView, ConnectivityView } from './bd';
|
||||
import { SvgX, MiGithubCircle, MiWeb, MiClose, MiTwitterCircle } from './common';
|
||||
|
||||
export default {
|
||||
|
@ -82,7 +83,7 @@
|
|||
props: ['active'],
|
||||
components: {
|
||||
SidebarView, Sidebar, SidebarItem, ContentColumn,
|
||||
SettingsWrapper, SettingsPanel, CssEditorView, PluginsView, ThemesView, UpdaterView,
|
||||
SettingsWrapper, SettingsPanel, CssEditorView, PluginsView, ThemesView, UpdaterView, ConnectivityView,
|
||||
MiGithubCircle, MiWeb, MiClose, MiTwitterCircle
|
||||
},
|
||||
computed: {
|
||||
|
|
|
@ -0,0 +1,112 @@
|
|||
/**
|
||||
* BetterDiscord Connectivity View Component
|
||||
* Copyright (c) 2015-present Jiiks/JsSucks - https://github.com/Jiiks / https://github.com/JsSucks
|
||||
* All rights reserved.
|
||||
* https://betterdiscord.net
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
<template>
|
||||
<SettingsWrapper headertext="Connectivity">
|
||||
<div class="bd-flex bd-flex-col bd-connectivityview">
|
||||
<div class="bd-settingswrap-item">
|
||||
<div v-if="connecting" class="bd-button bd-settingswrap-button-big bd-disabled">Connecting</div>
|
||||
<div v-else-if="!connected" class="bd-button bd-settingswrap-button-big" @click="showConnectWindow">Connect</div>
|
||||
<div v-else class="bd-settingswrap-infobox">
|
||||
<div class="bd-settingswrap-infobox-child" :style="{flex: '0 1 auto', backgroundImage: `url(${connectedUser.avatarUrl})`, width: '100px', height: '100px', borderRadius: '50%'}"></div>
|
||||
<div class="bd-settingswrap-infobox-child" :style="{flex: '1 1 auto', marginLeft: '10px'}">
|
||||
<div class="bd-wrapper">
|
||||
<h5>Username</h5>
|
||||
<div>
|
||||
{{connectedUser.username}}<span>#{{connectedUser.discriminator}}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bd-wrapper" :style="{display: 'flex'}">
|
||||
<h5>Themes: </h5><span>12</span>
|
||||
<h5>Plugins: </h5><span>0</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bd-button" :style="{height: '30px', borderRadius: '4px', padding: '0 5px'}" @click="disconnect">Disconnect</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bd-settingswrap-item">
|
||||
<h2 class="bd-settingswrap-subheader">BetterDiscord Connectivity</h2>
|
||||
<div class="bd-settingswrap-item-desc">
|
||||
Explanation for what connectivity is here.
|
||||
Explanation for what connectivity is here.
|
||||
Explanation for what connectivity is here.
|
||||
Explanation for what connectivity is here.
|
||||
Explanation for what connectivity is here.
|
||||
Explanation for what connectivity is here.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</SettingsWrapper>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import SettingsWrapper from './SettingsWrapper.vue';
|
||||
import electron from 'electron';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
connectWindow: null,
|
||||
connecting: false,
|
||||
connected: false,
|
||||
connectedUser: null
|
||||
};
|
||||
},
|
||||
components: {
|
||||
SettingsWrapper
|
||||
},
|
||||
methods: {
|
||||
showConnectWindow() {
|
||||
if (this.connecting) return;
|
||||
this.connecting = true;
|
||||
const x = (window.screenX + window.outerWidth / 2) - 520 / 2;
|
||||
const y = (window.screenY + window.outerHeight / 2) - 750 / 2;
|
||||
this.connectWindow = new electron.remote.BrowserWindow({
|
||||
width: 520,
|
||||
height: 750,
|
||||
x: x < 0 ? 0 : x,
|
||||
y: y < 0 ? 0 : y,
|
||||
backgroundColor: '#202225',
|
||||
show: true,
|
||||
resizable: false,
|
||||
maximizable: false,
|
||||
minimizable: false,
|
||||
alwaysOnTop: true,
|
||||
center: false,
|
||||
webPreferences: { nodeIntegration: false }
|
||||
});
|
||||
this.connectWindow.setMenu(null);
|
||||
|
||||
this.connectWindow.on('page-title-updated', (e, title) => {
|
||||
if (title !== 'BetterDiscord Auth Ready') return;
|
||||
this.connectWindow.webContents.executeJavaScript(`window.auth`, result => {
|
||||
const { username, discriminator, avatarUrl, token } = result;
|
||||
if (!username || !discriminator || !avatarUrl || !token) {
|
||||
this.connected = false;
|
||||
this.connectWindow.close();
|
||||
return;
|
||||
}
|
||||
this.connected = true;
|
||||
this.connectedUser = { username, discriminator, avatarUrl, token };
|
||||
this.connectWindow.close();
|
||||
});
|
||||
});
|
||||
this.connectWindow.on('close', (e) => {
|
||||
this.connectWindow = null;
|
||||
this.connecting = false;
|
||||
});
|
||||
this.connectWindow.loadURL(`ifyouareinwebtestthenyouknowwhatthisshouldbe/bd/v2/discord/connect?sub=${window.location.host.split('.')[0]}`);
|
||||
},
|
||||
disconnect() {
|
||||
this.connectedUser = null;
|
||||
this.connected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -5,3 +5,4 @@ export { default as PluginsView } from './PluginsView.vue';
|
|||
export { default as ThemesView } from './ThemesView.vue';
|
||||
export { default as UpdaterView } from './UpdaterView.vue';
|
||||
export { default as BdBadge } from './BdBadge.vue';
|
||||
export { default as ConnectivityView } from './ConnectivityView.vue';
|
||||
|
|
Loading…
Reference in New Issue