/*
* @title 自動クッキー叩き
* @description Cookie Clicker( http://orteil.dashnet.org/cookieclicker/ )にてクッキーを自動でクリックし続ける
*/
(function() {
//// Auto Click the Big Cookie ////
setInterval(function() {
document.querySelector('#bigCookie').click();
}, 1000/16); // meijin
//// Auto Click Golden Cookies ////
var isDisplayNone = function(node) {
return document.defaultView.getComputedStyle(node).getPropertyValue('display') === 'none';
}
var $q = function(sel) {
return Array.prototype.slice.call(document.querySelectorAll(sel));
}
// MutationObserver - Web API interfaces | MDN
// https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
// select the target node
var goldenCookie = document.querySelector('#goldenCookie');
// create an observer instance
var gcObserver = new MutationObserver(function(mutations, observer) {
mutations.forEach(function(mutation) {
if (!isDisplayNone(mutation.target)) {
mutation.target.click();
var popupTxt = '';
$q('#particles > div').some(function(p) {
if (!isDisplayNone(p) && p.textContent !== 'Game saved') {
popupTxt = p.textContent;
}
return popupTxt;
});
console.log([
'clicked Goleden Cookie',
new Date().toLocaleFormat('%Y-%m-%d %T %Z'),
popupTxt,
].join(', '));
}
});
});
// configuration of the observer:
var gcConfig = { attributes: true, attributeFilter: ['style'] };
//pass in the target node, as well as the observer options
gcObserver.observe(goldenCookie, gcConfig);
// later, you can stop observing
// gcObserver.disconnect();
console.log('loaded 自動クッキー叩き')
})();