fix: mp3 & midi download

The result differed as connection speed differs.

race condition: this script code and `webpackChunkmusescore_es6` chunks
This commit is contained in:
Xmader 2021-05-10 10:55:24 -04:00
parent a571fed456
commit b68ff38028
No known key found for this signature in database
GPG Key ID: A20B97FB9EB730E4
1 changed files with 7 additions and 8 deletions

View File

@ -30,10 +30,11 @@ function getRandL () {
// script loader
new Promise(resolve => {
const id = '' + Math.random();
w[id] = resolve;
const stackN = 9
const d = new Image()
document.body.prepend(d)
resolve(d)
}).then(d => {
const stackN = 10
let loaderIntro = ''
for (let i = 0; i < stackN; i++) {
loaderIntro += `(function ${getRandL()}(){`
@ -41,12 +42,10 @@ new Promise(resolve => {
const loaderOutro = '})()'.repeat(stackN)
const mockUrl = "https://c.amazon-adsystem.com/aax2/apstag.js"
setTimeout(`${loaderIntro}const d=new Image();window['${id}'](d);delete window['${id}'];document.body.prepend(d)${loaderOutro}//# sourceURL=${mockUrl}`)
}).then(d => {
d.style.display = 'none';
d.src = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
d.once = false;
d.setAttribute('onload', `if(this.once)return;this.once=true;this.remove();const GM=window['${gmId}'];delete window['${gmId}'];(` + function a () {
d.setAttribute('onload', `const self=this;${loaderIntro}if(self.once)return;self.once=true;self.remove();const GM=window['${gmId}'];delete window['${gmId}'];(` + function a () {
/** script code here */
}.toString() + ')()')})
}.toString() + `)()${loaderOutro}//# sourceURL=${mockUrl}`)})