6464 ipcRenderer . send ( 'disableRpcCallback' )
6565 }
6666
67+ function UploadBanner ( ) {
68+ let str = document . getElementById ( 'bannerBtn' ) . value
69+ let banner = document . getElementById ( 'bg' )
70+
71+ console . log ( str , banner )
72+ if ( ! str . startsWith ( 'https://' ) ) {
73+ let userID = localStorage . getItem ( 'userID' )
74+
75+ try {
76+ let splitted = str . split ( '.' , 1 ) ;
77+ } catch {
78+ return console . log ( "Invalid ID" )
79+ }
80+ if ( ! userID ) {
81+ return console . log ( 'Either set the RPC first, or use a full URL format.' )
82+ }
83+
84+ let final = `https://cdn.discordapp.com/banners/${ userID } /${ splitted } .${ str . startsWith ( 'a_' ) ?"gif" :'png' } ?size=64`
85+ banner . style . backgroundImage = `url(${ final } )`
86+ localStorage . setItem ( 'bannerURL' , final )
87+ } else {
88+ let final = str
89+ banner . style . backgroundImage = `url(${ final } )`
90+ localStorage . setItem ( 'bannerURL' , final )
91+ }
92+
93+
94+ }
95+
6796 function RPCfunc ( ) {
6897 // main initalization of rich presence information set as an object
6998 const obj = {
159188 userID,
160189 userDisc
161190 } = arg ;
191+
192+ localStorage . setItem ( 'userID' , userID )
162193 let largeImgIcn = document . getElementById ( 'paimon' ) ;
163194 let smallImgIcn = document . getElementById ( 'small' ) ;
164195 if ( iterations < 1 ) {
167198 }
168199 // checks if the old avatar is the same as the new one; if it isnt, it sets the banner again.
169200 profilePic . src = avatarIcon ;
201+ localStorage . setItem ( 'pfpURL' , avatarIcon )
170202 profilePic . onload = ( ) => {
171203 ColorThief . getColor ( avatarIcon )
172204 . then ( color => {
173- bgImg . style . backgroundColor = "rgb(" + color + ")" ;
205+ let banner = localStorage . getItem ( 'bannerURL' )
206+
207+ if ( ! banner ) {
208+ let bannerURL = "rgb(" + color + ")" ;
209+ bgImg . style . backgroundColor = bannerURL
210+ localStorage . setItem ( 'bannerURL' , bannerURL )
211+ }
174212 } )
175213 . catch ( err => {
176214 console . log ( err )
291329
292330 }
293331 document . getElementById ( 'badgeTooltipText' ) . innerText = `v${ version } @ 26.06.22`
332+ let banner = localStorage . getItem ( 'bannerURL' )
333+ let pfp = localStorage . getItem ( 'pfpURL' )
334+
335+ if ( banner ) {
336+ let bg = document . getElementById ( 'bg' )
337+ bg . style . backgroundImage = banner . startsWith ( 'https://' ) ?`url(${ banner } )` :banner ;
338+ }
339+ if ( pfp ) {
340+ let pfpIcon = document . getElementById ( 'pfp' )
341+ pfpIcon . src = pfp
342+ }
294343 loadTxt . innerText = "Loading... (100%)"
295344 loadBar . style . width = '80vw'
296345 setTimeout ( ( ) => {
382431 url1div . style . filter = "opacity(1)" ;
383432 url1div . style . zIndex = "1"
384433 } )
385-
434+ ipcRenderer . on ( 'setCustomBanner' , ( arg , event ) => {
435+ let url1div = document . getElementById ( 'bannerMenu' ) ;
436+ url1div . style . transition = "all 500ms ease" ;
437+ url1div . style . filter = "opacity(1)" ;
438+ url1div . style . zIndex = "1"
439+ } )
440+
386441 ipcRenderer . on ( 'clearCacheResponse' , ( event , arg ) => {
387442 const clearObj = {
388443 'clientVar' : "" ,
492547 let closeBtn = document . getElementById ( 'closeBtn5' ) ;
493548 closeBtn . parentElement . style . filter = "opacity(0)" ;
494549 closeBtn . parentElement . style . zIndex = "-1" ;
550+ } case 6 : {
551+ let closeBtn = document . getElementById ( 'closeBtn6' ) ;
552+ closeBtn . parentElement . style . filter = "opacity(0)" ;
553+ closeBtn . parentElement . style . zIndex = "-1" ;
495554 }
496555 }
497556
@@ -511,9 +570,9 @@ <h3 class='nickname' id='nickname'> Testing Only</h3>
511570 < h4 class ='username ' id ='username '> Test Account#0001</ h4 >
512571 < div class ='images things ' id ='play '> Playing a game</ div >
513572 < input type ="text " class ='genshin things ' id ='name ' value ='Genshin Impact ' placeholder ="Game Name " onclick ="this.select() " onchange ="RPCfunc() "> </ input >
514- < img src ='https://cdn.discordapp.com/app-assets/929391097824821318/929483644731551754.png ' alt ='paimon ' width ="60 " height ="60 " class ='paimon things ' id ='paimon ' onclick ="paimonClick() ">
573+ < img src ='https://cdn.discordapp.com/app-assets/929391097824821318/929483644731551754.png ' alt ='paimon ' width ="56 " height ="56 " class ='paimon things ' id ='paimon ' onclick ="paimonClick() ">
515574 < img src ='assets/yae.png ' alt ='small ' width ="20 " height ="20 " class ='yae things ' id ='small ' onclick ='smallClick() '>
516- < img src ="./assets/circle.png " alt ="circle " width ="10 " height ="10 ", class ='circle '>
575+ < img src ="./assets/circle.png " alt ="circle " width ="11 " height ="11 ", class ='circle '>
517576 < img src ="./assets/devportal.png " alt ="discord-dev-portal " width ="10 " height ="10 ", class ='devportal ' onclick ="devPortalFunc() ">
518577
519578 < img src ="./assets/badge-dev.png " alt ="developer-badge " width ="10 " height ="10 ", class ='badge ' id ='badge '>
@@ -539,6 +598,11 @@ <h4 class='username' id='username'> Test Account#0001</h4>
539598 < input class ='btnUrl2 stuff items btnUrls ' placeholder ="Button Url 2 " id ='btnUrl2 ' value ="" onclick ="this.select() " onchange ="RPCfunc() "> </ input >
540599 < button type ="button " class ="closeBtn " onclick ="closeFunc(2) " id ="closeBtn2 " data-type ="closeBtn "> Close Menu</ button >
541600 </ div >
601+ < div id ='bannerMenu '>
602+ < div class ='bannerTxt '> Input a Custom Banner URL:</ div >
603+ < input class ='btnUrl2 stuff items btnUrls ' placeholder ="Banner URL " id ='bannerBtn ' value ="" onclick ="this.select() " onchange ="UploadBanner() "> </ input >
604+ < button type ="button " class ="closeBtn " onclick ="closeFunc(6) " id ="closeBtn6 " data-type ="closeBtn "> Close Menu</ button >
605+ </ div >
542606 < div id ='paimonMenu '>
543607 < div class ='paimonTxt URL '> Edit Large Image:</ div >
544608 < input class ='largeImgTxt stuff items btnUrls ' placeholder ="Large Image Text " id ='largeImgTxt ' value ="" onclick ="this.select() " onchange ="RPCfunc() "> </ input >
0 commit comments