MCPcopy Create free account
hub / github.com/ThatGuySam/doesitarm / loadStorkScript

Method loadStorkScript

helpers/stork/browser.js:199–233  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

197 }
198
199 loadStorkScript () {
200
201 return new Promise((resolve, reject) => {
202 if ( !!this.stork ) resolve()
203
204 if ( !!window.stork ) {
205 this.stork = window.stork
206 resolve()
207 }
208
209 const s = document.createElement('script')
210 let r = false
211 s.type = 'text/javascript'
212 s.src = storkScriptURL
213 s.async = true
214 s.onerror = function(err) {
215 reject(err, s)
216 }
217
218 s.onload = s.onreadystatechange = () => {
219 // console.log(this.readyState); // uncomment this line to see which ready states are called.
220 if (!r && (!this.readyState || this.readyState == 'complete')) {
221 r = true
222
223 this.stork = window.stork
224
225 // console.log('window.stork', typeof window.stork)
226 resolve()
227 }
228 }
229
230 const t = document.getElementsByTagName('script')[0]
231 t.parentElement.insertBefore(s, t)
232 })
233 }
234
235 // https://github.com/jameslittle230/stork/blob/ff49f163db06734e18ab690c188b45a3c68442ae/js/main.ts#L40
236 async setup () {

Callers 1

setupMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected