Skip to content
This repository has been archived by the owner on Dec 4, 2022. It is now read-only.

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
DragonFire1230 authored Apr 20, 2022
1 parent 7a13574 commit c1defe7
Show file tree
Hide file tree
Showing 9 changed files with 2,280 additions and 40 deletions.
1 change: 1 addition & 0 deletions dragoncord/js/TODO-add-js-files-dc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// TODO
2 changes: 1 addition & 1 deletion dragoncord/pages/about/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h1>About Dragoncord</h1>
<h1>Author of idea & Developer</h1>

<img src="https://cdn.discordapp.com/avatars/957240995169337395/0eaa4683303f429e72f8b4ae19a63b37.webp?size=512" height="32" width="32">
abobusdragonfire#1905
драконогонь#8392
</img>

<h1>First Tester & Idea suggester</h1>
Expand Down
2 changes: 1 addition & 1 deletion dragoncord/pages/about/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ html {
}

* {
font-family: Verdana, Geneva, sans-serif;
font-family: Arial;
font-size: 18px;
}

Expand Down
14 changes: 14 additions & 0 deletions dragoncord/pages/settings/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Dragoncord | Settings</title>
<link rel="stylesheet" type="text/css" href="main.css">
</head>
<body>
<h1>Dragoncord Settings | Alpha</h1>
<p>Invisible typing <input type="checkbox" name="invisibleTyping"></p>
<script type="text/javascript" src="main.js"></script>
</body>
</html>
20 changes: 20 additions & 0 deletions dragoncord/pages/settings/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
html {
background-color: #36393F;
}

* {
font-family: Arial;
font-size: 18px;
}

* {
color: white;
}

img {
border-radius: 20px;
}

hr {
color: rgba(255, 255, 255, 0);
}
10 changes: 10 additions & 0 deletions dragoncord/pages/settings/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
let invisibleTyping = document.querySelector('input[name=invisibleTyping]');
invisibleTyping.addEventListener('change', function(event){
if (this.checked = true) {
console.log("CHECKED");
}

if(this.checked = false) {
console.log("UNCHECKED");
}
});
104 changes: 78 additions & 26 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ console.log('Endpoint: ' + config.DCORD_ENDPOINT);

let main;

function start_failed(error_message) {
console.error('[CRITICAL ERROR] Dragoncord Start Failed!');
console.error('[CRITICAL ERROR] ' + error_message);
}

