diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/changelog.js | 10 | ||||
-rw-r--r-- | scripts/client.js | 42 | ||||
-rw-r--r-- | scripts/rights.js | 4 | ||||
-rw-r--r-- | scripts/schema.js | 6 |
4 files changed, 49 insertions, 13 deletions
diff --git a/scripts/changelog.js b/scripts/changelog.js index 412e6e0c..4e0936df 100644 --- a/scripts/changelog.js +++ b/scripts/changelog.js @@ -1,3 +1,13 @@ +/* + Changelogs are baked inside the discord.com web client. + To change them, we simply need to update the changelog in a specific file of the client. + For v134842, thats 9c4b2d313c6e1c864e89.js, but it'll be different for every version. + To find which file the changelog is stored in your client, simply grep for the changelog text given by the client, + and update the `CHANGELOG_SCRIPT` variable to use that instead. + + This grabs the new changelog from `fosscord-server/assets/changelog.txt` +*/ + const fetch = require("node-fetch"); const fs = require("fs/promises"); const path = require("path"); diff --git a/scripts/client.js b/scripts/client.js index b42217a0..b36cf561 100644 --- a/scripts/client.js +++ b/scripts/client.js @@ -1,3 +1,21 @@ +/* + This file downloads a ( mostly ) complete discord.com web client for testing, + and performs some basic patching: + * Replaces all mentions of "Server" -> "Guild" + * Replaces "Discord" -> `INSTANCE_NAME` variable + * "Nitro" -> "Premium" + * Prevents `localStorage` deletion ( for `plugins`/`preload-plugins` ) + * Adds `fast-identify` support ( TODO: add documentation ) + + This script can only download javascript client files. + It cannot download images, sounds, video, etc. + For that, a `cacheMisses` file in `fosscord-server/assets` is used. + After running the server for a while, uncached assets will be appended to that file + and downloaded after the next run of this script. + + TODO: Make this configurable easily. +*/ + const path = require("path"); const fetch = require("node-fetch"); const http = require('http'); @@ -13,7 +31,7 @@ const agent = (_parsedURL) => _parsedURL.protocol == 'http:' ? httpAgent : https const CACHE_PATH = path.join(__dirname, "..", "assets", "cache"); const BASE_URL = "https://discord.com"; -const INSTANCE_NAME = "Slowcord"; +const INSTANCE_NAME = "Fosscord"; // Manual for now const INDEX_SCRIPTS = [ @@ -95,15 +113,15 @@ const doPatch = (content) => { ); // app download links - content = content.replaceAll( - "https://play.google.com/store/apps/details?id=com.discord", - "https://slowcord.understars.dev/api/download?platform=android", - ); + // content = content.replaceAll( + // "https://play.google.com/store/apps/details?id=com.discord", + // "https://slowcord.understars.dev/api/download?platform=android", + // ); - content = content.replaceAll( - "https://itunes.apple.com/app/discord/id985746746", - "https://slowcord.understars.dev/api/download?platform=ios" - ); + // content = content.replaceAll( + // "https://itunes.apple.com/app/discord/id985746746", + // "https://slowcord.understars.dev/api/download?platform=ios" + // ); // TODO change public test build link // content = content.replaceAll( @@ -111,9 +129,11 @@ const doPatch = (content) => { // "" // ) - content = content.replaceAll("status.discord.com", "status.understars.dev"); - content = content.replaceAll("discordstatus.com", "status.understars.dev"); + // TODO: Easy config for this + // content = content.replaceAll("status.discord.com", "status.understars.dev"); + // content = content.replaceAll("discordstatus.com", "status.understars.dev"); + // Stop client from deleting `localStorage` global. Makes `plugins` and `preload-plugins` less annoying. content = content.replaceAll( "delete window.localStorage", "console.log('Prevented deletion of localStorage')" diff --git a/scripts/rights.js b/scripts/rights.js index 16fb38bc..86c8db16 100644 --- a/scripts/rights.js +++ b/scripts/rights.js @@ -1,3 +1,7 @@ +/* + Calculates a discord.com-like rights value. +*/ + require("module-alias/register"); const { Rights } = require(".."); diff --git a/scripts/schema.js b/scripts/schema.js index debae7e1..be57adc2 100644 --- a/scripts/schema.js +++ b/scripts/schema.js @@ -1,5 +1,7 @@ -// https://mermade.github.io/openapi-gui/# -// https://editor.swagger.io/ +/* + Regenerates the `fosscord-server/assets/schemas.json` file, used for API/Gateway input validation. +*/ + const path = require("path"); const fs = require("fs"); const TJS = require("typescript-json-schema"); |