Cookie Clicker clicker
@@ -1,6 +1,10 @@
/*
- * @title 自動クッキー叩き
- * @description Cookie Clicker( http://orteil.dashnet.org/cookieclicker/ )にてクッキーを自動でクリックし続ける
+ * @title Cookie Clicker clicker
+ * @description auto-click Cookie Clicker( http://orteil.dashnet.org/cookieclicker/ )
+ * @contributor saitamanodoruji http://let.hatelabo.jp/saitamanodoruji/let/hLHUpdyt-_4f
+ * @orig-license Unknown (as-is)
+ * @contributor noromanba http://let.hatelabo.jp/noromanba/let/hJmcrJfO94ka
+ * @license TBD
*/
(function() {
@@ -15,11 +19,37 @@
var isDisplayNone = function(node) {
return document.defaultView.getComputedStyle(node).getPropertyValue('display') === 'none';
- }
+ };
var $q = function(sel) {
return Array.prototype.slice.call(document.querySelectorAll(sel));
- }
+ };
+
+ // X-browser shim
+ var timestamp = (function() {
+ // non-standard JS 1.6, Fx only; c.f.
+ // http://compatibility.shwups-cms.ch/en/home/?&&&property=Date.prototype.toLocaleFormat
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleFormat
+ if (Date.prototype.toLocaleFormat) {
+ return function() {
+ return new Date().toLocaleFormat('%Y-%m-%d %T %Z');
+ };
+ }
+
+ // Fx not supported yet; c.f.
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString
+ if (Date.prototype.toLocaleDateString) {
+ return function() {
+ var now = new Date();
+ return now.toLocaleDateString('ja', {
+ year: 'numeric',
+ month: '2-digit',
+ day: '2-digit'
+ }).replace(/\//g, '-') + ' ' + now.toTimeString();
+ };
+ }
+ })();
// MutationObserver - Web API interfaces | MDN
// https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
@@ -39,11 +69,7 @@
}
return popupTxt;
});
- console.log([
- 'clicked Goleden Cookie',
- new Date().toLocaleFormat('%Y-%m-%d %T %Z'),
- popupTxt,
- ].join(', '));
+ console.log(['clicked Goleden Cookie', timestamp(), popupTxt]);
}
});
});
@@ -57,6 +83,6 @@
// later, you can stop observing
// gcObserver.disconnect();
- console.log('loaded 自動クッキー叩き')
+ console.log('*loaded cookie-poker');
-})();
+})();
/*
* @title Cookie Clicker clicker
* @description auto-click Cookie Clicker( http://orteil.dashnet.org/cookieclicker/ )
* @contributor saitamanodoruji http://let.hatelabo.jp/saitamanodoruji/let/hLHUpdyt-_4f
* @orig-license Unknown (as-is)
* @contributor noromanba http://let.hatelabo.jp/noromanba/let/hJmcrJfO94ka
* @license TBD
*/
(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));
};
// X-browser shim
var timestamp = (function() {
// non-standard JS 1.6, Fx only; c.f.
// http://compatibility.shwups-cms.ch/en/home/?&&&property=Date.prototype.toLocaleFormat
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleFormat
if (Date.prototype.toLocaleFormat) {
return function() {
return new Date().toLocaleFormat('%Y-%m-%d %T %Z');
};
}
// Fx not supported yet; c.f.
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleDateString
if (Date.prototype.toLocaleDateString) {
return function() {
var now = new Date();
return now.toLocaleDateString('ja', {
year: 'numeric',
month: '2-digit',
day: '2-digit'
}).replace(/\//g, '-') + ' ' + now.toTimeString();
};
}
})();
// 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', timestamp(), popupTxt]);
}
});
});
// 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 cookie-poker');
})();
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。