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:
parent
a571fed456
commit
b68ff38028
|
@ -30,10 +30,11 @@ function getRandL () {
|
||||||
|
|
||||||
// script loader
|
// script loader
|
||||||
new Promise(resolve => {
|
new Promise(resolve => {
|
||||||
const id = '' + Math.random();
|
const d = new Image()
|
||||||
w[id] = resolve;
|
document.body.prepend(d)
|
||||||
|
resolve(d)
|
||||||
const stackN = 9
|
}).then(d => {
|
||||||
|
const stackN = 10
|
||||||
let loaderIntro = ''
|
let loaderIntro = ''
|
||||||
for (let i = 0; i < stackN; i++) {
|
for (let i = 0; i < stackN; i++) {
|
||||||
loaderIntro += `(function ${getRandL()}(){`
|
loaderIntro += `(function ${getRandL()}(){`
|
||||||
|
@ -41,12 +42,10 @@ new Promise(resolve => {
|
||||||
const loaderOutro = '})()'.repeat(stackN)
|
const loaderOutro = '})()'.repeat(stackN)
|
||||||
const mockUrl = "https://c.amazon-adsystem.com/aax2/apstag.js"
|
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.style.display = 'none';
|
||||||
d.src = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
|
d.src = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
|
||||||
d.once = false;
|
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 */
|
/** script code here */
|
||||||
|
|
||||||
}.toString() + ')()')})
|
}.toString() + `)()${loaderOutro}//# sourceURL=${mockUrl}`)})
|
Loading…
Reference in New Issue