arch-setup/files/vesktop/sessionData/vencordFiles/vencordDesktopMain.js

31 lines
35 KiB
JavaScript

// Vencord 6e11973
// Standalone: true
// Platform: Universal
// Updater Disabled: false
"use strict";var Ve=Object.defineProperty;var Ur=Object.getOwnPropertyDescriptor;var zr=Object.getOwnPropertyNames;var Nr=Object.prototype.hasOwnProperty;var G=(t,e)=>()=>(t&&(e=t(t=0)),e);var Q=(t,e)=>{for(var r in e)Ve(t,r,{get:e[r],enumerable:!0})},Gr=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of zr(e))!Nr.call(t,i)&&i!==r&&Ve(t,i,{get:()=>e[i],enumerable:!(n=Ur(e,i))||n.enumerable});return t};var Fr=t=>Gr(Ve({},"__esModule",{value:!0}),t);var c=G(()=>{"use strict"});var ee=G(()=>{"use strict";c()});async function At(t,e){try{var r=await fetch(t,e)}catch(i){throw i instanceof Error&&i.cause&&(i=i.cause),new Error(`${e?.method??"GET"} ${t} failed: ${i}`)}if(r.ok)return r;let n=`${e?.method??"GET"} ${t}: ${r.status} ${r.statusText}`;try{let i=await r.text();n+=`
${i}`}catch{}throw new Error(n)}async function Ot(t,e){return(await At(t,e)).json()}async function Te(t,e){let n=await(await At(t,e)).arrayBuffer();return Buffer.from(n)}var $r,He=G(()=>{"use strict";c();$r=require("original-fs")});var he,$e=G(()=>{c();he="6e11973"});var re,Be=G(()=>{c();re="Vendicated/Vencord"});var Re,Ye=G(()=>{"use strict";c();$e();Be();Re=`Vencord/${he}${re?` (https://github.com/${re})`:""}`});function pe(t){return async function(){try{return{ok:!0,value:await t(...arguments)}}catch(e){return{ok:!1,error:e instanceof Error?{...e,message:e.message,name:e.name,stack:e.stack}:e}}}}var _t,kt=G(()=>{"use strict";c();_t=["vencordDesktopMain.js","vencordDesktopPreload.js","vencordDesktopRenderer.js","vencordDesktopRenderer.css"]});var Kr={};async function Vt(t){return Ot(Br+t,{headers:{Accept:"application/vnd.github+json","User-Agent":Re}})}async function Yr(){return await Ut()?(await Vt(`/compare/${he}...HEAD`)).commits.map(r=>({hash:r.sha.slice(0,7),author:r.author.login,message:r.commit.message.split(`
`)[0]})):[]}async function Ut(){let t=await Vt("/releases/latest");return t.name.slice(t.name.lastIndexOf(" ")+1)===he?!1:(t.assets.forEach(({name:r,browser_download_url:n})=>{_t.some(i=>r.startsWith(i))&&Je.push([r,n])}),!0)}async function Jr(){let t=await Promise.all(Je.map(async([e,r])=>{let n=await Te(r);return[(0,Mt.join)(__dirname,e),n]}));return await Promise.all(t.map(async([e,r])=>(0,Lt.writeFile)(e,r))),Je=[],!0}var de,Lt,Mt,Br,Je,zt=G(()=>{"use strict";c();He();ee();Ye();de=require("electron"),Lt=require("fs/promises"),Mt=require("path");$e();Be();kt();Br=`https://api.github.com/repos/${re}`,Je=[];de.ipcMain.handle("VencordGetRepo",pe(()=>`https://github.com/${re}`));de.ipcMain.handle("VencordGetUpdates",pe(Yr));de.ipcMain.handle("VencordUpdate",pe(Ut));de.ipcMain.handle("VencordBuild",pe(Jr))});c();var B=require("electron"),Or=require("path"),pt=require("url");c();c();ee();c();var Ue=Symbol("SettingsStore.isProxy"),Et=Symbol("SettingsStore.getRawTarget"),fe=class{pathListeners=new Map;prefixListeners=new Map;globalListeners=new Set;proxyContexts=new WeakMap;proxyHandler=(()=>{let e=this;return{get(r,n,i){if(n===Ue)return!0;if(n===Et)return r;let o=Reflect.get(r,n,i),s=e.proxyContexts.get(r);if(s==null)return o;let{root:a,path:l}=s;if(!(n in r)&&e.getDefaultValue!=null&&(o=e.getDefaultValue({target:r,key:n,root:a,path:l})),typeof o=="object"&&o!==null&&!o[Ue]){let v=`${l}${l&&"."}${n}`;return e.makeProxy(o,a,v)}return o},set(r,n,i){if(i?.[Ue]&&(i=i[Et]),r[n]===i)return!0;if(!Reflect.set(r,n,i))return!1;let o=e.proxyContexts.get(r);if(o==null)return!0;let{root:s,path:a}=o,l=`${a}${a&&"."}${n}`;return e.notifyListeners(l,i,s),!0},deleteProperty(r,n){if(!Reflect.deleteProperty(r,n))return!1;let i=e.proxyContexts.get(r);if(i==null)return!0;let{root:o,path:s}=i,a=`${s}${s&&"."}${n}`;return e.notifyListeners(a,void 0,o),!0}}})();constructor(e,r={}){this.plain=e,this.store=this.makeProxy(e),Object.assign(this,r)}makeProxy(e,r=e,n=""){return this.proxyContexts.set(e,{root:r,path:n}),new Proxy(e,this.proxyHandler)}notifyPrefixListeners(e,r,n){for(let i=1;i<=r.length;i++){let o=r.slice(0,i).join(".");this.prefixListeners.get(o)?.forEach(s=>s(n,e))}}notifyListeners(e,r,n){let i=e.split(".");if(i.length>3&&i[0]==="plugins"){let o=i.slice(0,3),s=o.join("."),a=o.reduce((l,v)=>l[v],n);this.globalListeners.forEach(l=>l(n,s)),this.pathListeners.get(s)?.forEach(l=>l(a))}else this.globalListeners.forEach(o=>o(n,e));this.pathListeners.get(e)?.forEach(o=>o(r)),this.notifyPrefixListeners(e,i,r)}setData(e,r){if(this.readOnly)throw new Error("SettingsStore is read-only");if(this.plain=e,this.store=this.makeProxy(e),r){let n=e,i=r.split(".");for(let o of i){if(!n){console.warn(`Settings#setData: Path ${r} does not exist in new data. Not dispatching update`);return}n=n[o]}this.pathListeners.get(r)?.forEach(o=>o(n)),this.notifyPrefixListeners(r,i,n)}this.markAsChanged()}addGlobalChangeListener(e){this.globalListeners.add(e)}addChangeListener(e,r){let n=this.pathListeners.get(e)??new Set;n.add(r),this.pathListeners.set(e,n)}addPrefixChangeListener(e,r){let n=this.prefixListeners.get(e)??new Set;n.add(r),this.prefixListeners.set(e,n)}removeGlobalChangeListener(e){this.globalListeners.delete(e)}removeChangeListener(e,r){let n=this.pathListeners.get(e);n&&(n.delete(r),n.size||this.pathListeners.delete(e))}removePrefixChangeListener(e,r){let n=this.prefixListeners.get(e);n&&(n.delete(r),n.size||this.prefixListeners.delete(e))}markAsChanged(){this.globalListeners.forEach(e=>e(this.plain,""))}};c();function ze(t,e){for(let r in e){let n=e[r];typeof n=="object"&&!Array.isArray(n)?(t[r]??={},ze(t[r],n)):t[r]??=n}return t}var Fe=require("electron"),H=require("fs");c();var Tt=require("electron"),F=require("path"),Se=process.env.VENCORD_USER_DATA_DIR??(process.env.DISCORD_USER_DATA_DIR?(0,F.join)(process.env.DISCORD_USER_DATA_DIR,"..","VencordData"):(0,F.join)(Tt.app.getPath("userData"),"..","Vencord")),W=(0,F.join)(Se,"settings"),j=(0,F.join)(Se,"themes"),xe=(0,F.join)(W,"quickCss.css"),Ne=(0,F.join)(W,"settings.json"),Ge=(0,F.join)(W,"native-settings.json"),Rt=["https:","http:","steam:","spotify:","com.epicgames.launcher:","tidal:","itunes:"];(0,H.mkdirSync)(W,{recursive:!0});function Dt(t,e){try{return JSON.parse((0,H.readFileSync)(e,"utf-8"))}catch(r){return r?.code!=="ENOENT"&&console.error(`Failed to read ${t} settings`,r),{}}}var T=new fe(Dt("renderer",Ne));T.addGlobalChangeListener(()=>{try{(0,H.writeFileSync)(Ne,JSON.stringify(T.plain,null,4))}catch(t){console.error("Failed to write renderer settings",t)}});Fe.ipcMain.on("VencordGetSettings",t=>t.returnValue=T.plain);Fe.ipcMain.handle("VencordSetSettings",(t,e,r)=>{T.setData(e,r)});var Zr={plugins:{},customCspRules:{}},bt=Dt("native",Ge);ze(bt,Zr);var _=new fe(bt);_.addGlobalChangeListener(()=>{try{(0,H.writeFileSync)(Ge,JSON.stringify(_.plain,null,4))}catch(t){console.error("Failed to write native settings",t)}});var Ze=require("electron"),te=["connect-src"],I=[...te,"img-src"],Pt=["style-src","font-src"],y=[...I,...Pt],It=[...y,"script-src","worker-src"],je={"http://localhost:*":y,"http://127.0.0.1:*":y,"localhost:*":y,"127.0.0.1:*":y,"*.github.io":y,"github.com":y,"raw.githubusercontent.com":y,"*.gitlab.io":y,"gitlab.com":y,"*.codeberg.page":y,"codeberg.org":y,"*.githack.com":y,"jsdelivr.net":y,"fonts.googleapis.com":Pt,"i.imgur.com":I,"i.ibb.co":I,"i.pinimg.com":I,"*.tenor.com":I,"files.catbox.moe":y,"cdn.discordapp.com":y,"media.discordapp.net":I,"cdnjs.cloudflare.com":It,"cdn.jsdelivr.net":It,"api.github.com":te,"ws.audioscrobbler.com":te,"translate-pa.googleapis.com":te,"*.vencord.dev":I,"manti.vendicated.dev":I,"decor.fieryflames.dev":te,"ugc.decor.fieryflames.dev":I,"sponsor.ajay.app":te,"dearrow-thumb.ajay.app":I,"usrbg.is-hardly.online":I,"icons.duckduckgo.com":I},We=(t,e)=>Object.keys(t).find(r=>r.toLowerCase()===e),Wr=t=>{let e={};return t.split(";").forEach(r=>{let[n,...i]=r.trim().split(/\s+/g);n&&!Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=i)}),e},jr=t=>Object.entries(t).filter(([,e])=>e?.length).map(e=>e.flat().join(" ")).join("; "),Hr=t=>{let e=We(t,"content-security-policy-report-only");e&&delete t[e];let r=We(t,"content-security-policy");if(r){let n=Wr(t[r][0]),i=(o,...s)=>{n[o]??=[...n["default-src"]??[]],n[o].push(...s)};i("style-src","'unsafe-inline'"),i("script-src","'unsafe-inline'","'unsafe-eval'");for(let o of["style-src","connect-src","img-src","font-src","media-src","worker-src"])i(o,"blob:","data:","vencord:","vesktop:");for(let[o,s]of Object.entries(_.store.customCspRules))for(let a of s)i(a,o);for(let[o,s]of Object.entries(je))for(let a of s)i(a,o);t[r]=[jr(n)]}};function Ct(){Ze.session.defaultSession.webRequest.onHeadersReceived(({responseHeaders:t,resourceType:e},r)=>{if(t&&(e==="mainFrame"&&Hr(t),e==="stylesheet")){let n=We(t,"content-type");n&&(t[n]=["text/css"])}r({cancel:!1,responseHeaders:t})}),Ze.session.defaultSession.webRequest.onHeadersReceived=()=>{}}c();c();zt();c();ee();var it=require("electron");c();var qe={};Q(qe,{fetchTrackData:()=>Xr});c();Ye();var Nt=require("child_process"),Gt=require("util"),Ft=(0,Gt.promisify)(Nt.execFile);async function Ke(t){let{stdout:e}=await Ft("osascript",t.map(r=>["-e",r]).flat());return e}var C=null;async function qr({id:t,name:e,artist:r,album:n}){if(t===C?.id){if("data"in C)return C.data;if("failures"in C&&C.failures>=5)return null}try{let i=new URL("https://itunes.apple.com/search");i.searchParams.set("term",`${e} ${r} ${n}`),i.searchParams.set("media","music"),i.searchParams.set("entity","song");let o=await fetch(i,{headers:{"user-agent":Re}}).then(a=>a.json()).then(a=>a.results.find(l=>l.collectionName===n)||a.results[0]),s=await fetch(o.artistViewUrl).then(a=>a.text()).then(a=>{let l=a.match(/<meta property="og:image" content="(.+?)">/);return l?l[1].replace(/[0-9]+x.+/,"220x220bb-60.png"):void 0}).catch(()=>{});return C={id:t,data:{appleMusicLink:o.trackViewUrl,songLink:`https://song.link/i/${new URL(o.trackViewUrl).searchParams.get("i")}`,albumArtwork:o.artworkUrl100.replace("100x100","512x512"),artistArtwork:s}},C.data}catch(i){return console.error("[AppleMusicRichPresence] Failed to fetch remote data:",i),C={id:t,failures:(t===C?.id&&"failures"in C?C.failures:0)+1},null}}async function Xr(){try{await Ft("pgrep",["^Music$"])}catch{return null}if(await Ke(['tell application "Music"',"get player state","end tell"]).then(f=>f.trim())!=="playing")return null;let e=await Ke(['tell application "Music"',"get player position","end tell"]).then(f=>Number.parseFloat(f.trim())),r=await Ke(['set output to ""','tell application "Music"',"set t_id to database id of current track","set t_name to name of current track","set t_album to album of current track","set t_artist to artist of current track","set t_duration to duration of current track",'set output to "" & t_id & "\\n" & t_name & "\\n" & t_album & "\\n" & t_artist & "\\n" & t_duration',"end tell","return output"]),[n,i,o,s,a]=r.split(`
`).filter(f=>!!f),l=Number.parseFloat(a),v=await qr({id:n,name:i,artist:s,album:o});return{name:i,album:o,artist:s,playerPosition:e,duration:l,...v}}var Xe={};Q(Xe,{initDevtoolsOpenEagerLoad:()=>Qr});c();function Qr(t){let e=()=>t.sender.executeJavaScript("Vencord.Plugins.plugins.ConsoleShortcuts.eagerLoad(true)");t.sender.isDevToolsOpened()?e():t.sender.once("devtools-opened",()=>e())}var Wt={};c();var be=require("electron"),De=[];function Zt(){let t=[];for(let e=De.length-1;e>=0;e--){let{processId:r,routingId:n}=De[e],i=be.webFrameMain.fromId(r,n);if(!i){De.splice(e,1);continue}t.push(i)}return t}be.app.on("browser-window-created",(t,e)=>{e.webContents.on("frame-created",(r,{frame:n})=>{n?.once("dom-ready",()=>{if(n.url.startsWith("https://open.spotify.com/embed/")){Zt();let{routingId:i,processId:o}=n;De.push({routingId:i,processId:o});let s=T.store.plugins?.FixSpotifyEmbeds;if(!s?.enabled)return;n.executeJavaScript(`
globalThis._vcVolume = ${s.volume/100};
const original = Audio.prototype.play;
Audio.prototype.play = function() {
this.volume = _vcVolume;
return original.apply(this, arguments);
}
`)}})}),T.addChangeListener("plugins.FixSpotifyEmbeds.volume",r=>{try{Zt().forEach(n=>n.executeJavaScript(`globalThis._vcVolume = ${r/100}`))}catch(n){console.error("FixSpotifyEmbeds: Failed to update volume",n)}})});var Ht={};c();var jt=require("electron");jt.app.on("browser-window-created",(t,e)=>{e.webContents.on("frame-created",(r,{frame:n})=>{n?.once("dom-ready",()=>{if(n.url.startsWith("https://www.youtube.com/")){if(!T.store.plugins?.FixYoutubeEmbeds?.enabled)return;n.executeJavaScript(`
new MutationObserver(() => {
if(
document.querySelector('div.ytp-error-content-wrap-subreason a[href*="www.youtube.com/watch?v="]')
) location.reload()
}).observe(document.body, { childList: true, subtree:true });
`)}})})});var Qe={};Q(Qe,{resolveRedirect:()=>tn});c();var $t=require("https"),en=/^https:\/\/(spotify\.link|s\.team)\/.+$/;function Bt(t){return new Promise((e,r)=>{let n=(0,$t.request)(new URL(t),{method:"HEAD"},i=>{e(i.headers.location?Bt(i.headers.location):t)});n.on("error",r),n.end()})}async function tn(t,e){return en.test(e)?Bt(e):e}var et={};Q(et,{makeDeeplTranslateRequest:()=>rn});c();async function rn(t,e,r,n){let i=e?"https://api.deepl.com/v2/translate":"https://api-free.deepl.com/v2/translate";try{let o=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`DeepL-Auth-Key ${r}`},body:n}),s=await o.text();return{status:o.status,data:s}}catch(o){return{status:-1,data:String(o)}}}var tt={};Q(tt,{readRecording:()=>nn});c();var Yt=require("electron"),Jt=require("fs/promises"),ve=require("path");async function nn(t,e){e=(0,ve.normalize)(e);let r=(0,ve.basename)(e),n=(0,ve.normalize)(Yt.app.getPath("userData")+"/");if(console.log(r,n,e),r!=="recording.ogg"||!e.startsWith(n))return null;try{let i=await(0,Jt.readFile)(e);return new Uint8Array(i.buffer)}catch{return null}}var rt={};Q(rt,{sendToOverlay:()=>on});c();var qt=require("dgram"),Kt;function on(t,e){e.messageType=e.type;let r=JSON.stringify(e);Kt??=(0,qt.createSocket)("udp4"),Kt.send(r,42069,"127.0.0.1")}var Qt={};c();var Xt=require("electron");c();var nt=`"use strict";const hiddenCSS=["#__ffYoutube1","#__ffYoutube2","#__ffYoutube3","#__ffYoutube4","#feed-pyv-container","#feedmodule-PRO","#homepage-chrome-side-promo","#merch-shelf","#offer-module",'#pla-shelf > ytd-pla-shelf-renderer[class="style-scope ytd-watch"]',"#pla-shelf","#premium-yva","#promo-info","#promo-list","#promotion-shelf","#related > ytd-watch-next-secondary-results-renderer > #items > ytd-compact-promoted-video-renderer.ytd-watch-next-secondary-results-renderer","#search-pva","#shelf-pyv-container","#video-masthead","#watch-branded-actions","#watch-buy-urls","#watch-channel-brand-div","#watch7-branded-banner","#YtKevlarVisibilityIdentifier","#YtSparklesVisibilityIdentifier",".carousel-offer-url-container",".companion-ad-container",".GoogleActiveViewElement",'.list-view[style="margin: 7px 0pt;"]',".promoted-sparkles-text-search-root-container",".promoted-videos",".searchView.list-view",".sparkles-light-cta",".watch-extra-info-column",".watch-extra-info-right",".ytd-carousel-ad-renderer",".ytd-compact-promoted-video-renderer",".ytd-companion-slot-renderer",".ytd-merch-shelf-renderer",".ytd-player-legacy-desktop-watch-ads-renderer",".ytd-promoted-sparkles-text-search-renderer",".ytd-promoted-video-renderer",".ytd-search-pyv-renderer",".ytd-video-masthead-ad-v3-renderer",".ytp-ad-action-interstitial-background-container",".ytp-ad-action-interstitial-slot",".ytp-ad-image-overlay",".ytp-ad-overlay-container",".ytp-ad-progress",".ytp-ad-progress-list",'[class*="ytd-display-ad-"]','[layout*="display-ad-"]','a[href^="http://www.youtube.com/cthru?"]','a[href^="https://www.youtube.com/cthru?"]',"ytd-action-companion-ad-renderer","ytd-banner-promo-renderer","ytd-compact-promoted-video-renderer","ytd-companion-slot-renderer","ytd-display-ad-renderer","ytd-promoted-sparkles-text-search-renderer","ytd-promoted-sparkles-web-renderer","ytd-search-pyv-renderer","ytd-single-option-survey-renderer","ytd-video-masthead-ad-advertiser-info-renderer","ytd-video-masthead-ad-v3-renderer","YTM-PROMOTED-VIDEO-RENDERER"],hideElements=()=>{const e=hiddenCSS;if(!e)return;const t=e.join(", ")+" { display: none!important; }",r=document.createElement("style");r.textContent=t,document.head.appendChild(r)},observeDomChanges=e=>{new MutationObserver(r=>{e(r)}).observe(document.documentElement,{childList:!0,subtree:!0})},hideDynamicAds=()=>{const e=document.querySelectorAll("#contents > ytd-rich-item-renderer ytd-display-ad-renderer");e.length!==0&&e.forEach(t=>{if(t.parentNode&&t.parentNode.parentNode){const r=t.parentNode.parentNode;r.localName==="ytd-rich-item-renderer"&&(r.style.display="none")}})},autoSkipAds=()=>{if(document.querySelector(".ad-showing")){const e=document.querySelector("video");e&&e.duration&&(e.currentTime=e.duration,setTimeout(()=>{const t=document.querySelector("button.ytp-ad-skip-button");t&&t.click()},100))}},overrideObject=(e,t,r)=>{if(!e)return!1;let n=!1;for(const o in e)e.hasOwnProperty(o)&&o===t?(e[o]=r,n=!0):e.hasOwnProperty(o)&&typeof e[o]=="object"&&overrideObject(e[o],t,r)&&(n=!0);return n},jsonOverride=(e,t)=>{const r=JSON.parse;JSON.parse=(...n)=>{const o=r.apply(this,n);return overrideObject(o,e,t),o},Response.prototype.json=new Proxy(Response.prototype.json,{async apply(...n){const o=await Reflect.apply(...n);return overrideObject(o,e,t),o}})};jsonOverride("adPlacements",[]),jsonOverride("playerAds",[]),hideElements(),hideDynamicAds(),autoSkipAds(),observeDomChanges(()=>{hideDynamicAds(),autoSkipAds()});
`;Xt.app.on("browser-window-created",(t,e)=>{e.webContents.on("frame-created",(r,{frame:n})=>{n?.once("dom-ready",()=>{T.store.plugins?.YoutubeAdblock?.enabled&&(n.url.includes("youtube.com/embed/")?n.executeJavaScript(nt):n.parent?.url.includes("youtube.com/embed/")&&n.parent.executeJavaScript(nt))})})});var er={AppleMusicRichPresence:qe,ConsoleShortcuts:Xe,FixSpotifyEmbeds:Wt,FixYoutubeEmbeds:Ht,OpenInApp:Qe,Translate:et,VoiceMessages:tt,XSOverlay:rt,YoutubeAdblock:Qt};var tr={};for(let[t,e]of Object.entries(er)){let r=Object.entries(e);if(!r.length)continue;let n=tr[t]={};for(let[i,o]of r){let s=`VencordPluginNative_${t}_${i}`;it.ipcMain.handle(s,o),n[i]=s}}it.ipcMain.on("VencordGetPluginIpcMethodMap",t=>{t.returnValue=tr});c();ee();var g=require("electron");c();var rr="PCFkb2N0eXBlIGh0bWw+PGh0bWwgbGFuZz0iZW4iPjxoZWFkPjxtZXRhIGNoYXJzZXQ9InV0Zi04Ij48dGl0bGU+VmVuY29yZCBRdWlja0NTUyBFZGl0b3I8L3RpdGxlPjxsaW5rIHJlbD0ic3R5bGVzaGVldCIgaHJlZj0iaHR0cHM6Ly9jZG4uanNkZWxpdnIubmV0L25wbS9tb25hY28tZWRpdG9yQDAuNTAuMC9taW4vdnMvZWRpdG9yL2VkaXRvci5tYWluLmNzcyIgaW50ZWdyaXR5PSJzaGEyNTYtdGlKUFEyTzA0ei9wWi9Bd2R5SWdock9NemV3ZitQSXZFbDFZS2JRdnNaaz0iIGNyb3Nzb3JpZ2luPSJhbm9ueW1vdXMiIHJlZmVycmVycG9saWN5PSJuby1yZWZlcnJlciI+PHN0eWxlPiNjb250YWluZXIsYm9keSxodG1se3Bvc2l0aW9uOmFic29sdXRlO2xlZnQ6MDt0b3A6MDt3aWR0aDoxMDAlO2hlaWdodDoxMDAlO21hcmdpbjowO3BhZGRpbmc6MDtvdmVyZmxvdzpoaWRkZW59PC9zdHlsZT48L2hlYWQ+PGJvZHk+PGRpdiBpZD0iY29udGFpbmVyIj48L2Rpdj48c2NyaXB0IHNyYz0iaHR0cHM6Ly9jZG4uanNkZWxpdnIubmV0L25wbS9tb25hY28tZWRpdG9yQDAuNTAuMC9taW4vdnMvbG9hZGVyLmpzIiBpbnRlZ3JpdHk9InNoYTI1Ni1LY1U0OFRHcjg0cjd1bkY3SjVJZ0JvOTVhZVZyRWJyR2UwNFM3VGNGVWpzPSIgY3Jvc3NvcmlnaW49ImFub255bW91cyIgcmVmZXJyZXJwb2xpY3k9Im5vLXJlZmVycmVyIj48L3NjcmlwdD48c2NyaXB0PnJlcXVpcmUuY29uZmlnKHtwYXRoczp7dnM6Imh0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vbW9uYWNvLWVkaXRvckAwLjUwLjAvbWluL3ZzIn19KSxyZXF1aXJlKFsidnMvZWRpdG9yL2VkaXRvci5tYWluIl0sKCgpPT57Z2V0Q3VycmVudENzcygpLnRoZW4oKGU9Pnt2YXIgdD1tb25hY28uZWRpdG9yLmNyZWF0ZShkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgiY29udGFpbmVyIikse3ZhbHVlOmUsbGFuZ3VhZ2U6ImNzcyIsdGhlbWU6Z2V0VGhlbWUoKX0pO3Qub25EaWRDaGFuZ2VNb2RlbENvbnRlbnQoKCgpPT5zZXRDc3ModC5nZXRWYWx1ZSgpKSkpLHdpbmRvdy5hZGRFdmVudExpc3RlbmVyKCJyZXNpemUiLCgoKT0+e3QubGF5b3V0KCl9KSl9KSl9KSk8L3NjcmlwdD48L2JvZHk+PC9odG1sPg==";var me=require("fs"),oe=require("fs/promises"),ie=require("path");c();ee();var ne=require("electron");function nr(){ne.ipcMain.handle("VencordCspRemoveOverride",ln),ne.ipcMain.handle("VencordCspRequestAddOverride",cn),ne.ipcMain.handle("VencordCspIsDomainAllowed",un)}function sn(t,e){try{let{host:r}=new URL(t);if(/[;'"\\]/.test(r))return!1}catch{return!1}return!(e.length===0||e.some(r=>!y.includes(r)))}function an(t,e,r){let n=new URL(t).host,i=`${r} wants to allow connections to ${n}`,o=`Unless you recognise and fully trust ${n}, you should cancel this request!
You will have to fully close and restart Vesktop for the changes to take effect.`;if(e.length===1&&e[0]==="connect-src")return{message:i,detail:o};let s=e.filter(a=>a!=="connect-src").map(a=>{switch(a){case"img-src":return"Images";case"style-src":return"CSS & Themes";case"font-src":return"Fonts";default:throw new Error(`Illegal CSP directive: ${a}`)}}).sort().join(", ");return o=`The following types of content will be allowed to load from ${n}:
${s}
${o}`,{message:i,detail:o}}async function cn(t,e,r,n){if(!sn(e,r))return"invalid";let i=new URL(e).host;if(i in _.store.customCspRules)return"conflict";let{checkboxChecked:o,response:s}=await ne.dialog.showMessageBox({...an(e,r,n),type:n?"info":"warning",title:"Vencord Host Permissions",buttons:["Cancel","Allow"],defaultId:0,cancelId:0,checkboxLabel:`I fully trust ${i} and understand the risks of allowing connections to it.`,checkboxChecked:!1});return s!==1?"cancelled":o?(_.store.customCspRules[i]=r,"ok"):"unchecked"}function ln(t,e){return e in _.store.customCspRules?(delete _.store.customCspRules[e],!0):!1}function un(t,e,r){try{let n=new URL(e).host,i=je[n]??_.store.customCspRules[n];return i?r.every(o=>i.includes(o)):!1}catch{return!1}}c();var fn=/[^\S\r\n]*?\r?(?:\r\n|\n)[^\S\r\n]*?\*[^\S\r\n]?/,hn=/^\\@/;function ot(t,e={}){return{fileName:t,name:e.name??t.replace(/\.css$/i,""),author:e.author??"Unknown Author",description:e.description??"A Discord Theme.",version:e.version,license:e.license,source:e.source,website:e.website,invite:e.invite}}function ir(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}function or(t,e){if(!t)return ot(e);let r=t.split("/**",2)?.[1]?.split("*/",1)?.[0];if(!r)return ot(e);let n={},i="",o="";for(let s of r.split(fn))if(s.length!==0)if(s.charAt(0)==="@"&&s.charAt(1)!==" "){n[i]=o.trim();let a=s.indexOf(" ");i=s.substring(1,a),o=s.substring(a+1)}else o+=" "+s.replace("\\n",`
`).replace(hn,"@");return n[i]=o.trim(),delete n[""],ot(e,n)}c();var sr=require("electron");function ar(t){t.webContents.setWindowOpenHandler(({url:e})=>{switch(e){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:r}=new URL(e)}catch{return{action:"deny"}}switch(r){case"http:":case"https:":case"mailto:":case"steam:":case"spotify:":sr.shell.openExternal(e)}return{action:"deny"}})}(0,me.mkdirSync)(j,{recursive:!0});nr();function st(t,e){let r=(0,ie.normalize)(t+"/"),n=(0,ie.join)(t,e),i=(0,ie.normalize)(n);return i.startsWith(r)?i:null}function pn(){return(0,oe.readFile)(xe,"utf-8").catch(()=>"")}async function dn(){let t=await(0,oe.readdir)(j).catch(()=>[]),e=[];for(let r of t){if(!r.endsWith(".css"))continue;let n=await cr(r).then(ir).catch(()=>null);n!=null&&e.push(or(n,r))}return e}function cr(t){t=t.replace(/\?v=\d+$/,"");let e=st(j,t);return e?(0,oe.readFile)(e,"utf-8"):Promise.reject(`Unsafe path ${t}`)}g.ipcMain.handle("VencordOpenQuickCss",()=>g.shell.openPath(xe));g.ipcMain.handle("VencordOpenExternal",(t,e)=>{try{var{protocol:r}=new URL(e)}catch{throw"Malformed URL"}if(!Rt.includes(r))throw"Disallowed protocol.";g.shell.openExternal(e)});g.ipcMain.handle("VencordGetQuickCss",()=>pn());g.ipcMain.handle("VencordSetQuickCss",(t,e)=>(0,me.writeFileSync)(xe,e));g.ipcMain.handle("VencordGetThemesList",()=>dn());g.ipcMain.handle("VencordGetThemeData",(t,e)=>cr(e));g.ipcMain.handle("VencordGetThemeSystemValues",()=>({"os-accent-color":`#${g.systemPreferences.getAccentColor?.()||""}`}));g.ipcMain.handle("VencordOpenThemesFolder",()=>g.shell.openPath(j));g.ipcMain.handle("VencordOpenSettingsFolder",()=>g.shell.openPath(W));g.ipcMain.handle("VencordOpenMonacoEditor",async()=>{let t="Vencord QuickCSS Editor",e=g.BrowserWindow.getAllWindows().find(n=>n.title===t);if(e&&!e.isDestroyed()){e.focus();return}let r=new g.BrowserWindow({title:t,autoHideMenuBar:!0,darkTheme:!0,webPreferences:{preload:(0,ie.join)(__dirname,"vencordDesktopPreload.js"),contextIsolation:!0,nodeIntegration:!1,sandbox:!1}});ar(r),await r.loadURL(`data:text/html;base64,${rr}`)});c();var Pr=require("electron");c();var fr=require("module"),vn=(0,fr.createRequire)("/"),Pe,mn=";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{Pe=vn("worker_threads").Worker}catch{}var gn=Pe?function(t,e,r,n,i){var o=!1,s=new Pe(t+mn,{eval:!0}).on("error",function(a){return i(a,null)}).on("message",function(a){return i(null,a)}).on("exit",function(a){a&&!o&&i(new Error("exited with code "+a),null)});return s.postMessage(r,n),s.terminate=function(){return o=!0,Pe.prototype.terminate.call(s)},s}:function(t,e,r,n,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}},E=Uint8Array,$=Uint16Array,hr=Int32Array,lt=new E([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]),ut=new E([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]),pr=new E([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),dr=function(t,e){for(var r=new $(31),n=0;n<31;++n)r[n]=e+=1<<t[n-1];for(var i=new hr(r[30]),n=1;n<30;++n)for(var o=r[n];o<r[n+1];++o)i[o]=o-r[n]<<5|n;return{b:r,r:i}},vr=dr(lt,2),ft=vr.b,yn=vr.r;ft[28]=258,yn[258]=28;var mr=dr(ut,0),gr=mr.b,yo=mr.r,Oe=new $(32768);for(d=0;d<32768;++d)U=(d&43690)>>1|(d&21845)<<1,U=(U&52428)>>2|(U&13107)<<2,U=(U&61680)>>4|(U&3855)<<4,Oe[d]=((U&65280)>>8|(U&255)<<8)>>1;var U,d,se=(function(t,e,r){for(var n=t.length,i=0,o=new $(e);i<n;++i)t[i]&&++o[t[i]-1];var s=new $(e);for(i=1;i<e;++i)s[i]=s[i-1]+o[i-1]<<1;var a;if(r){a=new $(1<<e);var l=15-e;for(i=0;i<n;++i)if(t[i])for(var v=i<<4|t[i],f=e-t[i],u=s[t[i]-1]++<<f,m=u|(1<<f)-1;u<=m;++u)a[Oe[u]>>l]=v}else for(a=new $(n),i=0;i<n;++i)t[i]&&(a[i]=Oe[s[t[i]-1]++]>>15-t[i]);return a}),ge=new E(288);for(d=0;d<144;++d)ge[d]=8;var d;for(d=144;d<256;++d)ge[d]=9;var d;for(d=256;d<280;++d)ge[d]=7;var d;for(d=280;d<288;++d)ge[d]=8;var d,yr=new E(32);for(d=0;d<32;++d)yr[d]=5;var d;var wr=se(ge,9,1);var Sr=se(yr,5,1),Ce=function(t){for(var e=t[0],r=1;r<t.length;++r)t[r]>e&&(e=t[r]);return e},P=function(t,e,r){var n=e/8|0;return(t[n]|t[n+1]<<8)>>(e&7)&r},Ae=function(t,e){var r=e/8|0;return(t[r]|t[r+1]<<8|t[r+2]<<16)>>(e&7)},xr=function(t){return(t+7)/8|0},_e=function(t,e,r){return(e==null||e<0)&&(e=0),(r==null||r>t.length)&&(r=t.length),new E(t.subarray(e,r))};var Er=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],x=function(t,e,r){var n=new Error(e||Er[t]);if(n.code=t,Error.captureStackTrace&&Error.captureStackTrace(n,x),!r)throw n;return n},Tr=function(t,e,r,n){var i=t.length,o=n?n.length:0;if(!i||e.f&&!e.l)return r||new E(0);var s=!r,a=s||e.i!=2,l=e.i;s&&(r=new E(i*3));var v=function(wt){var St=r.length;if(wt>St){var xt=new E(Math.max(St*2,wt));xt.set(r),r=xt}},f=e.f||0,u=e.p||0,m=e.b||0,O=e.l,Y=e.d,M=e.m,R=e.n,D=i*8;do{if(!O){f=P(t,u,1);var z=P(t,u+1,3);if(u+=3,z)if(z==1)O=wr,Y=Sr,M=9,R=5;else if(z==2){var ce=P(t,u,31)+257,ye=P(t,u+10,15)+4,Z=ce+P(t,u+5,31)+1;u+=14;for(var b=new E(Z),K=new E(19),w=0;w<ye;++w)K[pr[w]]=P(t,u+w*3,7);u+=ye*3;for(var le=Ce(K),_r=(1<<le)-1,kr=se(K,le,1),w=0;w<Z;){var dt=kr[P(t,u,_r)];u+=dt&15;var S=dt>>4;if(S<16)b[w++]=S;else{var q=0,we=0;for(S==16?(we=3+P(t,u,3),u+=2,q=b[w-1]):S==17?(we=3+P(t,u,7),u+=3):S==18&&(we=11+P(t,u,127),u+=7);we--;)b[w++]=q}}var vt=b.subarray(0,ce),N=b.subarray(ce);M=Ce(vt),R=Ce(N),O=se(vt,M,1),Y=se(N,R,1)}else x(1);else{var S=xr(u)+4,V=t[S-4]|t[S-3]<<8,J=S+V;if(J>i){l&&x(0);break}a&&v(m+V),r.set(t.subarray(S,J),m),e.b=m+=V,e.p=u=J*8,e.f=f;continue}if(u>D){l&&x(0);break}}a&&v(m+131072);for(var Lr=(1<<M)-1,Mr=(1<<R)-1,ke=u;;ke=u){var q=O[Ae(t,u)&Lr],X=q>>4;if(u+=q&15,u>D){l&&x(0);break}if(q||x(2),X<256)r[m++]=X;else if(X==256){ke=u,O=null;break}else{var mt=X-254;if(X>264){var w=X-257,ue=lt[w];mt=P(t,u,(1<<ue)-1)+ft[w],u+=ue}var Le=Y[Ae(t,u)&Mr],Me=Le>>4;Le||x(3),u+=Le&15;var N=gr[Me];if(Me>3){var ue=ut[Me];N+=Ae(t,u)&(1<<ue)-1,u+=ue}if(u>D){l&&x(0);break}a&&v(m+131072);var gt=m+mt;if(m<N){var yt=o-N,Vr=Math.min(N,gt);for(yt+m<0&&x(3);m<Vr;++m)r[m]=n[yt+m]}for(;m<gt;++m)r[m]=r[m-N]}}e.l=O,e.p=ke,e.b=m,e.f=f,O&&(f=1,e.m=M,e.d=Y,e.n=R)}while(!f);return m!=r.length&&s?_e(r,0,m):r.subarray(0,m)};var wn=new E(0);var Sn=function(t,e){var r={};for(var n in t)r[n]=t[n];for(var n in e)r[n]=e[n];return r},lr=function(t,e,r){for(var n=t(),i=t.toString(),o=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/\s+/g,"").split(","),s=0;s<n.length;++s){var a=n[s],l=o[s];if(typeof a=="function"){e+=";"+l+"=";var v=a.toString();if(a.prototype)if(v.indexOf("[native code]")!=-1){var f=v.indexOf(" ",8)+1;e+=v.slice(f,v.indexOf("(",f))}else{e+=v;for(var u in a.prototype)e+=";"+l+".prototype."+u+"="+a.prototype[u].toString()}else e+=v}else r[l]=a}return e},Ie=[],xn=function(t){var e=[];for(var r in t)t[r].buffer&&e.push((t[r]=new t[r].constructor(t[r])).buffer);return e},En=function(t,e,r,n){if(!Ie[r]){for(var i="",o={},s=t.length-1,a=0;a<s;++a)i=lr(t[a],i,o);Ie[r]={c:lr(t[s],i,o),e:o}}var l=Sn({},Ie[r].e);return gn(Ie[r].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+e.toString()+"}",r,l,xn(l),n)},Tn=function(){return[E,$,hr,lt,ut,pr,ft,gr,wr,Sr,Oe,Er,se,Ce,P,Ae,xr,_e,x,Tr,ht,Rr,Dr]};var Rr=function(t){return postMessage(t,[t.buffer])},Dr=function(t){return t&&{out:t.size&&new E(t.size),dictionary:t.dictionary}},Rn=function(t,e,r,n,i,o){var s=En(r,n,i,function(a,l){s.terminate(),o(a,l)});return s.postMessage([t,e],e.consume?[t.buffer]:[]),function(){s.terminate()}};var k=function(t,e){return t[e]|t[e+1]<<8},A=function(t,e){return(t[e]|t[e+1]<<8|t[e+2]<<16|t[e+3]<<24)>>>0},at=function(t,e){return A(t,e)+A(t,e+4)*4294967296};function Dn(t,e,r){return r||(r=e,e={}),typeof r!="function"&&x(7),Rn(t,e,[Tn],function(n){return Rr(ht(n.data[0],Dr(n.data[1])))},1,r)}function ht(t,e){return Tr(t,{i:2},e&&e.out,e&&e.dictionary)}var ct=typeof TextDecoder<"u"&&new TextDecoder,bn=0;try{ct.decode(wn,{stream:!0}),bn=1}catch{}var In=function(t){for(var e="",r=0;;){var n=t[r++],i=(n>127)+(n>223)+(n>239);if(r+i>t.length)return{s:e,r:_e(t,r-1)};i?i==3?(n=((n&15)<<18|(t[r++]&63)<<12|(t[r++]&63)<<6|t[r++]&63)-65536,e+=String.fromCharCode(55296|n>>10,56320|n&1023)):i&1?e+=String.fromCharCode((n&31)<<6|t[r++]&63):e+=String.fromCharCode((n&15)<<12|(t[r++]&63)<<6|t[r++]&63):e+=String.fromCharCode(n)}};function Pn(t,e){if(e){for(var r="",n=0;n<t.length;n+=16384)r+=String.fromCharCode.apply(null,t.subarray(n,n+16384));return r}else{if(ct)return ct.decode(t);var i=In(t),o=i.s,r=i.r;return r.length&&x(8),o}}var Cn=function(t,e){return e+30+k(t,e+26)+k(t,e+28)},An=function(t,e,r){var n=k(t,e+28),i=Pn(t.subarray(e+46,e+46+n),!(k(t,e+8)&2048)),o=e+46+n,s=A(t,e+20),a=r&&s==4294967295?On(t,o):[s,A(t,e+24),A(t,e+42)],l=a[0],v=a[1],f=a[2];return[k(t,e+10),l,v,i,o+k(t,e+30)+k(t,e+32),f]},On=function(t,e){for(;k(t,e)!=1;e+=4+k(t,e+2));return[at(t,e+12),at(t,e+4),at(t,e+20)]};var ur=typeof queueMicrotask=="function"?queueMicrotask:typeof setTimeout=="function"?setTimeout:function(t){t()};function br(t,e,r){r||(r=e,e={}),typeof r!="function"&&x(7);var n=[],i=function(){for(var R=0;R<n.length;++R)n[R]()},o={},s=function(R,D){ur(function(){r(R,D)})};ur(function(){s=r});for(var a=t.length-22;A(t,a)!=101010256;--a)if(!a||t.length-a>65558)return s(x(13,0,1),null),i;var l=k(t,a+8);if(l){var v=l,f=A(t,a+16),u=f==4294967295||v==65535;if(u){var m=A(t,a-12);u=A(t,m)==101075792,u&&(v=l=A(t,m+32),f=A(t,m+48))}for(var O=e&&e.filter,Y=function(R){var D=An(t,f,u),z=D[0],S=D[1],V=D[2],J=D[3],ce=D[4],ye=D[5],Z=Cn(t,ye);f=ce;var b=function(w,le){w?(i(),s(w,null)):(le&&(o[J]=le),--l||s(null,o))};if(!O||O({name:J,size:S,originalSize:V,compression:z}))if(!z)b(null,_e(t,Z,Z+S));else if(z==8){var K=t.subarray(Z,Z+S);if(V<524288||S>.8*V)try{b(null,ht(K,{out:new E(V)}))}catch(w){b(w,null)}else n.push(Dn(K,{size:V},b))}else b(x(14,"unknown compression type "+z,1),null);else b(null,null)},M=0;M<v;++M)Y(M)}else s(null,{});return i}var Cr=require("fs"),L=require("fs/promises"),ae=require("path");c();function Ir(t){function e(s,a,l,v){let f=0;return f+=s<<0,f+=a<<8,f+=l<<16,f+=v<<24>>>0,f}if(t[0]===80&&t[1]===75&&t[2]===3&&t[3]===4)return t;if(t[0]!==67||t[1]!==114||t[2]!==50||t[3]!==52)throw new Error("Invalid header: Does not start with Cr24");let r=t[4]===3,n=t[4]===2;if(!n&&!r||t[5]||t[6]||t[7])throw new Error("Unexpected crx format version number.");if(n){let s=e(t[8],t[9],t[10],t[11]),a=e(t[12],t[13],t[14],t[15]),l=16+s+a;return t.subarray(l,t.length)}let o=12+e(t[8],t[9],t[10],t[11]);return t.subarray(o,t.length)}He();var _n=(0,ae.join)(Se,"ExtensionCache");async function kn(t,e){return await(0,L.mkdir)(e,{recursive:!0}),new Promise((r,n)=>{br(t,(i,o)=>{if(i)return void n(i);Promise.all(Object.keys(o).map(async s=>{if(s.startsWith("_metadata/"))return;if(s.endsWith("/"))return void(0,L.mkdir)((0,ae.join)(e,s),{recursive:!0});let a=s.split("/"),l=a.pop(),v=a.join("/"),f=(0,ae.join)(e,v);v&&await(0,L.mkdir)(f,{recursive:!0}),await(0,L.writeFile)((0,ae.join)(f,l),o[s])})).then(()=>r()).catch(s=>{(0,L.rm)(e,{recursive:!0,force:!0}),n(s)})})})}async function Ar(t){let e=(0,ae.join)(_n,`${t}`);try{await(0,L.access)(e,Cr.constants.F_OK)}catch{let n=`https://clients2.google.com/service/update2/crx?response=redirect&acceptformat=crx2,crx3&x=id%3D${t}%26uc&prodversion=${process.versions.chrome}`,i=await Te(n,{headers:{"User-Agent":`Electron ${process.versions.electron} ~ Vencord (https://github.com/Vendicated/Vencord)`}});await kn(Ir(i),e).catch(o=>console.error(`Failed to extract extension ${t}`,o))}Pr.session.defaultSession.loadExtension(e)}B.app.whenReady().then(()=>{B.protocol.handle("vencord",({url:t})=>{let e=decodeURI(t).slice(10).replace(/\?v=\d+$/,"");if(e.endsWith("/")&&(e=e.slice(0,-1)),e.startsWith("/themes/")){let r=e.slice(8),n=st(j,r);return n?B.net.fetch((0,pt.pathToFileURL)(n).toString()):new Response(null,{status:404})}switch(e){case"renderer.js.map":case"vencordDesktopRenderer.js.map":case"preload.js.map":case"vencordDesktopPreload.js.map":case"patcher.js.map":case"vencordDesktopMain.js.map":return B.net.fetch((0,pt.pathToFileURL)((0,Or.join)(__dirname,e)).toString());default:return new Response(null,{status:404})}});try{T.store.enableReactDevtools&&Ar("fmkadmapgofadopljbjfkapdkoienihi").then(()=>console.info("[Vencord] Installed React Developer Tools")).catch(t=>console.error("[Vencord] Failed to install React Developer Tools",t))}catch{}Ct()});
//# sourceURL=file:///VencordDesktopMain
//# sourceMappingURL=vencord://vencordDesktopMain.js.map
/*! For license information please see vencordDesktopMain.js.LEGAL.txt */