// Window
function createWindow() {
const main = new BrowserWindow({
Expand Down Expand Up @@ -87,59 +92,92 @@ function createWindow() {
fs.readdir('./dragoncord/js', function (err, files) {
if (err) {
console.log('[Error] Unable to scan directory: ' + err);
start_failed("/dragoncord/js/ is missing! Please redownload Dragoncord!");
}
files.forEach(function (file) {
const pluginsToLoad = fs.readFileSync('./dragoncord/js/' + file).toString();
main.webContents.executeJavaScript(pluginsToLoad);
console.log('[Dragoncord JS] Loaded: ' + file);
});
else {
if (!files.length) {
console.log('[Dragoncord JS] Folder is empty');
start_failed("/dragoncord/js/ folder is empty! Please redownload Dragoncord!");
}
else {
files.forEach(function (file) {
const pluginsToLoad = fs.readFileSync('./dragoncord/js/' + file).toString();
main.webContents.executeJavaScript(pluginsToLoad);
console.log('[Dragoncord JS] Loaded: ' + file);
});
}
}
});

fs.readdir('./dragoncord/css', function (err, files) {
if (err) {
console.log('[Error] Unable to scan directory: ' + err);
start_failed("/dragoncord/css/ is missing! Please redownload Dragoncord!");
}
files.forEach(function (file) {
const themeToLoad = fs.readFileSync('./dragoncord/css/' + file).toString();
main.webContents.insertCSS(themeToLoad);
console.log('[Dragoncord CSS] Loaded: ' + file);
});
else {
if (!files.length) {
console.log('[Dragoncord CSS] Folder is empty');
start_failed("/dragoncord/css/ folder is empty! Please redownload Dragoncord!");
}
else {
files.forEach(function (file) {
const themeToLoad = fs.readFileSync('./dragoncord/css/' + file).toString();
main.webContents.insertCSS(themeToLoad);
console.log('[Dragoncord CSS] Loaded: ' + file);
});
}
}
});

// Node Plugins
fs.readdir('./dcord_node_plugins', function (err, files) {
if (err) {
console.log('[Error] Unable to scan directory: ' + err);
}
files.forEach(function (file) {
const pluginsToLoad = fs.readFileSync('./dcord_node_plugins/' + file + '/' + 'main.js').toString();
require('./dcord_node_plugins/' + file + '/' + 'main.js');
console.log('[Node Plugin] Loaded: ' + file);
});
else {
if (!files.length) { console.log('[Node Plugin] Folder is empty'); }
else {
files.forEach(function (file) {
const pluginsToLoad = fs.readFileSync('./dcord_node_plugins/' + file + '/' + 'main.js').toString();
require('./dcord_node_plugins/' + file + '/' + 'main.js');
console.log('[Node Plugin] Loaded: ' + file);
});
}
}
});

// Plugins
fs.readdir('./plugins', function (err, files) {
if (err) {
console.log('[Error] Unable to scan directory: ' + err);
}
files.forEach(function (file) {
const pluginsToLoad = fs.readFileSync('./plugins/' + file + '/' + 'main.js').toString();
main.webContents.executeJavaScript(pluginsToLoad);
console.log('[Plugin] Loaded: ' + file);
});
else {
if (!files.length) { console.log('[Plugin] Folder is empty'); }
else {
files.forEach(function (file) {
const pluginsToLoad = fs.readFileSync('./plugins/' + file + '/' + 'main.js').toString();
main.webContents.executeJavaScript(pluginsToLoad);
console.log('[Plugin] Loaded: ' + file);
});
}
}
});

// Themes
fs.readdir('./themes', function (err, files) {
if (err) {
console.log('[Error] Unable to scan directory: ' + err);
}
files.forEach(function (file) {
const themeToLoad = fs.readFileSync('./themes/' + file + '/' + 'main.css').toString();
main.webContents.insertCSS(themeToLoad);
console.log('[Theme] Loaded: ' + file);
});
else {
if (!files.length) { console.log('[Theme] Folder is empty'); }
else {
files.forEach(function (file) {
const themeToLoad = fs.readFileSync('./themes/' + file + '/' + 'main.css').toString();
main.webContents.insertCSS(themeToLoad);
console.log('[Theme] Loaded: ' + file);
});
}
}
});
}
else {
Expand All @@ -166,6 +204,12 @@ function createWindow() {
spawnObj('notepad.exe', ["config.json"]);
}
},
{
label: 'Settings (Alpha)',
click() {
main.webContents.loadFile('./dragoncord/pages/settings/index.html');
}
},
{
label: 'Reload plugins/themes',
accelerator: process.platform === 'darwin' ? 'Alt+Cmd+Z' : 'Alt+Shift+Z',
Expand All @@ -177,7 +221,6 @@ function createWindow() {
label: 'About',
click() {
main.webContents.loadFile('./dragoncord/pages/about/index.html');
load_plugins();
}
}]
},
Expand Down Expand Up @@ -243,13 +286,16 @@ function createWindow() {
main.webContents.session.webRequest.onBeforeRequest(
{
urls: [
//'https://*/api/*/channels/*/typing',
'https://*/api/*/science',
'https://*/api/*/track'
]
},
(details, callback) => {
const url = new URL(details.url);
if (url.pathname.endsWith('/science') || url.pathname.endsWith('/track')) { console.debug('[Anti-Telemetry] Blocking ' + url.pathname); return 0;}
//else if (url.pathname.endsWith('/typing')) { console.debug('[Dragoncord] Typing disabled: ' + url.pathname); return 0;}
//else if (url.pathname.startsWith('wss://')) { console.debug('[Dragoncord] WSS disabled: ' + url.pathname); return 0;}
else { console.debug('[Anti-Telemetry] Blocking ' + url.pathname); return 0; }
},
);
Expand All @@ -270,6 +316,12 @@ app.on('window-all-closed', () => {
});

app.on('minimize', () => {
console.log('minimize');
main.blurWebView();
});

app.on('blur', () => {
console.log('blur');
main.blurWebView();
});

Expand Down
Loading

0 comments on commit c1defe7

Please sign in to comment.