Tampermonkey script no longer works specifically in Google Chrome (not all Chromium-based browser)
PeterNjeim opened this issue · comments
Peter Njeim commented
For some reason, when creating a new Image, const d = new Image();
, the script fails at the next line document.body.prepend(d)
, saying that d
is undefined. This is very strange, and I don't even know if it's possible to fix, without Google Chrome reverting something they did.
Tom Wenzheng Tang commented
They've added the detection code again.
window.Image = function() {
var stack = new Error().stack
var stackChunks = stack.split('\n').slice(2);
var lastLine = stackChunks.reverse()[0];
var url = lastLine.split(' ').reverse()[0]
var urlChunks = url.substr(1, url.length - 2).split(':')
var resultUrl = urlChunks[0] + ':' + urlChunks[1]
if (
getIsUserScript(stack)
|| lastLine.split(' (eval').length >= 3
|| (lastLine.indexOf(' eval ') && resultUrl === location.href) || stackChunks.every(function (chunk) { return chunk.indexOf('a (https://c.amazon-adsystem.com/aax2/apstag.js:') > -1 })
) {
disable()
return null;
}
return new Img(arguments[0], arguments[1])
}