diff options
author | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-09-26 22:29:30 +1000 |
---|---|---|
committer | Madeline <46743919+MaddyUnderStars@users.noreply.github.com> | 2022-09-26 22:41:21 +1000 |
commit | 99ee7e9400f06e8718612d8b52d15215dc620774 (patch) | |
tree | 08de8c5d3985b9c2eaa419f5198f891ecd82d012 /scripts/client.js | |
parent | Remove the cdn storage location log (diff) | |
download | server-99ee7e9400f06e8718612d8b52d15215dc620774.tar.xz |
Prettier
Diffstat (limited to 'scripts/client.js')
-rw-r--r-- | scripts/client.js | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/scripts/client.js b/scripts/client.js index e73bc7ee..ed1a94b9 100644 --- a/scripts/client.js +++ b/scripts/client.js @@ -8,21 +8,21 @@ const BASE_URL = "https://discord.com"; // Manual for now const INDEX_SCRIPTS = [ - "83ace7450e110d16319e", // 50 - "e02290aaa8dac5d195c2", // 1 - "4f3b3c576b879a5f75d1", // 0? - "699456246fdfe7589855", // ~4500. + "83ace7450e110d16319e", // 50 + "e02290aaa8dac5d195c2", // 1 + "4f3b3c576b879a5f75d1", // 0? + "699456246fdfe7589855", // ~4500. ]; const doPatch = (content) => { //remove nitro references content = content.replace(/Discord Nitro/g, "Fosscord Premium"); - content = content.replace(/"Nitro"/g, "\"Premium\""); + content = content.replace(/"Nitro"/g, '"Premium"'); content = content.replace(/Nitro /g, "Premium "); content = content.replace(/ Nitro/g, " Premium"); content = content.replace(/\[Nitro\]/g, "[Premium]"); content = content.replace(/\*Nitro\*/g, "*Premium*"); - content = content.replace(/\"Nitro \. /g, "\"Premium. "); + content = content.replace(/\"Nitro \. /g, '"Premium. '); //remove discord references content = content.replace(/ Discord /g, " Fosscord "); @@ -35,11 +35,11 @@ const doPatch = (content) => { content = content.replace(/\*Discord\*/g, "*Fosscord*"); //server -> guild - content = content.replace(/"Server"/g, "\"Guild\""); - content.replaceAll("server.\"", "guild.\""); + content = content.replace(/"Server"/g, '"Guild"'); + content.replaceAll('server."', 'guild."'); content.replaceAll(" server ", " guild "); content.replaceAll(" Server ", " Guild "); - content.replaceAll("\"Server", "\"Guild"); + content.replaceAll('"Server', '"Guild'); // //change some vars // content = content.replace('dsn: "https://fa97a90475514c03a42f80cd36d147c4@sentry.io/140984"', "dsn: (/true/.test(localStorage.sentryOptIn)?'https://6bad92b0175d41a18a037a73d0cff282@sentry.thearcanebrony.net/12':'')"); @@ -52,8 +52,14 @@ const doPatch = (content) => { // content = content.replace('width: n, height: o, viewBox: "0 0 28 20"', 'width: 48, height: 48, viewBox: "0 0 48 48"'); //save some time on load resolving asset urls... - content = content.replaceAll('e.exports = n.p + "', 'e.exports = "/assets/'); - content = content.replaceAll('e.exports = r.p + "', 'e.exports = "/assets/'); + content = content.replaceAll( + 'e.exports = n.p + "', + 'e.exports = "/assets/', + ); + content = content.replaceAll( + 'e.exports = r.p + "', + 'e.exports = "/assets/', + ); return content; }; @@ -66,7 +72,7 @@ const processFile = async (name) => { await fs.writeFile(path.join(CACHE_PATH, `${name}.js`), text); - return [...new Set(text.match((/[A-Fa-f0-9]{20}/g)))]; + return [...new Set(text.match(/[A-Fa-f0-9]{20}/g))]; }; (async () => { @@ -83,7 +89,9 @@ const processFile = async (name) => { process.stdout.clearLine(0); process.stdout.cursorTo(0); - process.stdout.write(`Scraping asset ${asset}. Remaining: ${INDEX_SCRIPTS.length}`); + process.stdout.write( + `Scraping asset ${asset}. Remaining: ${INDEX_SCRIPTS.length}`, + ); const newAssets = await processFile(asset); assets.push(...newAssets); @@ -103,15 +111,21 @@ const processFile = async (name) => { } while (rates.length > 20) rates.shift(); - const averageRate = rates.length ? rates.reduce((prev, curr) => prev + curr) / rates.length : 1; - const finishTime = (averageRate * (assets.length - i)); + const averageRate = rates.length + ? rates.reduce((prev, curr) => prev + curr) / rates.length + : 1; + const finishTime = averageRate * (assets.length - i); process.stdout.clearLine(0); process.stdout.cursorTo(0); process.stdout.write( `Caching asset ${asset}. ` + - `${i}/${assets.length - 1} = ${Math.floor((i / (assets.length - 1)) * 100)}% ` + - `Finish at: ${new Date(Date.now() + finishTime).toLocaleTimeString()}` + `${i}/${assets.length - 1} = ${Math.floor( + (i / (assets.length - 1)) * 100, + )}% ` + + `Finish at: ${new Date( + Date.now() + finishTime, + ).toLocaleTimeString()}`, ); await processFile(asset); @@ -122,4 +136,4 @@ const processFile = async (name) => { } console.log(`\nDone`); -})(); \ No newline at end of file +})(); |