mirror of
https://github.com/Lightcord/Lightcord.git
synced 2025-04-12 00:55:40 +02:00
Tabs - should be working but no multiple accounts
This commit is contained in:
parent
4eb40ccd42
commit
b21efa25e3
File diff suppressed because one or more lines are too long
@ -1,132 +1,133 @@
|
||||
import BDV2 from "../modules/v2";
|
||||
import V2C_SettingsTitle from "./settingsTitle";
|
||||
|
||||
/**
|
||||
* @type {typeof import("react")}
|
||||
*/
|
||||
const React = BDV2.React;
|
||||
|
||||
let marginModule2 = BDModules.get(e => e.defaultMarginh5)[0]
|
||||
let colorModule = BDModules.get(e => e.colorStandard)[0]
|
||||
let sizeModule = BDModules.get(e => e.size32)[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
|
||||
const userModule = BDModules.get(e => e.default && e.default.getCurrentUser)[0].default
|
||||
|
||||
export default class V2C_AccountInfos extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
render() {
|
||||
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 [
|
||||
<V2C_SettingsTitle text="Account Infos"/>,
|
||||
<div>
|
||||
<h5 className={colorModule.colorStandard+" "+sizeModule.size14+" "+marginModule2.h5+" "+marginModule2.defaultMarginh5}>
|
||||
Profile
|
||||
</h5>
|
||||
<CodeContent content={this.getProfileValue()} language="diff" />
|
||||
<h5 className={colorModule.colorStandard+" "+sizeModule.size14+" "+marginModule2.h5+" "+marginModule2.defaultMarginh5}>
|
||||
Statistics
|
||||
</h5>
|
||||
<CodeContent content={this.getStatistics()} language="diff" />
|
||||
<h5 className={colorModule.colorStandard+" "+sizeModule.size14+" "+marginModule2.h5+" "+marginModule2.defaultMarginh5}>
|
||||
Connected Sessions
|
||||
</h5>
|
||||
<CodeContent content={this.getSessionValue()} language="diff" />
|
||||
</div>,
|
||||
<div className={BDModules.get(e => e.marginBottom20)[0].marginBottom20}></div>
|
||||
]
|
||||
}
|
||||
|
||||
getSessionValue(){
|
||||
const sessionsRaw = sessionModule.getSessions()
|
||||
const sessions = Object.keys(sessionsRaw).filter(e => e !== "all").map(e => sessionsRaw[e])
|
||||
|
||||
if(sessions.length === 0)return "- No session detected. Please try in a few seconds"
|
||||
|
||||
return sessions.map(e => {
|
||||
return `+ id: ${e.sessionId}
|
||||
+ os: ${e.clientInfo.os[0].toUpperCase()+e.clientInfo.os.slice(1)}
|
||||
+ client: ${e.clientInfo.client}
|
||||
+ status: ${e.status}
|
||||
+ active: ${e.active ? "Yes" : "No"}
|
||||
+ Activities: ${e.activities.length}`
|
||||
}).join("\n"+"-".repeat(38)+"\n")
|
||||
}
|
||||
|
||||
getProfileValue(){
|
||||
const user = userModule.getCurrentUser()
|
||||
/**
|
||||
* @type {Date}
|
||||
*/
|
||||
const createdAt = user.createdAt
|
||||
|
||||
let avatarURL = user.avatarURL
|
||||
if(user.avatar && user.avatar.startsWith("a_")){
|
||||
avatarURL = user.getAvatarURL("gif")
|
||||
}
|
||||
|
||||
if(avatarURL.startsWith("/")){
|
||||
avatarURL = "https://discord.com"+avatarURL
|
||||
}
|
||||
if(avatarURL.endsWith("?size=128")){
|
||||
avatarURL = avatarURL.replace("?size=128", "?size=4096")
|
||||
}
|
||||
|
||||
return `+ Username: ${user.username}
|
||||
+ Discriminator: ${user.discriminator}
|
||||
+ Tag: ${user.tag}
|
||||
+ ID: ${user.id}
|
||||
+ Avatar: ${user.avatar}
|
||||
+ Avatar URL: ${avatarURL}
|
||||
+ Creation Date: ${(createdAt.getDate()).toString().padStart(2, "0")}/${(createdAt.getMonth()+1).toString().padStart(2, "0")}/${(createdAt.getFullYear()).toString().padStart(2, "0")} ${createdAt.getHours().toString().padStart(2, "0")}h ${createdAt.getMinutes().toString().padStart(2, "0")}min ${createdAt.getSeconds()}s
|
||||
+ Flags: ${user.flags}
|
||||
+ Has Nitro: ${user.hasPremiumSubscription ? "Yes" : "No"}
|
||||
- Email: ${user.email}
|
||||
- 2FA: ${user.mfaEnabled ? "Yes" : "No"}
|
||||
- Has Been On Mobile: ${user.mobile ? "Yes" : "No"}
|
||||
- Phone: ${user.phone || "None"}
|
||||
- Verified: ${user.verified}`
|
||||
}
|
||||
|
||||
getStatistics(){
|
||||
|
||||
const guilds = Object.values(GuildModule.getGuilds())
|
||||
const relations = Object.keys(relationShipModule.getRelationships())
|
||||
const friends = relations.filter(e => relationShipModule.isFriend(e))
|
||||
const blocked = relations.filter(e => relationShipModule.isBlocked(e))
|
||||
|
||||
return `+ Server Count: ${guilds.length} servers
|
||||
+ Relations: ${relations.length} relations
|
||||
+ Friends Count: ${friends.length} friends
|
||||
- Blocked Users Count: ${blocked.length} blocked users`
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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}}>
|
||||
|
||||
</code>
|
||||
</pre>
|
||||
<div className={BDModules.get(e => e.marginBottom8)[0].marginBottom8}></div>
|
||||
</div>)
|
||||
}
|
||||
import BDV2 from "../modules/v2";
|
||||
import V2C_SettingsTitle from "./settingsTitle";
|
||||
|
||||
/**
|
||||
* @type {typeof import("react")}
|
||||
*/
|
||||
const React = BDV2.React;
|
||||
|
||||
let marginModule2 = BDModules.get(e => e.defaultMarginh5)[0]
|
||||
let colorModule = BDModules.get(e => e.colorStandard)[0]
|
||||
let sizeModule = BDModules.get(e => e.size32)[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
|
||||
const userModule = BDModules.get(e => e.default && e.default.getCurrentUser)[0].default
|
||||
|
||||
export default class V2C_AccountInfos extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
render() {
|
||||
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 [
|
||||
<V2C_SettingsTitle text="Account Infos"/>,
|
||||
<div>
|
||||
<h5 className={colorModule.colorStandard+" "+sizeModule.size14+" "+marginModule2.h5+" "+marginModule2.defaultMarginh5}>
|
||||
Profile
|
||||
</h5>
|
||||
<CodeContent content={this.getProfileValue()} language="diff" />
|
||||
<h5 className={colorModule.colorStandard+" "+sizeModule.size14+" "+marginModule2.h5+" "+marginModule2.defaultMarginh5}>
|
||||
Statistics
|
||||
</h5>
|
||||
<CodeContent content={this.getStatistics()} language="diff" />
|
||||
<h5 className={colorModule.colorStandard+" "+sizeModule.size14+" "+marginModule2.h5+" "+marginModule2.defaultMarginh5}>
|
||||
Connected Sessions
|
||||
</h5>
|
||||
<CodeContent content={this.getSessionValue()} language="diff" />
|
||||
</div>,
|
||||
<div className={BDModules.get(e => e.marginBottom20)[0].marginBottom20}></div>
|
||||
]
|
||||
}
|
||||
|
||||
getSessionValue(){
|
||||
const sessionsRaw = sessionModule.getSessions()
|
||||
const sessions = Object.keys(sessionsRaw).filter(e => e !== "all").map(e => sessionsRaw[e])
|
||||
let session = sessionsRaw.all
|
||||
|
||||
if(sessions.length === 0)return "- No session detected. Please try in a few seconds"
|
||||
|
||||
return sessions.map(e => {
|
||||
return `+ id: ${e.sessionId}
|
||||
+ os: ${e.clientInfo.os[0].toUpperCase()+e.clientInfo.os.slice(1)}
|
||||
+ client: ${e.clientInfo.client}
|
||||
+ status: ${e.status}
|
||||
+ active: ${session.sessionId === e.sessionId}
|
||||
+ Activities: ${e.activities.length}`
|
||||
}).join("\n"+"-".repeat(38)+"\n")
|
||||
}
|
||||
|
||||
getProfileValue(){
|
||||
const user = userModule.getCurrentUser()
|
||||
/**
|
||||
* @type {Date}
|
||||
*/
|
||||
const createdAt = user.createdAt
|
||||
|
||||
let avatarURL = user.avatarURL
|
||||
if(user.avatar && user.avatar.startsWith("a_")){
|
||||
avatarURL = user.getAvatarURL("gif")
|
||||
}
|
||||
|
||||
if(avatarURL.startsWith("/")){
|
||||
avatarURL = "https://discord.com"+avatarURL
|
||||
}
|
||||
if(avatarURL.endsWith("?size=128")){
|
||||
avatarURL = avatarURL.replace("?size=128", "?size=4096")
|
||||
}
|
||||
|
||||
return `+ Username: ${user.username}
|
||||
+ Discriminator: ${user.discriminator}
|
||||
+ Tag: ${user.tag}
|
||||
+ ID: ${user.id}
|
||||
+ Avatar: ${user.avatar}
|
||||
+ Avatar URL: ${avatarURL}
|
||||
+ Creation Date: ${(createdAt.getDate()).toString().padStart(2, "0")}/${(createdAt.getMonth()+1).toString().padStart(2, "0")}/${(createdAt.getFullYear()).toString().padStart(2, "0")} ${createdAt.getHours().toString().padStart(2, "0")}h ${createdAt.getMinutes().toString().padStart(2, "0")}min ${createdAt.getSeconds()}s
|
||||
+ Flags: ${user.flags}
|
||||
+ Has Nitro: ${user.hasPremiumSubscription ? "Yes" : "No"}
|
||||
- Email: ${user.email}
|
||||
- 2FA: ${user.mfaEnabled ? "Yes" : "No"}
|
||||
- Has Been On Mobile: ${user.mobile ? "Yes" : "No"}
|
||||
- Phone: ${user.phone || "None"}
|
||||
- Verified: ${user.verified}`
|
||||
}
|
||||
|
||||
getStatistics(){
|
||||
|
||||
const guilds = Object.values(GuildModule.getGuilds())
|
||||
const relations = Object.keys(relationShipModule.getRelationships())
|
||||
const friends = relations.filter(e => relationShipModule.isFriend(e))
|
||||
const blocked = relations.filter(e => relationShipModule.isBlocked(e))
|
||||
|
||||
return `+ Server Count: ${guilds.length} servers
|
||||
+ Relations: ${relations.length} relations
|
||||
+ Friends Count: ${friends.length} friends
|
||||
- Blocked Users Count: ${blocked.length} blocked users`
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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}}>
|
||||
|
||||
</code>
|
||||
</pre>
|
||||
<div className={BDModules.get(e => e.marginBottom8)[0].marginBottom8}></div>
|
||||
</div>)
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ exports.startup = startup;
|
||||
exports.handleSingleInstance = handleSingleInstance;
|
||||
exports.setMainWindowVisible = setMainWindowVisible;
|
||||
const { Menu, BrowserWindow } = require('electron');
|
||||
const yauzl = require("yauzl")
|
||||
const fetch = require("node-fetch").default
|
||||
|
||||
let mainScreen;
|
||||
@ -68,8 +67,51 @@ function startup(bootstrapModules) {
|
||||
global.mainWindowId = Constants.DEFAULT_MAIN_WINDOW_ID;
|
||||
global.moduleUpdater = moduleUpdater;
|
||||
|
||||
const applicationMenu = require('./applicationMenu');
|
||||
Menu.setApplicationMenu(applicationMenu);
|
||||
let applicationMenu = require('./applicationMenu');
|
||||
|
||||
if(appSettings().get("isTabs", false)){
|
||||
console.log(`Patching applicationMenu`)
|
||||
applicationMenu = applicationMenu.map(e => {
|
||||
if(["View", "&View"].includes(e.label)){
|
||||
console.log(`Patching Tabs`)
|
||||
e.submenu.push({
|
||||
type: "separator"
|
||||
}, {
|
||||
label: "New Tab",
|
||||
click: () => {
|
||||
mainScreen.webContentsSend("NEW_TAB")
|
||||
},
|
||||
accelerator: "Command+T"
|
||||
}, {
|
||||
label: "Close Current Tab",
|
||||
click: () => {
|
||||
mainScreen.webContentsSend("CLOSE_TAB")
|
||||
},
|
||||
accelerator: "Command+W"
|
||||
})
|
||||
}
|
||||
e.submenu = e.submenu.map(e => {
|
||||
if(["Command+r", "Control+R"].includes(e.accelerator)){
|
||||
console.log(`Patching Refresh`)
|
||||
e.click = function(){
|
||||
mainScreen.webContentsSend("RELOAD")
|
||||
}
|
||||
}
|
||||
console.log(e.accelerator)
|
||||
if(["&Developer", "Developer"].includes(e.label)){
|
||||
console.log(`Patching devtools`)
|
||||
e.submenu[0].click = () => {
|
||||
mainScreen.webContentsSend("OPEN_DEVTOOLS")
|
||||
}
|
||||
}
|
||||
return e
|
||||
})
|
||||
return e
|
||||
})
|
||||
Menu.setApplicationMenu(Menu.buildFromTemplate(applicationMenu));
|
||||
}else{
|
||||
Menu.setApplicationMenu(applicationMenu);
|
||||
}
|
||||
|
||||
mainScreen = require('./mainScreen');
|
||||
|
||||
|
@ -68,9 +68,9 @@ const connectionBackoff = new _Backoff2.default(1000, 20000);
|
||||
const events = exports.events = new EventEmitter()
|
||||
const DISCORD_NAMESPACE = 'DISCORD_';
|
||||
|
||||
let isTabs = true
|
||||
let isTabs = false
|
||||
const getWebappEndpoint = () => {
|
||||
//isTabs = settings.get("isTabs", false)
|
||||
isTabs = settings.get("isTabs", false)
|
||||
if(!isTabs){
|
||||
let endpoint = settings.get('WEBAPP_ENDPOINT');
|
||||
if (!endpoint) {
|
||||
@ -433,7 +433,7 @@ function launchMainAppWindow(isVisible) {
|
||||
}
|
||||
|
||||
webContentsSend(mainWindow != null && mainWindow.isFocused() ? 'MAIN_WINDOW_FOCUS' : 'MAIN_WINDOW_BLUR');
|
||||
|
||||
webContentsSend("test", "sdasd", "sltsv")
|
||||
if (!lastPageLoadFailed) {
|
||||
connectionBackoff.succeed();
|
||||
}
|
||||
|
@ -18,6 +18,12 @@ ipcRenderer.on(TRACK_ANALYTICS_EVENT, e => {
|
||||
e.sender.send(TRACK_ANALYTICS_EVENT_COMMIT);
|
||||
});
|
||||
|
||||
global.isTab = false
|
||||
ipcRenderer.on("IS_TAB", (ev) => {
|
||||
global.isTab = true
|
||||
})
|
||||
|
||||
|
||||
const DiscordNative = {
|
||||
isRenderer: process.type === 'renderer',
|
||||
|
||||
|
@ -43,8 +43,7 @@
|
||||
<body>
|
||||
<div class="surface">
|
||||
<div class="chrome-tabs chrome-tabs-dark-theme" style="--tab-content-margin: 9px;margin-top: -8px">
|
||||
<div class="chrome-tabs-content">
|
||||
</div>
|
||||
<div class="chrome-tabs-content" style="width: calc(100% - 200px)"></div>
|
||||
<div class="chrome-tabs-bottom-bar"></div>
|
||||
<!-- Styles to prevent flash after JS initialization -->
|
||||
<style>
|
||||
|
@ -1,11 +1,60 @@
|
||||
const fs = require("fs")
|
||||
const { join } = require("path")
|
||||
const { pathToFileURL } = require("url")
|
||||
const { remote } = require("electron")
|
||||
const ipc = require("../discord_native/ipc")
|
||||
|
||||
let webviews = new Map()
|
||||
window.webviews = webviews
|
||||
|
||||
function forwardToCurrentWebview(event){
|
||||
return [event, (...args) => {
|
||||
let webview = webviews.get(document.querySelector(".chrome-tab[active]"))
|
||||
if(!webview)return
|
||||
webview.send(event, ...args.slice(1))
|
||||
}]
|
||||
}
|
||||
|
||||
ipc.on(...forwardToCurrentWebview("MAIN_WINDOW_FOCUS"))
|
||||
ipc.on(...forwardToCurrentWebview("MAIN_WINDOW_BLUR"))
|
||||
ipc.on(...forwardToCurrentWebview("SYSTEM_TRAY_OPEN_VOICE_SETTINGS"))
|
||||
ipc.on(...forwardToCurrentWebview("SYSTEM_TRAY_TOGGLE_MUTE"))
|
||||
ipc.on(...forwardToCurrentWebview("SYSTEM_TRAY_TOGGLE_DEAFEN"))
|
||||
ipc.on(...forwardToCurrentWebview("LAUNCH_APPLICATION"))
|
||||
ipc.on(...forwardToCurrentWebview("UPDATE_ERROR"))
|
||||
ipc.on(...forwardToCurrentWebview("UPDATE_NOT_AVAILABLE"))
|
||||
ipc.on(...forwardToCurrentWebview("UPDATE_MANUALLY"))
|
||||
ipc.on(...forwardToCurrentWebview("UPDATE_AVAILABLE"))
|
||||
ipc.on(...forwardToCurrentWebview("MODULE_INSTALL_PROGRESS"))
|
||||
ipc.on(...forwardToCurrentWebview("UPDATE_DOWNLOADED"))
|
||||
ipc.on(...forwardToCurrentWebview("MODULE_INSTALLED"))
|
||||
ipc.on(...forwardToCurrentWebview("CHECKING_FOR_UPDATES"))
|
||||
ipc.on(...forwardToCurrentWebview("UPDATER_HISTORY_RESPONSE"))
|
||||
ipc.on(...forwardToCurrentWebview("ACCESSIBILITY_SUPPORT_CHANGED"))
|
||||
ipc.on(...forwardToCurrentWebview("HELP_OPEN"))
|
||||
ipc.on(...forwardToCurrentWebview("USER_SETTINGS_OPEN"))
|
||||
ipc.on(...forwardToCurrentWebview("MAIN_WINDOW_PATH"))
|
||||
ipc.on("RELOAD", () => {
|
||||
let webview = webviews.get(document.querySelector(".chrome-tab[active]"))
|
||||
if(!webview)return
|
||||
webview.reload()
|
||||
})
|
||||
ipc.on("NEW_TAB", () => {
|
||||
chromeTabs.addTab({
|
||||
title: 'Lightcord',
|
||||
favicon: faviconURL
|
||||
})
|
||||
})
|
||||
ipc.on("CLOSE_TAB", () => {
|
||||
let active = document.querySelector("div.chrome-tab[active]")
|
||||
if(!active)return
|
||||
chromeTabs.removeTab(active)
|
||||
})
|
||||
ipc.on("OPEN_DEVTOOLS", () => {
|
||||
let webview = webviews.get(document.querySelector(".chrome-tab[active]"))
|
||||
if(!webview)return
|
||||
webview.openDevTools()
|
||||
})
|
||||
|
||||
window.onload = () => {
|
||||
const ChromeTabs = require("chrome-tabs")
|
||||
require("chrome-tabs/css/chrome-tabs.css")
|
||||
@ -27,26 +76,49 @@ window.onload = () => {
|
||||
webview.classList.add("active-webview")
|
||||
})
|
||||
tabs.addEventListener('tabAdd', ({detail}) => {
|
||||
console.log('Tab added', detail.tabEl)
|
||||
detail.tabEl.querySelector(".chrome-tab-title").innerText = "Lightcord Loading..."
|
||||
chromeTabs.updateTab(detail.tabEl, {
|
||||
title: "Lightcord Loading...",
|
||||
favicon: faviconURL
|
||||
})
|
||||
let webview = document.createElement("webview")
|
||||
webview.src = "https://discord.com/app"
|
||||
webview.classList.add("discord-webview")
|
||||
webview.classList.add("webview-active")
|
||||
webview.setAttribute("preload", pathToFileURL(join(__dirname, "../mainScreenPreload.js")))
|
||||
webview.shadowRoot.childNodes.item(1).style.height = "100%"
|
||||
webview.enableremotemodule = true
|
||||
webview.nodeintegration = false
|
||||
webview.webpreferences = "nativeWindowOpen=yes"
|
||||
webview.enableblinkfeatures = "EnumerateDevices,AudioOutputDevices"
|
||||
webview.addEventListener("ipc-message", function(...ev){
|
||||
ipc.send(ev[0].channel.replace("DISCORD_", ""))
|
||||
})
|
||||
webview.addEventListener('page-title-updated', () => {
|
||||
let el = Array.from(webviews.entries()).find(e => e[1] === webview)[0]
|
||||
if(!el)return
|
||||
chromeTabs.updateTab(el, {
|
||||
favicon: faviconURL,
|
||||
title: webview.getTitle()
|
||||
})
|
||||
})
|
||||
webviews.set(detail.tabEl, webview)
|
||||
document.querySelector(".documentFull").appendChild(webview)
|
||||
webview.addEventListener("dom-ready", () => {
|
||||
remote.webContents.fromId(webview.getWebContentsId()).openDevTools()
|
||||
webview.send("DISCORD_IS_TAB")
|
||||
})
|
||||
webview.addEventListener("will-navigate", (e) => {
|
||||
e.preventDefault()
|
||||
console.log(e, e.url)
|
||||
})
|
||||
})
|
||||
tabs.addEventListener('tabRemove', ({detail}) => {
|
||||
console.log('Tab removed', detail.tabEl)
|
||||
let webview = webviews.get(detail.tabEl)
|
||||
if(!webview)return
|
||||
webview.remove()
|
||||
webviews.delete(detail.tabEl)
|
||||
if(document.querySelector(".chrome-tabs-content").childNodes.length === 0){
|
||||
window.close()
|
||||
}
|
||||
})
|
||||
|
||||
window.addEventListener('keydown', (event) => {
|
||||
@ -63,6 +135,12 @@ window.onload = () => {
|
||||
}
|
||||
}
|
||||
})
|
||||
setImmediate(() => {
|
||||
chromeTabs.addTab({
|
||||
title: 'Lightcord Loading...',
|
||||
favicon: faviconURL
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
require.extensions[".css"] = (m, filename) => {
|
||||
@ -80,11 +158,4 @@ require.extensions[".css"] = (m, filename) => {
|
||||
return m.exports
|
||||
}
|
||||
|
||||
const faviconURL = pathToFileURL(join(__dirname, "../images/discord.png"))
|
||||
|
||||
window.onbeforeunload = (ev) => {
|
||||
if(!webviews)return
|
||||
webviews.forEach(webview => {
|
||||
webview.src = 'about:blank'
|
||||
})
|
||||
}
|
||||
const faviconURL = pathToFileURL(join(__dirname, "../images/discord.png"))
|
Loading…
x
Reference in New Issue
Block a user