自動クッキー叩き
by
saitamanodoruji
2014-12-15 [2014/12/15 02:40:25]
(Forked from
自動クッキー叩き by
bouze_me)
Cookie Clicker( http://orteil.dashnet.org/cookieclicker/ )にてクッキーを自動でクリックし続ける
@@ -1,6 +1,7 @@
/*
- * @title 自動クッキー叩き
- * @description Cookie Clicker( http://orteil.dashnet.org/cookieclicker/ )にてクッキーを自動でクリックし続ける
+ * @title 自動クッキー叩き
+ * @description Cookie Clicker( http://orteil.dashnet.org/cookieclicker/ )にてクッキーを自動でクリックし続ける
+ * @include http://orteil.dashnet.org/cookieclicker/*
*/
(function() {
@@ -26,21 +27,26 @@
// select the target node
var goldenCookie = document.querySelector('#goldenCookie');
+ var seasonPopup = document.querySelector('#seasonPopup');
// create an observer instance
- var gcObserver = new MutationObserver(function(mutations, observer) {
+ var popupObserver = new MutationObserver(function(mutations, observer) {
mutations.forEach(function(mutation) {
if (!isDisplayNone(mutation.target)) {
- mutation.target.click();
var popupTxt = '';
+ if (mutation.target.id == 'goldenCookie') {
+ popupTxt += 'clicked Goleden Cookie, ';
+ } else if (mutation.target.id == 'seasonPopup') {
+ popupTxt += 'clicked Season Popup, ';
+ }
+ mutation.target.click();
$q('#notes > div').some(function(e) {
if (!isDisplayNone(e) && e.textContent !== 'Game saved') {
- popupTxt = e.textContent;
+ popupTxt += e.textContent;
}
return popupTxt;
});
console.log([
- 'clicked Goleden Cookie',
new Date().toLocaleFormat('%Y-%m-%d %T %Z'),
popupTxt,
].join(', '));
@@ -49,13 +55,14 @@
});
// configuration of the observer:
- var gcConfig = { attributes: true, attributeFilter: ['style'] };
+ var observerConfig = { attributes: true, attributeFilter: ['style'] };
//pass in the target node, as well as the observer options
- gcObserver.observe(goldenCookie, gcConfig);
+ popupObserver.observe(goldenCookie, observerConfig);
+ popupObserver.observe(seasonPopup, observerConfig);
// later, you can stop observing
- // gcObserver.disconnect();
+ // popupObserver.disconnect();
console.log('loaded 自動クッキー叩き')
/*
* @title 自動クッキー叩き
* @description Cookie Clicker( http://orteil.dashnet.org/cookieclicker/ )にてクッキーを自動でクリックし続ける
* @include 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');
var seasonPopup = document.querySelector('#seasonPopup');
// create an observer instance
var popupObserver = new MutationObserver(function(mutations, observer) {
mutations.forEach(function(mutation) {
if (!isDisplayNone(mutation.target)) {
var popupTxt = '';
if (mutation.target.id == 'goldenCookie') {
popupTxt += 'clicked Goleden Cookie, ';
} else if (mutation.target.id == 'seasonPopup') {
popupTxt += 'clicked Season Popup, ';
}
mutation.target.click();
$q('#notes > div').some(function(e) {
if (!isDisplayNone(e) && e.textContent !== 'Game saved') {
popupTxt += e.textContent;
}
return popupTxt;
});
console.log([
new Date().toLocaleFormat('%Y-%m-%d %T %Z'),
popupTxt,
].join(', '));
}
});
});
// configuration of the observer:
var observerConfig = { attributes: true, attributeFilter: ['style'] };
//pass in the target node, as well as the observer options
popupObserver.observe(goldenCookie, observerConfig);
popupObserver.observe(seasonPopup, observerConfig);
// later, you can stop observing
// popupObserver.disconnect();
console.log('loaded 自動クッキー叩き')
})();
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。