-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpatcher.js
More file actions
31 lines (29 loc) · 39.7 KB
/
patcher.js
File metadata and controls
31 lines (29 loc) · 39.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Vencord 15e92a4
// Standalone: true
// Platform: Universal
// Updater Disabled: false
"use strict";var nn=Object.create;var Pe=Object.defineProperty;var on=Object.getOwnPropertyDescriptor;var sn=Object.getOwnPropertyNames;var an=Object.getPrototypeOf,cn=Object.prototype.hasOwnProperty;var E=(e,t)=>()=>(e&&(t=e(e=0)),t);var ae=(e,t)=>{for(var r in t)Pe(e,r,{get:t[r],enumerable:!0})},kt=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of sn(t))!cn.call(e,i)&&i!==r&&Pe(e,i,{get:()=>t[i],enumerable:!(n=on(t,i))||n.enumerable});return e};var Lt=(e,t,r)=>(r=e!=null?nn(an(e)):{},kt(t||!e||!e.__esModule?Pe(r,"default",{value:e,enumerable:!0}):r,e)),He=e=>kt(Pe({},"__esModule",{value:!0}),e);var c=E(()=>{"use strict"});var ce=E(()=>{"use strict";c()});var $e,Vt,we,Mt=E(()=>{"use strict";c();$e=Symbol("SettingsStore.isProxy"),Vt=Symbol("SettingsStore.getRawTarget"),we=class{pathListeners=new Map;prefixListeners=new Map;globalListeners=new Set;proxyContexts=new WeakMap;proxyHandler=(()=>{let t=this;return{get(r,n,i){if(n===$e)return!0;if(n===Vt)return r;let o=Reflect.get(r,n,i),s=t.proxyContexts.get(r);if(s==null)return o;let{root:a,path:l}=s;if(!(n in r)&&t.getDefaultValue!=null&&(o=t.getDefaultValue({target:r,key:n,root:a,path:l})),typeof o=="object"&&o!==null&&!o[$e]){let m=`${l}${l&&"."}${n}`;return t.makeProxy(o,a,m)}return o},set(r,n,i){if(i?.[$e]&&(i=i[Vt]),r[n]===i)return!0;if(!Reflect.set(r,n,i))return!1;let o=t.proxyContexts.get(r);if(o==null)return!0;let{root:s,path:a}=o,l=`${a}${a&&"."}${n}`;return t.notifyListeners(l,i,s),!0},deleteProperty(r,n){if(!Reflect.deleteProperty(r,n))return!1;let i=t.proxyContexts.get(r);if(i==null)return!0;let{root:o,path:s}=i,a=`${s}${s&&"."}${n}`;return t.notifyListeners(a,void 0,o),!0}}})();constructor(t,r={}){this.plain=t,this.store=this.makeProxy(t),Object.assign(this,r)}makeProxy(t,r=t,n=""){return this.proxyContexts.set(t,{root:r,path:n}),new Proxy(t,this.proxyHandler)}notifyPrefixListeners(t,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,t))}}notifyListeners(t,r,n){let i=t.split(".");if(i.length>3&&i[0]==="plugins"){let o=i.slice(0,3),s=o.join("."),a=o.reduce((l,m)=>l[m],n);this.globalListeners.forEach(l=>l(n,s)),this.pathListeners.get(s)?.forEach(l=>l(a))}else this.globalListeners.forEach(o=>o(n,t));this.pathListeners.get(t)?.forEach(o=>o(r)),this.notifyPrefixListeners(t,i,r)}setData(t,r){if(this.readOnly)throw new Error("SettingsStore is read-only");if(this.plain=t,this.store=this.makeProxy(t),r){let n=t,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(t){this.globalListeners.add(t)}addChangeListener(t,r){let n=this.pathListeners.get(t)??new Set;n.add(r),this.pathListeners.set(t,n)}addPrefixChangeListener(t,r){let n=this.prefixListeners.get(t)??new Set;n.add(r),this.prefixListeners.set(t,n)}removeGlobalChangeListener(t){this.globalListeners.delete(t)}removeChangeListener(t,r){let n=this.pathListeners.get(t);n&&(n.delete(r),n.size||this.pathListeners.delete(t))}removePrefixChangeListener(t,r){let n=this.prefixListeners.get(t);n&&(n.delete(r),n.size||this.prefixListeners.delete(t))}markAsChanged(){this.globalListeners.forEach(t=>t(this.plain,""))}}});function Be(e,t){for(let r in t){let n=t[r];typeof n=="object"&&!Array.isArray(n)?(e[r]??={},Be(e[r],n)):e[r]??=n}return e}var Nt=E(()=>{"use strict";c()});var Ut,$,Ie,Q,B,le,qe,Ye,Gt,Ce,ue=E(()=>{"use strict";c();Ut=require("electron"),$=require("path"),Ie=process.env.VENCORD_USER_DATA_DIR??(process.env.DISCORD_USER_DATA_DIR?(0,$.join)(process.env.DISCORD_USER_DATA_DIR,"..","VencordData"):(0,$.join)(Ut.app.getPath("userData"),"..","Vencord")),Q=(0,$.join)(Ie,"settings"),B=(0,$.join)(Ie,"themes"),le=(0,$.join)(Q,"quickCss.css"),qe=(0,$.join)(Q,"settings.json"),Ye=(0,$.join)(Q,"native-settings.json"),Gt=["https:","http:","steam:","spotify:","com.epicgames.launcher:","tidal:","itunes:"],Ce=process.argv.includes("--vanilla")});function zt(e,t){try{return JSON.parse((0,X.readFileSync)(t,"utf-8"))}catch(r){return r?.code!=="ENOENT"&&console.error(`Failed to read ${e} settings`,r),{}}}var Je,X,T,ln,Ft,M,F=E(()=>{"use strict";c();ce();Mt();Nt();Je=require("electron"),X=require("fs");ue();(0,X.mkdirSync)(Q,{recursive:!0});T=new we(zt("renderer",qe));T.addGlobalChangeListener(()=>{try{(0,X.writeFileSync)(qe,JSON.stringify(T.plain,null,4))}catch(e){console.error("Failed to write renderer settings",e)}});Je.ipcMain.on("VencordGetSettings",e=>e.returnValue=T.plain);Je.ipcMain.handle("VencordSetSettings",(e,t,r)=>{T.setData(t,r)});ln={plugins:{},customCspRules:{}},Ft=zt("native",Ye);Be(Ft,ln);M=new we(Ft);M.addGlobalChangeListener(()=>{try{(0,X.writeFileSync)(Ye,JSON.stringify(M.plain,null,4))}catch(e){console.error("Failed to write native settings",e)}})});async function Ht(e,t){try{var r=await fetch(e,t)}catch(i){throw i instanceof Error&&i.cause&&(i=i.cause),new Error(`${t?.method??"GET"} ${e} failed: ${i}`)}if(r.ok)return r;let n=`${t?.method??"GET"} ${e}: ${r.status} ${r.statusText}`;try{let i=await r.text();n+=`
${i}`}catch{}throw new Error(n)}async function $t(e,t){return(await Ht(e,t)).json()}async function Ae(e,t){let n=await(await Ht(e,t)).arrayBuffer();return Buffer.from(n)}var pn,et=E(()=>{"use strict";c();pn=require("original-fs")});var Se,tt=E(()=>{c();Se="15e92a4"});var he,rt=E(()=>{c();he="Vendicated/Vencord"});var Oe,nt=E(()=>{"use strict";c();tt();rt();Oe=`Vencord/${Se}${he?` (https://github.com/${he})`:""}`});function xe(e){return async function(){try{return{ok:!0,value:await e(...arguments)}}catch(t){return{ok:!1,error:t instanceof Error?{...t,message:t.message,name:t.name,stack:t.stack}:t}}}}var Bt,qt=E(()=>{"use strict";c();Bt=["patcher.js","preload.js","renderer.js","renderer.css"]});var gn={};async function Kt(e){return $t(dn+e,{headers:{Accept:"application/vnd.github+json","User-Agent":Oe}})}async function mn(){return await Qt()?(await Kt(`/compare/${Se}...HEAD`)).commits.map(r=>({hash:r.sha.slice(0,7),author:r.author.login,message:r.commit.message.split(`
`)[0]})):[]}async function Qt(){let e=await Kt("/releases/latest");return e.name.slice(e.name.lastIndexOf(" ")+1)===Se?!1:(e.assets.forEach(({name:r,browser_download_url:n})=>{Bt.some(i=>r.startsWith(i))&&it.push([r,n])}),!0)}async function vn(){let e=await Promise.all(it.map(async([t,r])=>{let n=await Ae(r);return[(0,Jt.join)(__dirname,t),n]}));return await Promise.all(e.map(async([t,r])=>(0,Yt.writeFile)(t,r))),it=[],!0}var Ee,Yt,Jt,dn,it,Xt=E(()=>{"use strict";c();et();ce();nt();Ee=require("electron"),Yt=require("fs/promises"),Jt=require("path");tt();rt();qt();dn=`https://api.github.com/repos/${he}`,it=[];Ee.ipcMain.handle("VencordGetRepo",xe(()=>`https://github.com/${he}`));Ee.ipcMain.handle("VencordGetUpdates",xe(mn));Ee.ipcMain.handle("VencordUpdate",xe(Qt));Ee.ipcMain.handle("VencordBuild",xe(vn))});function $r(e,t,r){let n=t;if(t in e)return void r(e[n]);Object.defineProperty(e,t,{set(i){delete e[n],e[n]=i,r(i)},configurable:!0,enumerable:!1})}var Br=E(()=>{"use strict";c()});var ri={};function ei(e,t){let r=e.slice(4).split(".").map(Number),n=t.slice(4).split(".").map(Number);for(let i=0;i<n.length;i++){if(r[i]>n[i])return!0;if(r[i]<n[i])return!1}return!1}function ti(){if(!process.env.DISABLE_UPDATER_AUTO_PATCHING)try{let e=(0,O.dirname)(process.execPath),t=(0,O.basename)(e),r=(0,O.join)(e,".."),n=(0,D.readdirSync)(r).reduce((a,l)=>l.startsWith("app-")&&ei(l,a)?l:a,t);if(n===t)return;let i=(0,O.join)(r,n,"resources"),o=(0,O.join)(i,"app.asar"),s=(0,O.join)(i,"_app.asar");if(!(0,D.existsSync)(o)||(0,D.statSync)(o).isDirectory())return;console.info("[Vencord] Detected Host Update. Repatching..."),(0,D.renameSync)(o,s),(0,D.mkdirSync)(o),(0,D.writeFileSync)((0,O.join)(o,"package.json"),JSON.stringify({name:"discord",main:"index.js"})),(0,D.writeFileSync)((0,O.join)(o,"index.js"),`require(${JSON.stringify((0,O.join)(__dirname,"patcher.js"))});`)}catch(e){console.error("[Vencord] Failed to repatch latest host update",e)}}var qr,D,O,Yr=E(()=>{"use strict";c();qr=require("electron"),D=require("original-fs"),O=require("path");qr.app.on("before-quit",ti)});var si={};var S,J,ni,ii,Tt,oi,Jr=E(()=>{"use strict";c();Br();S=Lt(require("electron")),J=require("path");F();ue();console.log("[Vencord] Starting up...");ni=require.main.filename,ii=require.main.path.endsWith("app.asar")?"_app.asar":"app.asar",Tt=(0,J.join)((0,J.dirname)(ni),"..",ii),oi=require((0,J.join)(Tt,"package.json"));require.main.filename=(0,J.join)(Tt,oi.main);S.app.setAppPath(Tt);if(Ce)console.log("[Vencord] Running in vanilla mode. Not loading Vencord");else{let e=T.store;if(process.platform==="win32"&&(Yr(),e.winCtrlQ)){let i=S.Menu.buildFromTemplate;S.Menu.buildFromTemplate=function(o){if(o[0]?.label==="&File"){let{submenu:s}=o[0];Array.isArray(s)&&s.push({label:"Quit (Hidden)",visible:!1,acceleratorWorksWhenHidden:!0,accelerator:"Control+Q",click:()=>S.app.quit()})}return i.call(this,o)}}class t extends S.default.BrowserWindow{constructor(o){if(o?.webPreferences?.preload&&o.title){let s=o.webPreferences.preload;o.webPreferences.preload=(0,J.join)(__dirname,"preload.js"),o.webPreferences.sandbox=!1,o.webPreferences.backgroundThrottling=!1,e.frameless?o.frame=!1:process.platform==="win32"&&e.winNativeTitleBar&&delete o.frame,e.transparent&&(o.transparent=!0,o.backgroundColor="#00000000"),e.disableMinSize&&(o.minWidth=0,o.minHeight=0),process.platform==="darwin"&&e.macosVibrancyStyle&&(o.backgroundColor="#00000000",e.macosVibrancyStyle&&(o.vibrancy=e.macosVibrancyStyle)),process.env.DISCORD_PRELOAD=s,super(o),e.disableMinSize&&(this.setMinimumSize=(l,m)=>{})}else super(o)}}Object.assign(t,S.default.BrowserWindow),Object.defineProperty(t,"name",{value:"BrowserWindow",configurable:!0});let r=require.resolve("electron");delete require.cache[r].exports,require.cache[r].exports={...S.default,BrowserWindow:t},$r(global,"appSettings",i=>{i.set("DANGEROUS_ENABLE_DEVTOOLS_ONLY_ENABLE_IF_YOU_KNOW_WHAT_YOURE_DOING",!0)}),process.env.DATA_DIR=(0,J.join)(S.app.getPath("userData"),"..","Vencord");let n=S.app.commandLine.appendSwitch;S.app.commandLine.appendSwitch=function(...i){if(i[0]==="disable-features"){let o=new Set((i[1]??"").split(","));o.add("WidgetLayering"),o.add("UseEcoQoSForBackgroundProcess"),i[1]+=[...o].join(",")}return n.apply(this,i)},S.app.commandLine.appendSwitch("disable-renderer-backgrounding"),S.app.commandLine.appendSwitch("disable-background-timer-throttling"),S.app.commandLine.appendSwitch("disable-backgrounding-occluded-windows")}console.log("[Vencord] Loading original Discord app.asar");require(require.main.filename)});c();var te=require("electron"),Kr=require("path"),Rt=require("url");c();F();var Ke=require("electron"),fe=["connect-src"],_=[...fe,"img-src"],jt=["style-src","font-src"],y=[..._,...jt],Wt=[...y,"script-src","worker-src"],Xe={"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":jt,"i.imgur.com":_,"i.ibb.co":_,"i.pinimg.com":_,"*.tenor.com":_,"files.catbox.moe":y,"cdn.discordapp.com":y,"media.discordapp.net":_,"cdnjs.cloudflare.com":Wt,"cdn.jsdelivr.net":Wt,"api.github.com":fe,"ws.audioscrobbler.com":fe,"translate-pa.googleapis.com":fe,"*.vencord.dev":_,"manti.vendicated.dev":_,"decor.fieryflames.dev":fe,"ugc.decor.fieryflames.dev":_,"sponsor.ajay.app":fe,"dearrow-thumb.ajay.app":_,"usrbg.is-hardly.online":_,"icons.duckduckgo.com":_},Qe=(e,t)=>Object.keys(e).find(r=>r.toLowerCase()===t),un=e=>{let t={};return e.split(";").forEach(r=>{let[n,...i]=r.trim().split(/\s+/g);n&&!Object.prototype.hasOwnProperty.call(t,n)&&(t[n]=i)}),t},fn=e=>Object.entries(e).filter(([,t])=>t?.length).map(t=>t.flat().join(" ")).join("; "),hn=e=>{let t=Qe(e,"content-security-policy-report-only");t&&delete e[t];let r=Qe(e,"content-security-policy");if(r){let n=un(e[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(M.store.customCspRules))for(let a of s)i(a,o);for(let[o,s]of Object.entries(Xe))for(let a of s)i(a,o);e[r]=[fn(n)]}};function Zt(){Ke.session.defaultSession.webRequest.onHeadersReceived(({responseHeaders:e,resourceType:t},r)=>{if(e&&(t==="mainFrame"&&hn(e),t==="stylesheet")){let n=Qe(e,"content-type");n&&(e[n]=["text/css"])}r({cancel:!1,responseHeaders:e})}),Ke.session.defaultSession.webRequest.onHeadersReceived=()=>{}}c();c();Xt();c();ce();var pt=require("electron");c();var st={};ae(st,{fetchTrackData:()=>wn});c();nt();var er=require("child_process"),tr=require("util"),rr=(0,tr.promisify)(er.execFile);async function ot(e){let{stdout:t}=await rr("osascript",e.map(r=>["-e",r]).flat());return t}var k=null;async function yn({id:e,name:t,artist:r,album:n}){if(e===k?.id){if("data"in k)return k.data;if("failures"in k&&k.failures>=5)return null}try{let i=new URL("https://itunes.apple.com/search");i.searchParams.set("term",`${t} ${r} ${n}`),i.searchParams.set("media","music"),i.searchParams.set("entity","song");let o=await fetch(i,{headers:{"user-agent":Oe}}).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 k={id:e,data:{appleMusicLink:o.trackViewUrl,songLink:`https://song.link/i/${new URL(o.trackViewUrl).searchParams.get("i")}`,albumArtwork:o.artworkUrl100.replace("100x100","512x512"),artistArtwork:s}},k.data}catch(i){return console.error("[AppleMusicRichPresence] Failed to fetch remote data:",i),k={id:e,failures:(e===k?.id&&"failures"in k?k.failures:0)+1},null}}async function wn(){try{await rr("pgrep",["^Music$"])}catch{return null}if(await ot(['tell application "Music"',"get player state","end tell"]).then(p=>p.trim())!=="playing")return null;let t=await ot(['tell application "Music"',"get player position","end tell"]).then(p=>Number.parseFloat(p.trim())),r=await ot(['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(p=>!!p),l=Number.parseFloat(a),m=await yn({id:n,name:i,artist:s,album:o});return{name:i,album:o,artist:s,playerPosition:t,duration:l,...m}}var at={};ae(at,{initDevtoolsOpenEagerLoad:()=>Sn});c();function Sn(e){let t=()=>e.sender.executeJavaScript("Vencord.Plugins.plugins.ConsoleShortcuts.eagerLoad(true)");e.sender.isDevToolsOpened()?t():e.sender.once("devtools-opened",()=>t())}var ir={};c();F();var Le=require("electron"),ke=[];function nr(){let e=[];for(let t=ke.length-1;t>=0;t--){let{processId:r,routingId:n}=ke[t],i=Le.webFrameMain.fromId(r,n);if(!i){ke.splice(t,1);continue}e.push(i)}return e}Le.app.on("browser-window-created",(e,t)=>{t.webContents.on("frame-created",(r,{frame:n})=>{n?.once("dom-ready",()=>{if(n.url.startsWith("https://open.spotify.com/embed/")){nr();let{routingId:i,processId:o}=n;ke.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{nr().forEach(n=>n.executeJavaScript(`globalThis._vcVolume = ${r/100}`))}catch(n){console.error("FixSpotifyEmbeds: Failed to update volume",n)}})});var sr={};c();F();var or=require("electron");or.app.on("browser-window-created",(e,t)=>{t.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 ct={};ae(ct,{resolveRedirect:()=>En});c();var ar=require("https"),xn=/^https:\/\/(spotify\.link|s\.team)\/.+$/;function cr(e){return new Promise((t,r)=>{let n=(0,ar.request)(new URL(e),{method:"HEAD"},i=>{t(i.headers.location?cr(i.headers.location):e)});n.on("error",r),n.end()})}async function En(e,t){return xn.test(t)?cr(t):t}var lt={};ae(lt,{makeDeeplTranslateRequest:()=>Tn});c();async function Tn(e,t,r,n){let i=t?"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 ut={};ae(ut,{readRecording:()=>Rn});c();var lr=require("electron"),Ve=require("fs/promises"),Te=require("path");async function Rn(e,t){t=(0,Te.normalize)(t);let r=(0,Te.basename)(t),n=(0,Te.normalize)(lr.app.getPath("userData")+"/");if(!/^\d*recording\.ogg$/.test(r)||!t.startsWith(n))return null;try{let i=await(0,Ve.readFile)(t);return(0,Ve.rm)(t).catch(()=>{}),new Uint8Array(i.buffer)}catch{return null}}var ft={};ae(ft,{sendToOverlay:()=>bn});c();var fr=require("dgram"),ur;function bn(e,t){t.messageType=t.type;let r=JSON.stringify(t);ur??=(0,fr.createSocket)("udp4"),ur.send(r,42069,"127.0.0.1")}var pr={};c();F();var hr=require("electron");c();var ht=`"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()});
`;hr.app.on("browser-window-created",(e,t)=>{t.webContents.on("frame-created",(r,{frame:n})=>{n?.once("dom-ready",()=>{T.store.plugins?.YoutubeAdblock?.enabled&&(n.url.includes("youtube.com/embed/")?n.executeJavaScript(ht):n.parent?.url.includes("youtube.com/embed/")&&n.parent.executeJavaScript(ht))})})});var dr={AppleMusicRichPresence:st,ConsoleShortcuts:at,FixSpotifyEmbeds:ir,FixYoutubeEmbeds:sr,OpenInApp:ct,Translate:lt,VoiceMessages:ut,XSOverlay:ft,YoutubeAdblock:pr};var mr={};for(let[e,t]of Object.entries(dr)){let r=Object.entries(t);if(!r.length)continue;let n=mr[e]={};for(let[i,o]of r){let s=`VencordPluginNative_${e}_${i}`;pt.ipcMain.handle(s,o),n[i]=s}}pt.ipcMain.on("VencordGetPluginIpcMethodMap",e=>{e.returnValue=mr});F();c();function dt(e,t=300){let r;return function(...n){clearTimeout(r),r=setTimeout(()=>{e(...n)},t)}}ce();var g=require("electron");c();var vr="PCFkb2N0eXBlIGh0bWw+PGh0bWwgbGFuZz0iZW4iPjxoZWFkPjxtZXRhIGNoYXJzZXQ9InV0Zi04Ij48dGl0bGU+VmVuY29yZCBRdWlja0NTUyBFZGl0b3I8L3RpdGxlPjxsaW5rIHJlbD0ic3R5bGVzaGVldCIgaHJlZj0iaHR0cHM6Ly9jZG4uanNkZWxpdnIubmV0L25wbS9tb25hY28tZWRpdG9yQDAuNTAuMC9taW4vdnMvZWRpdG9yL2VkaXRvci5tYWluLmNzcyIgaW50ZWdyaXR5PSJzaGEyNTYtdGlKUFEyTzA0ei9wWi9Bd2R5SWdock9NemV3ZitQSXZFbDFZS2JRdnNaaz0iIGNyb3Nzb3JpZ2luPSJhbm9ueW1vdXMiIHJlZmVycmVycG9saWN5PSJuby1yZWZlcnJlciI+PHN0eWxlPiNjb250YWluZXIsYm9keSxodG1se3Bvc2l0aW9uOmFic29sdXRlO2xlZnQ6MDt0b3A6MDt3aWR0aDoxMDAlO2hlaWdodDoxMDAlO21hcmdpbjowO3BhZGRpbmc6MDtvdmVyZmxvdzpoaWRkZW59PC9zdHlsZT48L2hlYWQ+PGJvZHk+PGRpdiBpZD0iY29udGFpbmVyIj48L2Rpdj48c2NyaXB0IHNyYz0iaHR0cHM6Ly9jZG4uanNkZWxpdnIubmV0L25wbS9tb25hY28tZWRpdG9yQDAuNTAuMC9taW4vdnMvbG9hZGVyLmpzIiBpbnRlZ3JpdHk9InNoYTI1Ni1LY1U0OFRHcjg0cjd1bkY3SjVJZ0JvOTVhZVZyRWJyR2UwNFM3VGNGVWpzPSIgY3Jvc3NvcmlnaW49ImFub255bW91cyIgcmVmZXJyZXJwb2xpY3k9Im5vLXJlZmVycmVyIj48L3NjcmlwdD48c2NyaXB0PnJlcXVpcmUuY29uZmlnKHtwYXRoczp7dnM6Imh0dHBzOi8vY2RuLmpzZGVsaXZyLm5ldC9ucG0vbW9uYWNvLWVkaXRvckAwLjUwLjAvbWluL3ZzIn19KSxyZXF1aXJlKFsidnMvZWRpdG9yL2VkaXRvci5tYWluIl0sKCgpPT57Z2V0Q3VycmVudENzcygpLnRoZW4oKGU9Pnt2YXIgdD1tb25hY28uZWRpdG9yLmNyZWF0ZShkb2N1bWVudC5nZXRFbGVtZW50QnlJZCgiY29udGFpbmVyIikse3ZhbHVlOmUsbGFuZ3VhZ2U6ImNzcyIsdGhlbWU6Z2V0VGhlbWUoKX0pO3Qub25EaWRDaGFuZ2VNb2RlbENvbnRlbnQoKCgpPT5zZXRDc3ModC5nZXRWYWx1ZSgpKSkpLHdpbmRvdy5hZGRFdmVudExpc3RlbmVyKCJyZXNpemUiLCgoKT0+e3QubGF5b3V0KCl9KSl9KSl9KSk8L3NjcmlwdD48L2JvZHk+PC9odG1sPg==";var W=require("fs"),Y=require("fs/promises"),q=require("path");c();F();ce();var pe=require("electron");function gr(){pe.ipcMain.handle("VencordCspRemoveOverride",Cn),pe.ipcMain.handle("VencordCspRequestAddOverride",In),pe.ipcMain.handle("VencordCspIsDomainAllowed",_n)}function Dn(e,t){try{let{host:r}=new URL(e);if(/[;'"\\]/.test(r))return!1}catch{return!1}return!(t.length===0||t.some(r=>!y.includes(r)))}function Pn(e,t,r){let n=new URL(e).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 Discord for the changes to take effect.`;if(t.length===1&&t[0]==="connect-src")return{message:i,detail:o};let s=t.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 In(e,t,r,n){if(!Dn(t,r))return"invalid";let i=new URL(t).host;if(i in M.store.customCspRules)return"conflict";let{checkboxChecked:o,response:s}=await pe.dialog.showMessageBox({...Pn(t,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?(M.store.customCspRules[i]=r,"ok"):"unchecked"}function Cn(e,t){return t in M.store.customCspRules?(delete M.store.customCspRules[t],!0):!1}function _n(e,t,r){try{let n=new URL(t).host,i=Xe[n]??M.store.customCspRules[n];return i?r.every(o=>i.includes(o)):!1}catch{return!1}}c();var An=/[^\S\r\n]*?\r?(?:\r\n|\n)[^\S\r\n]*?\*[^\S\r\n]?/,On=/^\\@/;function mt(e,t={}){return{fileName:e,name:t.name??e.replace(/\.css$/i,""),author:t.author??"Unknown Author",description:t.description??"A Discord Theme.",version:t.version,license:t.license,source:t.source,website:t.website,invite:t.invite}}function yr(e){return e.charCodeAt(0)===65279&&(e=e.slice(1)),e}function wr(e,t){if(!e)return mt(t);let r=e.split("/**",2)?.[1]?.split("*/",1)?.[0];if(!r)return mt(t);let n={},i="",o="";for(let s of r.split(An))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(On,"@");return n[i]=o.trim(),delete n[""],mt(t,n)}ue();c();var Sr=require("electron");function xr(e){e.webContents.setWindowOpenHandler(({url:t})=>{switch(t){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(t)}catch{return{action:"deny"}}switch(r){case"http:":case"https:":case"mailto:":case"steam:":case"spotify:":Sr.shell.openExternal(t)}return{action:"deny"}})}var kn=(0,q.join)(__dirname,"renderer.css");(0,W.mkdirSync)(B,{recursive:!0});gr();function vt(e,t){let r=(0,q.normalize)(e+"/"),n=(0,q.join)(e,t),i=(0,q.normalize)(n);return i.startsWith(r)?i:null}function Er(){return(0,Y.readFile)(le,"utf-8").catch(()=>"")}async function Ln(){let e=await(0,Y.readdir)(B).catch(()=>[]),t=[];for(let r of e){if(!r.endsWith(".css"))continue;let n=await Tr(r).then(yr).catch(()=>null);n!=null&&t.push(wr(n,r))}return t}function Tr(e){e=e.replace(/\?v=\d+$/,"");let t=vt(B,e);return t?(0,Y.readFile)(t,"utf-8"):Promise.reject(`Unsafe path ${e}`)}g.ipcMain.handle("VencordOpenQuickCss",()=>g.shell.openPath(le));g.ipcMain.handle("VencordOpenExternal",(e,t)=>{try{var{protocol:r}=new URL(t)}catch{throw"Malformed URL"}if(!Gt.includes(r))throw"Disallowed protocol.";g.shell.openExternal(t)});g.ipcMain.handle("VencordGetQuickCss",()=>Er());g.ipcMain.handle("VencordSetQuickCss",(e,t)=>(0,W.writeFileSync)(le,t));g.ipcMain.handle("VencordGetThemesList",()=>Ln());g.ipcMain.handle("VencordGetThemeData",(e,t)=>Tr(t));g.ipcMain.handle("VencordGetThemeSystemValues",()=>{let e=g.systemPreferences.getAccentColor?.()??"";return e.length&&e[0]!=="#"&&(e=`#${e}`),{"os-accent-color":e}});g.ipcMain.handle("VencordOpenThemesFolder",()=>g.shell.openPath(B));g.ipcMain.handle("VencordOpenSettingsFolder",()=>g.shell.openPath(Q));g.ipcMain.handle("VencordInitFileWatchers",({sender:e})=>{let t,r;(0,Y.open)(le,"a+").then(i=>{i.close(),t=(0,W.watch)(le,{persistent:!1},dt(async()=>{e.postMessage("VencordQuickCssUpdate",await Er())},50))}).catch(()=>{});let n=(0,W.watch)(B,{persistent:!1},dt(()=>{e.postMessage("VencordThemeUpdate",void 0)}));e.once("destroyed",()=>{t?.close(),n.close(),r?.close()})});g.ipcMain.on("VencordGetMonacoTheme",e=>{e.returnValue=g.nativeTheme.shouldUseDarkColors?"vs-dark":"vs-light"});g.ipcMain.handle("VencordOpenMonacoEditor",async()=>{let e="Vencord QuickCSS Editor",t=g.BrowserWindow.getAllWindows().find(n=>n.title===e);if(t&&!t.isDestroyed()){t.focus();return}let r=new g.BrowserWindow({title:e,autoHideMenuBar:!0,darkTheme:!0,webPreferences:{preload:(0,q.join)(__dirname,"preload.js"),contextIsolation:!0,nodeIntegration:!1,sandbox:!1}});xr(r),await r.loadURL(`data:text/html;base64,${vr}`)});g.ipcMain.handle("VencordGetRendererCss",()=>(0,Y.readFile)(kn,"utf-8"));g.ipcMain.on("VencordPreloadGetRendererJs",e=>{e.returnValue=(0,W.readFileSync)((0,q.join)(__dirname,"renderer.js"),"utf-8")});F();ue();c();var jr=require("electron");c();var Dr=require("module"),Vn=(0,Dr.createRequire)("/"),Ne,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{Ne=Vn("worker_threads").Worker}catch{}var Nn=Ne?function(e,t,r,n,i){var o=!1,s=new Ne(e+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,Ne.prototype.terminate.call(s)},s}:function(e,t,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}},b=Uint8Array,ee=Uint16Array,Pr=Int32Array,wt=new b([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]),St=new b([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]),Ir=new b([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Cr=function(e,t){for(var r=new ee(31),n=0;n<31;++n)r[n]=t+=1<<e[n-1];for(var i=new Pr(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}},_r=Cr(wt,2),xt=_r.b,Un=_r.r;xt[28]=258,Un[258]=28;var Ar=Cr(St,0),Or=Ar.b,Zo=Ar.r,ze=new ee(32768);for(d=0;d<32768;++d)j=(d&43690)>>1|(d&21845)<<1,j=(j&52428)>>2|(j&13107)<<2,j=(j&61680)>>4|(j&3855)<<4,ze[d]=((j&65280)>>8|(j&255)<<8)>>1;var j,d,de=(function(e,t,r){for(var n=e.length,i=0,o=new ee(t);i<n;++i)e[i]&&++o[e[i]-1];var s=new ee(t);for(i=1;i<t;++i)s[i]=s[i-1]+o[i-1]<<1;var a;if(r){a=new ee(1<<t);var l=15-t;for(i=0;i<n;++i)if(e[i])for(var m=i<<4|e[i],p=t-e[i],u=s[e[i]-1]++<<p,v=u|(1<<p)-1;u<=v;++u)a[ze[u]>>l]=m}else for(a=new ee(n),i=0;i<n;++i)e[i]&&(a[i]=ze[s[e[i]-1]++]>>15-e[i]);return a}),Re=new b(288);for(d=0;d<144;++d)Re[d]=8;var d;for(d=144;d<256;++d)Re[d]=9;var d;for(d=256;d<280;++d)Re[d]=7;var d;for(d=280;d<288;++d)Re[d]=8;var d,kr=new b(32);for(d=0;d<32;++d)kr[d]=5;var d;var Lr=de(Re,9,1);var Vr=de(kr,5,1),Ue=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},A=function(e,t,r){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(t&7)&r},Ge=function(e,t){var r=t/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(t&7)},Mr=function(e){return(e+7)/8|0},Fe=function(e,t,r){return(t==null||t<0)&&(t=0),(r==null||r>e.length)&&(r=e.length),new b(e.subarray(t,r))};var Nr=["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"],R=function(e,t,r){var n=new Error(t||Nr[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,R),!r)throw n;return n},Ur=function(e,t,r,n){var i=e.length,o=n?n.length:0;if(!i||t.f&&!t.l)return r||new b(0);var s=!r,a=s||t.i!=2,l=t.i;s&&(r=new b(i*3));var m=function(_t){var At=r.length;if(_t>At){var Ot=new b(Math.max(At*2,_t));Ot.set(r),r=Ot}},p=t.f||0,u=t.p||0,v=t.b||0,V=t.l,re=t.d,G=t.m,P=t.n,I=i*8;do{if(!V){p=A(e,u,1);var Z=A(e,u+1,3);if(u+=3,Z)if(Z==1)V=Lr,re=Vr,G=9,P=5;else if(Z==2){var ve=A(e,u,31)+257,be=A(e,u+10,15)+4,K=ve+A(e,u+5,31)+1;u+=14;for(var C=new b(K),ie=new b(19),w=0;w<be;++w)ie[Ir[w]]=A(e,u+w*3,7);u+=be*3;for(var ge=Ue(ie),Qr=(1<<ge)-1,Xr=de(ie,ge,1),w=0;w<K;){var bt=Xr[A(e,u,Qr)];u+=bt&15;var x=bt>>4;if(x<16)C[w++]=x;else{var oe=0,De=0;for(x==16?(De=3+A(e,u,3),u+=2,oe=C[w-1]):x==17?(De=3+A(e,u,7),u+=3):x==18&&(De=11+A(e,u,127),u+=7);De--;)C[w++]=oe}}var Dt=C.subarray(0,ve),H=C.subarray(ve);G=Ue(Dt),P=Ue(H),V=de(Dt,G,1),re=de(H,P,1)}else R(1);else{var x=Mr(u)+4,z=e[x-4]|e[x-3]<<8,ne=x+z;if(ne>i){l&&R(0);break}a&&m(v+z),r.set(e.subarray(x,ne),v),t.b=v+=z,t.p=u=ne*8,t.f=p;continue}if(u>I){l&&R(0);break}}a&&m(v+131072);for(var en=(1<<G)-1,tn=(1<<P)-1,We=u;;We=u){var oe=V[Ge(e,u)&en],se=oe>>4;if(u+=oe&15,u>I){l&&R(0);break}if(oe||R(2),se<256)r[v++]=se;else if(se==256){We=u,V=null;break}else{var Pt=se-254;if(se>264){var w=se-257,ye=wt[w];Pt=A(e,u,(1<<ye)-1)+xt[w],u+=ye}var je=re[Ge(e,u)&tn],Ze=je>>4;je||R(3),u+=je&15;var H=Or[Ze];if(Ze>3){var ye=St[Ze];H+=Ge(e,u)&(1<<ye)-1,u+=ye}if(u>I){l&&R(0);break}a&&m(v+131072);var It=v+Pt;if(v<H){var Ct=o-H,rn=Math.min(H,It);for(Ct+v<0&&R(3);v<rn;++v)r[v]=n[Ct+v]}for(;v<It;++v)r[v]=r[v-H]}}t.l=V,t.p=We,t.b=v,t.f=p,V&&(p=1,t.m=G,t.d=re,t.n=P)}while(!p);return v!=r.length&&s?Fe(r,0,v):r.subarray(0,v)};var Gn=new b(0);var zn=function(e,t){var r={};for(var n in e)r[n]=e[n];for(var n in t)r[n]=t[n];return r},Rr=function(e,t,r){for(var n=e(),i=e.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"){t+=";"+l+"=";var m=a.toString();if(a.prototype)if(m.indexOf("[native code]")!=-1){var p=m.indexOf(" ",8)+1;t+=m.slice(p,m.indexOf("(",p))}else{t+=m;for(var u in a.prototype)t+=";"+l+".prototype."+u+"="+a.prototype[u].toString()}else t+=m}else r[l]=a}return t},Me=[],Fn=function(e){var t=[];for(var r in e)e[r].buffer&&t.push((e[r]=new e[r].constructor(e[r])).buffer);return t},Wn=function(e,t,r,n){if(!Me[r]){for(var i="",o={},s=e.length-1,a=0;a<s;++a)i=Rr(e[a],i,o);Me[r]={c:Rr(e[s],i,o),e:o}}var l=zn({},Me[r].e);return Nn(Me[r].c+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+t.toString()+"}",r,l,Fn(l),n)},jn=function(){return[b,ee,Pr,wt,St,Ir,xt,Or,Lr,Vr,ze,Nr,de,Ue,A,Ge,Mr,Fe,R,Ur,Et,Gr,zr]};var Gr=function(e){return postMessage(e,[e.buffer])},zr=function(e){return e&&{out:e.size&&new b(e.size),dictionary:e.dictionary}},Zn=function(e,t,r,n,i,o){var s=Wn(r,n,i,function(a,l){s.terminate(),o(a,l)});return s.postMessage([e,t],t.consume?[e.buffer]:[]),function(){s.terminate()}};var N=function(e,t){return e[t]|e[t+1]<<8},L=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},gt=function(e,t){return L(e,t)+L(e,t+4)*4294967296};function Hn(e,t,r){return r||(r=t,t={}),typeof r!="function"&&R(7),Zn(e,t,[jn],function(n){return Gr(Et(n.data[0],zr(n.data[1])))},1,r)}function Et(e,t){return Ur(e,{i:2},t&&t.out,t&&t.dictionary)}var yt=typeof TextDecoder<"u"&&new TextDecoder,$n=0;try{yt.decode(Gn,{stream:!0}),$n=1}catch{}var Bn=function(e){for(var t="",r=0;;){var n=e[r++],i=(n>127)+(n>223)+(n>239);if(r+i>e.length)return{s:t,r:Fe(e,r-1)};i?i==3?(n=((n&15)<<18|(e[r++]&63)<<12|(e[r++]&63)<<6|e[r++]&63)-65536,t+=String.fromCharCode(55296|n>>10,56320|n&1023)):i&1?t+=String.fromCharCode((n&31)<<6|e[r++]&63):t+=String.fromCharCode((n&15)<<12|(e[r++]&63)<<6|e[r++]&63):t+=String.fromCharCode(n)}};function qn(e,t){if(t){for(var r="",n=0;n<e.length;n+=16384)r+=String.fromCharCode.apply(null,e.subarray(n,n+16384));return r}else{if(yt)return yt.decode(e);var i=Bn(e),o=i.s,r=i.r;return r.length&&R(8),o}}var Yn=function(e,t){return t+30+N(e,t+26)+N(e,t+28)},Jn=function(e,t,r){var n=N(e,t+28),i=qn(e.subarray(t+46,t+46+n),!(N(e,t+8)&2048)),o=t+46+n,s=L(e,t+20),a=r&&s==4294967295?Kn(e,o):[s,L(e,t+24),L(e,t+42)],l=a[0],m=a[1],p=a[2];return[N(e,t+10),l,m,i,o+N(e,t+30)+N(e,t+32),p]},Kn=function(e,t){for(;N(e,t)!=1;t+=4+N(e,t+2));return[gt(e,t+12),gt(e,t+4),gt(e,t+20)]};var br=typeof queueMicrotask=="function"?queueMicrotask:typeof setTimeout=="function"?setTimeout:function(e){e()};function Fr(e,t,r){r||(r=t,t={}),typeof r!="function"&&R(7);var n=[],i=function(){for(var P=0;P<n.length;++P)n[P]()},o={},s=function(P,I){br(function(){r(P,I)})};br(function(){s=r});for(var a=e.length-22;L(e,a)!=101010256;--a)if(!a||e.length-a>65558)return s(R(13,0,1),null),i;var l=N(e,a+8);if(l){var m=l,p=L(e,a+16),u=p==4294967295||m==65535;if(u){var v=L(e,a-12);u=L(e,v)==101075792,u&&(m=l=L(e,v+32),p=L(e,v+48))}for(var V=t&&t.filter,re=function(P){var I=Jn(e,p,u),Z=I[0],x=I[1],z=I[2],ne=I[3],ve=I[4],be=I[5],K=Yn(e,be);p=ve;var C=function(w,ge){w?(i(),s(w,null)):(ge&&(o[ne]=ge),--l||s(null,o))};if(!V||V({name:ne,size:x,originalSize:z,compression:Z}))if(!Z)C(null,Fe(e,K,K+x));else if(Z==8){var ie=e.subarray(K,K+x);if(z<524288||x>.8*z)try{C(null,Et(ie,{out:new b(z)}))}catch(w){C(w,null)}else n.push(Hn(ie,{size:z},C))}else C(R(14,"unknown compression type "+Z,1),null);else C(null,null)},G=0;G<m;++G)re(G)}else s(null,{});return i}var Zr=require("fs"),U=require("fs/promises"),me=require("path");ue();c();function Wr(e){function t(s,a,l,m){let p=0;return p+=s<<0,p+=a<<8,p+=l<<16,p+=m<<24>>>0,p}if(e[0]===80&&e[1]===75&&e[2]===3&&e[3]===4)return e;if(e[0]!==67||e[1]!==114||e[2]!==50||e[3]!==52)throw new Error("Invalid header: Does not start with Cr24");let r=e[4]===3,n=e[4]===2;if(!n&&!r||e[5]||e[6]||e[7])throw new Error("Unexpected crx format version number.");if(n){let s=t(e[8],e[9],e[10],e[11]),a=t(e[12],e[13],e[14],e[15]),l=16+s+a;return e.subarray(l,e.length)}let o=12+t(e[8],e[9],e[10],e[11]);return e.subarray(o,e.length)}et();var Qn=(0,me.join)(Ie,"ExtensionCache");async function Xn(e,t){return await(0,U.mkdir)(t,{recursive:!0}),new Promise((r,n)=>{Fr(e,(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,U.mkdir)((0,me.join)(t,s),{recursive:!0});let a=s.split("/"),l=a.pop(),m=a.join("/"),p=(0,me.join)(t,m);m&&await(0,U.mkdir)(p,{recursive:!0}),await(0,U.writeFile)((0,me.join)(p,l),o[s])})).then(()=>r()).catch(s=>{(0,U.rm)(t,{recursive:!0,force:!0}),n(s)})})})}async function Hr(e){let t=(0,me.join)(Qn,`${e}`);try{await(0,U.access)(t,Zr.constants.F_OK)}catch{let n=`https://clients2.google.com/service/update2/crx?response=redirect&acceptformat=crx2,crx3&x=id%3D${e}%26uc&prodversion=${process.versions.chrome}`,i=await Ae(n,{headers:{"User-Agent":`Electron ${process.versions.electron} ~ Vencord (https://github.com/Vendicated/Vencord)`}});await Xn(Wr(i),t).catch(o=>console.error(`Failed to extract extension ${e}`,o))}jr.session.defaultSession.loadExtension(t)}Ce||te.app.whenReady().then(()=>{te.protocol.handle("vencord",({url:e})=>{let t=decodeURI(e).slice(10).replace(/\?v=\d+$/,"");if(t.endsWith("/")&&(t=t.slice(0,-1)),t.startsWith("/themes/")){let r=t.slice(8),n=vt(B,r);return n?te.net.fetch((0,Rt.pathToFileURL)(n).toString()):new Response(null,{status:404})}switch(t){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 te.net.fetch((0,Rt.pathToFileURL)((0,Kr.join)(__dirname,t)).toString());default:return new Response(null,{status:404})}});try{T.store.enableReactDevtools&&Hr("fmkadmapgofadopljbjfkapdkoienihi").then(()=>console.info("[Vencord] Installed React Developer Tools")).catch(e=>console.error("[Vencord] Failed to install React Developer Tools",e))}catch{}Zt()});Jr();
//# sourceURL=file:///VencordPatcher
//# sourceMappingURL=vencord://patcher.js.map
/*! For license information please see patcher.js.LEGAL.txt */