dotfiles/VencordDesktop/vencordDist/vencordDesktopMain.js

16 lines
23 KiB
JavaScript
Raw Normal View History

2024-01-10 23:19:19 -06:00
// Vencord d73790e
2023-11-14 11:41:09 -06:00
// Standalone: true
// Platform: Universal
// Updater disabled: false
2024-01-10 23:19:19 -06:00
"use strict";var Qn=Object.create;var xe=Object.defineProperty;var qn=Object.getOwnPropertyDescriptor;var $n=Object.getOwnPropertyNames;var et=Object.getPrototypeOf,nt=Object.prototype.hasOwnProperty;var O=(e,n)=>()=>(e&&(n=e(e=0)),n);var Te=(e,n)=>{for(var t in n)xe(e,t,{get:n[t],enumerable:!0})},tt=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of $n(n))!nt.call(e,i)&&i!==t&&xe(e,i,{get:()=>n[i],enumerable:!(r=qn(n,i))||r.enumerable});return e};var rt=(e,n,t)=>(t=e!=null?Qn(et(e)):{},tt(n||!e||!e.__esModule?xe(t,"default",{value:e,enumerable:!0}):t,e));var u=O(()=>{"use strict"});var te,Ee=O(()=>{u();te="d73790e"});var B,De=O(()=>{u();B="Vendicated/Vencord"});var Je,Qe=O(()=>{"use strict";u();Ee();De();Je=`Vencord/${te}${B?` (https://github.com/${B})`:""}`});var le=O(()=>{"use strict";u()});function H(e,n={}){return new Promise((t,r)=>{qe.default.get(e,n,i=>{let{statusCode:o,statusMessage:a,headers:s}=i;if(o>=400)return void r(`${o}: ${a} - ${e}`);if(o>=300)return void t(H(s.location,n));let c=[];i.on("error",r),i.on("data",f=>c.push(f)),i.once("end",()=>t(Buffer.concat(c)))})})}var qe,Re=O(()=>{"use strict";u();qe=rt(require("https"))});function re(e){return async function(){try{return{ok:!0,value:await e(...arguments)}}catch(n){return{ok:!1,error:n instanceof Error?{...n}:n}}}}var $e,en=O(()=>{"use strict";u();$e=["vencordDesktopMain.js","vencordDesktopPreload.js","vencordDesktopRenderer.js","vencordDesktopRenderer.css"]});var st={};async function an(e){return H(it+e,{headers:{Accept:"application/vnd.github+json","User-Agent":Je}})}async function at(){if(!await on())return[];let n=await an(`/compare/${te}...HEAD`);return JSON.parse(n.toString("utf-8")).commits.map(r=>({hash:r.sha.slice(0,7),author:r.author.login,message:r.commit.message}))}async function on(){let e=await an("/releases/latest"),n=JSON.parse(e.toString());return n.name.slice(n.name.lastIndexOf(" ")+1)===te?!1:(n.assets.forEach(({name:r,browser_download_url:i})=>{$e.some(o=>r.startsWith(o))&&ke.push([r,i])}),!0)}async function ot(){return await Promise.all(ke.map(async([e,n])=>(0,tn.writeFile)((0,rn.join)(__dirname,e),await H(n)))),ke=[],!0}var ie,tn,rn,it,ke,sn=O(()=>{"use strict";u();Qe();le();ie=require("electron"),tn=require("fs/promises"),rn=require("path");Ee();De();Re();en();it=`https://api.github.com/repos/${B}`,ke=[];ie.ipcMain.handle("VencordGetRepo",re(()=>`https://github.com/${B}`));ie.ipcMain.handle("VencordGetUpdates",re(at));ie.ipcMain.handle("VencordUpdate",re(on));ie.ipcMain.handle("VencordBuild",re(ot))});u();var Z=require("electron"),Yn=require("path");u();u();Promise.resolve().then(()=>sn());u();le();var Ue=require("electron");u();var un={};u();var cn=require("electron");cn.app.on("browser-window-created",(e,n)=>{n.webContents.on("frame-created",(t,{frame:r})=>{r.once("dom-ready",()=>{if(r.url.startsWith("https://open.spotify.com/embed/")){let i=he().plugins?.FixSpotifyEmbeds;if(!i?.enabled)return;r.executeJavaScript(`
2023-11-14 11:41:09 -06:00
const original = Audio.prototype.play;
Audio.prototype.play = function() {
this.volume = ${i.volume/100||.1};
return original.apply(this, arguments);
}
2024-01-10 23:19:19 -06:00
`)}})})});var Ge={};Te(Ge,{resolveRedirect:()=>ut});u();var fn=require("https"),ct=/^https:\/\/(spotify\.link|s\.team)\/.+$/;function ln(e){return new Promise((n,t)=>{let r=(0,fn.request)(new URL(e),{method:"HEAD"},i=>{n(i.headers.location?ln(i.headers.location):e)});r.on("error",t),r.end()})}async function ut(e,n){return ct.test(n)?ln(n):n}var ze={};Te(ze,{readRecording:()=>ft});u();var hn=require("electron"),gn=require("fs/promises"),ae=require("path");async function ft(e,n){n=(0,ae.normalize)(n);let t=(0,ae.basename)(n),r=(0,ae.normalize)(hn.app.getPath("userData")+"/");if(console.log(t,r,n),t!=="recording.ogg"||!n.startsWith(r))return null;try{let i=await(0,gn.readFile)(n);return new Uint8Array(i.buffer)}catch{return null}}var Pe={};Te(Pe,{sendToOverlay:()=>lt});u();var vn=require("dgram"),pn;function lt(e,n){n.icon=Buffer.from(n.icon).toString("base64");let t=JSON.stringify(n);pn??=(0,vn.createSocket)("udp4"),pn.send(t,42069,"127.0.0.1")}var mn={FixSpotifyEmbeds:un,OpenInApp:Ge,VoiceMessages:ze,XsOverlay:Pe};var dn={};for(let[e,n]of Object.entries(mn)){let t=Object.entries(n);if(!t.length)continue;let r=dn[e]={};for(let[i,o]of t){let a=`VencordPluginNative_${e}_${i}`;Ue.ipcMain.handle(a,o),r[i]=a}}Ue.ipcMain.on("VencordGetPluginIpcMethodMap",e=>{e.returnValue=dn});u();le();u();var oe=class{constructor(n=1/0){this.maxSize=n}queue=[];promise;next(){let n=this.queue.shift();n?this.promise=Promise.resolve().then(n).finally(()=>this.next()):this.promise=void 0}run(){this.promise||this.next()}push(n){this.size>=this.maxSize&&this.queue.shift(),this.queue.push(n),this.run()}unshift(n){this.size>=this.maxSize&&this.queue.pop(),this.queue.unshift(n),this.run()}get size(){return this.queue.length}};var v=require("electron"),Y=require("fs"),R=require("fs/promises"),b=require("path");u();var In="PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KICAgIDxoZWFkPgogICAgICAgIDxtZXRhIGNoYXJzZXQ9InV0Zi04IiAvPgogICAgICAgIDx0aXRsZT5WZW5jb3JkIFF1aWNrQ1NTIEVkaXRvcjwvdGl0bGU+CiAgICAgICAgPGxpbmsKICAgICAgICAgICAgcmVsPSJzdHlsZXNoZWV0IgogICAgICAgICAgICBocmVmPSJodHRwczovL2NkbmpzLmNsb3VkZmxhcmUuY29tL2FqYXgvbGlicy9tb25hY28tZWRpdG9yLzAuNDAuMC9taW4vdnMvZWRpdG9yL2VkaXRvci5tYWluLm1pbi5jc3MiCiAgICAgICAgICAgIGludGVncml0eT0ic2hhNTEyLU1Pb1EwMmg4MGhrbGNjZkxyWEZZa0N6RytXVmpPUmZsT3A5WnA4ZGx0aWFSUCszNUxZbk80TEtPa2xSNjRvTUdmR2dKRExPOFdKcGtNMW81Z1pYWVpRPT0iCiAgICAgICAgICAgIGNyb3Nzb3JpZ2luPSJhbm9ueW1vdXMiCiAgICAgICAgICAgIHJlZmVycmVycG9saWN5PSJuby1yZWZlcnJlciIKICAgICAgICAvPgogICAgICAgIDxzdHlsZT4KICAgICAgICAgICAgaHRtbCwKICAgICAgICAgICAgYm9keSwKICAgICAgICAgICAgI2NvbnRhaW5lciB7CiAgICAgICAgICAgICAgICBwb3NpdGlvbjogYWJzb2x1dGU7CiAgICAgICAgICAgICAgICBsZWZ0OiAwOwogICAgICAgICAgICAgICAgdG9wOiAwOwogICAgICAgICAgICAgICAgd2lkdGg6IDEwMCU7CiAgICAgICAgICAgICAgICBoZWlnaHQ6IDEwMCU7CiAgICAgICAgICAgICAgICBtYXJnaW46IDA7CiAgICAgICAgICAgICAgICBwYWRkaW5nOiAwOwogICAgICAgICAgICAgICAgb3ZlcmZsb3c6IGhpZGRlbjsKICAgICAgICAgICAgfQogICAgICAgIDwvc3R5bGU+CiAgICA8L2hlYWQ+CgogICAgPGJvZHk+CiAgICAgICAgPGRpdiBpZD0iY29udGFpbmVyIj48L2Rpdj4KICAgICAgICA8c2NyaXB0CiAgICAgICAgICAgIHNyYz0iaHR0cHM6Ly9jZG5qcy5jbG91ZGZsYXJlLmNvbS9hamF4L2xpYnMvbW9uYWNvLWVkaXRvci8wLjQwLjAvbWluL3ZzL2xvYWRlci5taW4uanMiCiAgICAgICAgICAgIGludGVncml0eT0ic2hhNTEyLVF6TXBYZUNQY2lBSFA0d2JZbFYyUFlnclFjYUVrRFFVanprUFU0eG5qeVZTRDlUMzYvdWRhbXh0TkJxYjRxSzQvYk1RTVBaOGF5ckJlOWhyR2RCRmpRPT0iCiAgICAgICAgICAgIGNyb3Nzb3JpZ2luPSJhbm9ueW1vdXMiCiAgICAgICAgICAgIHJlZmVycmVycG9saWN5PSJuby1yZWZlcnJlciIKICAgICAgICA+PC9zY3JpcHQ+CgogICAgICAgIDxzY3JpcHQ+CiAgICAgICAgICAgIHJlcXVpcmUuY29uZmlnKHsKICAgICAgICAgICAgICAgIHBhdGhzOiB7CiAgICAgICAgICAgICAgICAgICAgdnM6ICJodHRwczovL2NkbmpzLmNsb3VkZmxhcmUuY29tL2FqYXgvbGlicy9tb25hY28tZWRpdG9yLzAuNDAuMC9taW4vdnMiLAogICAgICAgICAgICAgICAgfSwKICAgICAgICAgICAgfSk7CgogICAgICAgICAgICByZXF1aXJlKFsidnMvZWRpdG9yL2VkaXRvci5tYWluIl0sICgpID0+IHsKICAgICAgICAgICAgICAgIGdldEN1cnJlbnRDc3MoKS50aGVuKChjc3MpID0+IHsKICAgICAgICAgICAgICAgICAgICB2YXIgZWRpdG9yID0gbW9uYWNvLmVkaXRvci5jcmVhdGUoCiAgICAgICAgICAgICAgICAgICAgICAgIGRvY3VtZW50LmdldEVsZW1lbnRCeUlkKCJjb250YWluZXIiKSwKICAgICAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICAgICA
`).replace(gt,"@");return r[i]=o.trim(),delete r[""],Oe(n,r)}u();var yn=require("electron"),_=require("path"),ge=process.env.VENCORD_USER_DATA_DIR??(process.env.DISCORD_USER_DATA_DIR?(0,_.join)(process.env.DISCORD_USER_DATA_DIR,"..","VencordData"):(0,_.join)(yn.app.getPath("userData"),"..","Vencord")),se=(0,_.join)(ge,"settings"),L=(0,_.join)(ge,"themes"),pe=(0,_.join)(se,"quickCss.css"),Ve=(0,_.join)(se,"settings.json"),wn=["https:","http:","steam:","spotify:","com.epicgames.launcher:"];u();var Sn=require("electron");function xn(e){e.webContents.setWindowOpenHandler(({url:n})=>{switch(n){case"about:blank":case"https://discord.com/popout":case"https://ptb.discord.com/popout":case"https://canary.discord.com/popout":return{action:"allow"}}try{var{protocol:t}=new URL(n)}catch{return{action:"deny"}}switch(t){case"http:":case"https:":case"mailto:":case"steam:":case"spotify:":Sn.shell.openExternal(n)}return{action:"deny"}})}(0,Y.mkdirSync)(se,{recursive:!0});(0,Y.mkdirSync)(L,{recursive:!0});function Ne(e,n){let t=(0,b.normalize)(e),r=(0,b.join)(e,n),i=(0,b.normalize)(r);return i.startsWith(t)?i:null}function pt(){return(0,R.readFile)(pe,"utf-8").catch(()=>"")}async function vt(){let e=await(0,R.readdir)(L).catch(()=>[]),n=[];for(let t of e){if(!t.endsWith(".css"))continue;let r=await Tn(t).then(An).catch(()=>null);r!=null&&n.push(Cn(r,t))}return n}function Tn(e){e=e.replace(/\?v=\d+$/,"");let n=Ne(L,e);return n?(0,R.readFile)(n,"utf-8"):Promise.reject(`Unsafe path ${e}`)}function En(){try{return(0,Y.readFileSync)(Ve,"utf-8")}catch{return"{}"}}function he(){try{return JSON.parse(En())}catch{return{}}}v.ipcMain.handle("VencordOpenQuickCss",()=>v.shell.openPath(pe));v.ipcMain.handle("VencordOpenExternal",(e,n)=>{try{var{protocol:t}=new URL(n)}catch{throw"Malformed URL"}if(!wn.includes(t))throw"Disallowed protocol.";v.shell.openExternal(n)});var mt=new oe,dt=new oe;v.ipcMain.handle("VencordGetQuickCss",()=>pt());v.ipcMain.handle("VencordSetQuickCss",(e,n)=>mt.push(()=>(0,R.writeFile)(pe,n)));v.ipcMain.handle("VencordGetThemesDir",()=>L);v.ipcMain.handle("VencordGetThemesList",()=>vt());v.ipcMain.handle("VencordGetThemeData",(e,n)=>Tn(n));v.ipcMain.handle("VencordGetThemeSystemValues",()=>({"os-accent-color":`#${v.systemPreferences.getAccentColor?.()||""}`}));v.ipcMain.handle("VencordGetSettingsDir",()=>se);v.ipcMain.on("VencordGetSettings",e=>e.returnValue=En());v.ipcMain.handle("VencordSetSettings",(e,n)=>{dt.push(()=>(0,R.writeFile)(Ve,n))});v.ipcMain.handle("VencordOpenMonacoEditor",async()=>{let e=new v.BrowserWindow({title:"Vencord QuickCSS Editor",autoHideMenuBar:!0,darkTheme:!0,webPreferences:{preload:(0,b.join)(__dirname,"vencordDesktopPreload.js"),contextIsolation:!0,nodeIntegration:!1,sandbox:!1}});xn(e),await e.loadURL(`data:text/html;base64,${In}`)});u();var Bn=require("electron");u();var kn=require("module"),It=(0,kn.createRequire)("/"),me,At=";var __w=require('worker_threads');__w.parentPort.on('message',function(m){onmessage({data:m})}),postMessage=function(m,t){__w.parentPort.postMessage(m,t)},close=process.exit;self=global";try{me=It("worker_threads").Worker}catch{}var Ct=me?function(e,n,t,r,i){var o=!1,a=new me(e+At,{eval:!0}).on("error",function(s){return i(s,null)}).on("message",function(s){return i(null,s)}).on("exit",function(s){s&&!o&&i(new Error("exited with code "+s),null)});return a.postMessage(t,r),a.terminate=function(){return o=!0,me.prototype.terminate.call(a)},a}:function(e,n,t,r,i){setImmediate(function(){return i(new Error("async operations unsupported - update to Node 12+ (or Node 10-11 with the --experimental-worker CLI flag)"),null)});var o=function(){};return{terminate:o,postMessage:o}},A=Uint8Array,V=Uint16Array,Le=Uint32Array,Ze=new A([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),We=new A([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Gn=new A([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),zn=function(e,n){for(var t=new V(31),r=0;r<31;++r)t[r]=n+=1<<e[r-1];for(var i=new Le(t[30]),r=1;r<30;++r)for(var o=t[r];o<t[r+1];++o)i[o]=o-t[r]<<5|r;re
2023-11-14 11:41:09 -06:00
//# sourceURL=VencordDesktopMain
//# sourceMappingURL=vencord://vencordDesktopMain.js.map
/*! For license information please see vencordDesktopMain.js.LEGAL.txt */