Skip to content

Instantly share code, notes, and snippets.

@m1k1o
Created June 7, 2019 19:18
Show Gist options
  • Save m1k1o/b5b5982dee20f005c191e8b2d332db5a to your computer and use it in GitHub Desktop.
Save m1k1o/b5b5982dee20f005c191e8b2d332db5a to your computer and use it in GitHub Desktop.
Window Dance
var s1i = 0,
s2i = 0;
window.name = '';
function posred() {
window.resizeTo(100, 100);
if (window.screenY > 100) window.moveTo(0, 0);
else window.moveTo(9999, 9999)
};
function dance() {
if (s1i == 0) {
s1i = window.setInterval(function() {
posred();
}, 50);
}
posred();
document.onmousemove = null;
};
document.onmousemove = dance;
function phash() {
return window.screenX + ',' + window.screenY + ',' + window.outerWidth + ',' + window.outerHeight
};
phashc = phash();
s2i = setInterval(function() {
if ((phashc != phash())) {
if (phashc.indexOf(',100,100') == -1) {
dance();
};
phashc = phash();
}
}, 100);
var deploy = function() {
window.clearInterval(s1i);
window.clearInterval(s2i);
document.onmousemove = null;
window.moveTo(0, 0);
window.resizeTo(1920, 1040);
if (window.name == '') window.name = 'ready';
else window.location.replace(window.name);
window.onblur = null;
};
window.onblur = deploy;
var toi = setInterval(function() {
if (window.name.length > 5) {
clearInterval(toi);
setTimeout(function() {
deploy()
}, 60000);
}
}, 50);
@murphyjohn
Copy link

Hi Miroslav,

What is this code doing? What is the purpose of running this in a user's browser?

Thanks,
John.

@m1k1o
Copy link
Author

m1k1o commented May 15, 2020

Hi,

this is just an interesting piece of code I found at some page (most likely some video-sharing page). When I opened it, windows started "dancing" around my screen and i couldn't close them. I was kinda inderested in what piece of code did that, did some reverse engineering of huge JS file, and found this.

It is just demonstration of how can a site owner annoy his visitors. I am not sure whether it works in newest version of major internet browsers, but back then it did. I think, browsers should not allow such thing.

@murphyjohn
Copy link

Thanks Miroslav,

I just came across it on a video site snahp it, in the script of a pop under window. Hence I found it on your profile searching it. It certainly seems like it is perhaps part of ad scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment