1010 justify-content : center;
1111 text-align : center;
1212 height : 100vh ;
13- display : none;
1413 overflow : hidden;
1514 }
1615
3332 .cred {
3433 right : 0 ;
3534 }
35+
36+ .loader {
37+ width : 100% ;
38+ height : 100% ;
39+ display : flex;
40+ align-items : center;
41+ justify-content : center;
42+ position : absolute;
43+ top : 0 ;
44+ left : 0 ;
45+ background : # 1e1e1e ;
46+ color : # fff ;
47+ z-index : 1000 ;
48+ }
49+
50+ .loader > div {
51+ width : 200px ;
52+ height : 20px ;
53+ background : # fff ;
54+ border : 1px solid # fff ;
55+ outline : 1px solid # 000 ;
56+ }
57+
58+ .loader > div > div {
59+ width : 0 ;
60+ height : 100% ;
61+ background : # FF4545 ;
62+ transition : width 0.5s ;
63+ margin : 0 ;
64+ padding : 0 ;
65+ margin-bottom : 10px ;
66+ }
67+
68+ .loader > div > span {
69+ font-family : 'Arial' , sans-serif;
70+ margin : 0 ;
71+ padding : 0 ;
72+ font-size : 24px ;
73+ }
74+
75+ .hidden {
76+ display : none;
77+ }
3678 </ style >
3779</ head >
3880
3981< body >
40- < div class ="content ">
82+ < div class ="loader ">
83+ < div >
84+ < div > </ div >
85+ < span > Loading (%)</ span >
86+ </ div >
87+ </ div >
88+ < div class ="content hidden ">
4189 < h1 > yee loader</ h1 >
4290 < button class ="btn " id ="blob " onclick ="load('blob') ">
4391 Open Blob
@@ -46,16 +94,37 @@ <h1>yee loader</h1>
4694 Open Blank
4795 </ button >
4896 </ div >
49- < a class ="ver "> v1.1_1 </ a >
50- < a class ="cred "> Made by Colbster937</ a >
97+ < a class ="ver hidden "> v1.2 </ a >
98+ < a class ="cred hidden "> Made by Colbster937</ a >
5199 < script >
52100 let url ;
53- async function init ( ) {
101+ let checkprogress = 0 ;
102+ let loadprogress = 0 ;
103+ let loadingText = { } ;
104+
105+ async function checkURL ( url ) {
106+ try {
107+ const response = await fetch ( url ) ;
108+ if ( ! response . status === 200 || ! response . ok ) throw new Error ( ) ;
109+ const data = await response . text ( ) || await response . json ( ) ;
110+ return {
111+ status : true ,
112+ data
113+ } ;
114+ } catch {
115+ return {
116+ status : false ,
117+ data : null
118+ } ;
119+ }
120+ }
121+
122+ async function init ( git_url ) {
54123 try {
55124 const response = await fetch (
56- "https://raw.githubusercontent.com/ZYPHERStudios/assets/refs/heads/main/eWVlbGF1bmNoZXJ1cmxz" ,
125+ git_url ,
57126 ) ;
58- if ( ! response . ok ) {
127+ if ( ! response . status === 200 || ! response . ok ) {
59128 throw new Error (
60129 `HTTP error! Status: ${ response . status } ` ,
61130 ) ;
@@ -65,22 +134,85 @@ <h1>yee loader</h1>
65134
66135 const decoded = JSON . parse ( atob ( b64 ) ) ;
67136
68- url = decoded [ "yee1" ] ;
137+ const array = Object . entries ( decoded ) ;
138+
139+ let i = 0 ;
140+
141+ for ( const [ num , url2 ] of array ) {
142+ i ++
143+ const fullURL = `${ url2 . replace ( / ^ ( h t t p s ? : \/ \/ [ ^ \/ ] + ) \/ i n d e x \. h t m l $ / , "$1/" ) } ` ;
144+ const urlCheck = `${ fullURL } data/onlineCheck.txt` ;
145+ const response = await checkURL ( urlCheck ) ;
146+ checkprogress = ( i / array . length ) ;
147+ if ( response . status ) {
148+ if ( ! url ) url = fullURL ;
149+ updateBar ( ) ;
150+ } else {
151+ updateBar ( ) ;
152+ }
153+ }
154+
155+ if ( ! url ) {
156+ if ( confirm ( "No working URLs found, use new github?" ) ) {
157+ await init ( prompt ( "Enter github url" ,
158+ "https://raw.githubusercontent.com/ZYPHERStudios/assets/refs/heads/main/eWVlbGF1bmNoZXJ1cmxz"
159+ ) ) ;
160+ return ;
161+ } else {
162+ return ;
163+ }
164+ }
69165 } catch ( error ) {
70166 console . error ( "Error:" , error ) ;
71167 }
72- const style = document . createElement ( "link" ) ;
73- style . href = `${ url } data/style.css` ;
74- style . rel = "stylesheet" ;
75- const style2 = document . createElement ( "link" ) ;
76- style2 . href = `${ url } data/button.css` ;
77- style2 . rel = "stylesheet" ;
78- document . head . appendChild ( style ) ;
79- document . head . appendChild ( style2 ) ;
80- }
81-
82- document . addEventListener ( "DOMContentLoaded" , ( ) => {
83- init ( ) ;
168+ const styles = [ "data/style.css" , "data/button.css" ] ;
169+ for ( let i = 0 ; i < styles . length ; i ++ ) {
170+ const response = await fetch ( `${ url } ${ styles [ i ] } ` ) ;
171+ let data = await response . text ( ) ;
172+ data = data . replace ( / u r l \( (? ! h t t p s ? : \/ \/ ) [ ' " ] ? ( [ ^ ) ] + ?) [ ' " ] ? \) / g,
173+ `url(${ url } ${ getFolder ( styles [ i ] ) } /$1)` ) ;
174+ const blob = new Blob ( [ data ] ) ;
175+ const blobUrl = URL . createObjectURL ( blob ) ;
176+ const style = document . createElement ( "link" ) ;
177+ style . rel = "stylesheet" ;
178+ style . href = blobUrl ;
179+ await document . head . appendChild ( style ) ;
180+ loadprogress = ( ( i + 1 ) / styles . length ) ;
181+ updateBar ( ) ;
182+ }
183+ }
184+
185+ function getFolder ( f ) {
186+ return f . slice ( 0 , f . lastIndexOf ( '/' ) ) || f ;
187+ }
188+
189+ function showMain ( ) {
190+ document . querySelectorAll ( '.hidden' ) . forEach ( el => {
191+ el . classList . remove ( 'hidden' ) ;
192+ } ) ;
193+ document . querySelector ( ".loader" ) . remove ( ) ;
194+ }
195+
196+ function updateBar ( ) {
197+ const progress = ( ( checkprogress * 100 ) + ( loadprogress * 100 ) ) / 2 ;
198+ const progressBar = document . querySelector ( ".loader > div > div" ) ;
199+ progressBar . style . width = `${ progress } %` ;
200+ loadingText . element . textContent = loadingText . text . replace ( "%" , `${ progress . toFixed ( 0 ) } %` ) ;
201+ if ( progress >= 100 ) {
202+ showMain ( ) ;
203+ }
204+ }
205+
206+ document . addEventListener ( "DOMContentLoaded" , async ( ) => {
207+ const loadingTextElem = document . querySelector ( ".loader > div > span" ) ;
208+ loadingText = {
209+ element : loadingTextElem ,
210+ text : loadingTextElem . textContent
211+ } ;
212+ await updateBar ( ) ;
213+ await init (
214+ "https://raw.githubusercontent.com/ZYPHERStudios/assets/refs/heads/main/eWVlbGF1bmNoZXJ1cmxz"
215+ ) ;
84216 if ( location !== window . parent . location ) {
85217 document . documentElement . borderRadius = "2vh" ;
86218 }
0 commit comments