jeudi 31 octobre 2019

halloween bookmarklet

halloween!

<script>
var ww=window.innerWidth;
var wh=window.innerHeight;
var x=Math.round(Math.random()*ww);
var y=wh;
var dx=Math.round(Math.random()*ww);
var dy=Math.round(Math.random()*wh);
var a=+Math.round(Math.random()*10000);
var monster=[
"https://thumbs.gfycat.com/ContentActualHectorsdolphin-max-1mb.gif",
"https://media2.giphy.com/media/5YMDSfui21JLi/source.gif",
"http://www.carlswebgraphics.com/halloween/2019-bat-flying-animation.gif",
"https://images.gr-assets.com/hostedimages/1442535269ra/16248025.gif",
"http://images6.fanpop.com/image/photos/41600000/Scary-Jack-O-Lantern-halloween-41600763-320-320.gif",
"http://pa1.narvii.com/6338/6a8ed56af0b9b82c1a28559b010f01070e6c43b6_00.gif",
"https://thumbs.gfycat.com/PeacefulFlatIslandcanary-size_restricted.gif"
];

function createbat(){
var rand=Math.round(Math.random()*6);
var img1=document.createElement("IMG");
img1.setAttribute("src",monster[rand]);
img1.setAttribute("width","100");
img1.setAttribute("height","auto");
img1.setAttribute("id","bat"+a);
img1.setAttribute("style","position:fixed;z-index:9999;top:0px;left:0px;");
document.body.appendChild(img1);
}

createbat();

function fly(){
var bat=document.getElementById("bat"+a);
ww=window.innerWidth;
wh=window.innerHeight;
if(dx>x){x++}
if(dx<x){x--}
if(dx==x){dx=Math.round(Math.random()*ww);}
if(dy>y){y++}
if(dy<y){y--}
if(dy==y){dy=Math.round(Math.random()*wh);}
bat.style.left=x+"px";
bat.style.top=y+"px";
}

setInterval(fly,10);
</script>