Skip to content

Commit

Permalink
fix: tampermonkey script on Chrome
Browse files Browse the repository at this point in the history
fixes: #121
  • Loading branch information
Xmader committed May 11, 2021
1 parent 7a397e0 commit 30514e9
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,23 @@ function getRandL () {

// script loader
new Promise(resolve => {
const d = new Image()
document.body.prepend(d)
resolve(d)
}).then(d => {
const stackN = 10
const id = '' + Math.random();
w[id] = resolve;

const stackN = 9
let loaderIntro = ''
for (let i = 0; i < stackN; i++) {
loaderIntro += `(function ${getRandL()}(){`
}
const loaderOutro = '})()'.repeat(stackN)
const mockUrl = "https://c.amazon-adsystem.com/aax2/apstag.js"

Function(`${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', `const self=this;${loaderIntro}if(self.once)return;self.once=true;self.remove();const GM=window['${gmId}'];delete window['${gmId}'];(` + function a () {
d.setAttribute('onload', `if(this.once)return;this.once=true;this.remove();const GM=window['${gmId}'];delete window['${gmId}'];(` + function a () {
/** script code here */

}.toString() + `)()${loaderOutro}//# sourceURL=${mockUrl}`)})
}.toString() + ')()')})

0 comments on commit 30514e9

Please sign in to comment.