/*
* @title github_404_kurukuru
* @description githubの404のページをくるくるする
* @include https://github.com
* @license MIT License
* @require
*/
var MouseUtil = { };
['mousemove', 'mousedown', 'mouseup', 'click'].forEach(function (method) {
MouseUtil[method] = function(x, y) {
if (!x) x = 0;
if (!y) y = 0;
var event = document.createEvent("MouseEvents");
event.initMouseEvent(method, true, false, window,
0, x, y, x, y, false, false, true, false, 0, null );
return event;
}
});
var target = document.querySelector('#parallax_illustration');
if (!target) {
alert('404のページで実行してください');
}
var rect = target.getBoundingClientRect();
var i = 0;
setInterval(function() {
i++;
var x = rect.left + window.scrollX + Math.sin(i / 5) * rect.width / 2 + rect.width;
var y = rect.top + window.scrollY + Math.cos(i / 5) * rect.height / 2 + rect.height;
target.dispatchEvent(MouseUtil.mousemove(x, y));
}, 10);