Cookie Clicker clicker
@@ -1,25 +1,24 @@
/*
* @title Cookie Clicker clicker
- * @description auto-click Cookie Clicker( http://orteil.dashnet.org/cookieclicker/ )
+ * @description auto-click Cookie Clicker http://orteil.dashnet.org/cookieclicker/
* @contributor bouze_me http://let.hatelabo.jp/bouze_me/let/hJmcpKukvYVM
* @contributor saitamanodoruji http://let.hatelabo.jp/saitamanodoruji/let/hLHUpdyt-_4f (Fork of)
* @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
+ }, 1000 / 16); // meijin
//// Auto Click Golden Cookies ////
- var isDisplayNone = function(node) {
- return document.defaultView.getComputedStyle(node).getPropertyValue('display') === 'none';
+ var isDisplay = function(node) {
+ return document.defaultView.getComputedStyle(node).getPropertyValue('display') !== 'none';
};
var $q = function(sel) {
@@ -39,10 +38,10 @@
return function() {
var now = new Date();
return now.toLocaleDateString('ja', {
- year: 'numeric',
+ year: 'numeric',
month: '2-digit',
- day: '2-digit'
- }).replace(/\//g, '-') + ' ' + now.toTimeString();
+ day: '2-digit'
+ }).replace(/\//g, '-') + ' ' + now.toTimeString();
};
}
})();
@@ -51,52 +50,45 @@
if (!console || !console.log) return function() {};
var isChrome = navigator.userAgent.toLowerCase().indexOf('chrome/') > -1,
- style = 'color: brown;';
+ style = 'color: brown;';
+
+ // '%c': console style
+ // https://developers.google.com/chrome-developer-tools/docs/console-api
+ if (isChrome) {
+ return function(msg) { return console.log('%c' + msg, style); };
+ }
- // '%c': console style
- // https://developers.google.com/chrome-developer-tools/docs/console-api
- if (isChrome) {
- return function(msg) { return console.log('%c' + msg, style); };
- }
-
- // Firefox not implemented yet?
- // https://developer.mozilla.org/en-US/docs/Web/API/console.log
- // https://developer.mozilla.org/en-US/docs/Web/API/console
- return function(msg) { return console.log(msg); };
+ // Firefox not implemented yet?
+ // https://developer.mozilla.org/en-US/docs/Web/API/console.log
+ // https://developer.mozilla.org/en-US/docs/Web/API/console
+ return function(msg) { return console.log(msg); };
})();
// 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) {
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;
- });
+ if (!isDisplay(mutation.target)) return;
- log(['*Goleden Cookie was clicked', timestamp(), popupTxt].join(', '));
- }
+ mutation.target.click();
+
+ var popupTxt = '';
+ $q('#particles > div').some(function(p) {
+ if (isDisplay(p) && p.textContent !== 'Game saved') {
+ return !!(popupTxt = p.textContent);
+ }
+ });
+ log(['*Goleden Cookie was clicked', timestamp(), popupTxt].join(', '));
});
});
- // configuration of the observer:
+ var goldenCookie = document.querySelector('#goldenCookie');
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();
+ // you can stop observing
+ //gcObserver.disconnect();
log('*Cookie Clicker clicker loaded');
/*
* @title Cookie Clicker clicker
* @description auto-click Cookie Clicker http://orteil.dashnet.org/cookieclicker/
* @contributor bouze_me http://let.hatelabo.jp/bouze_me/let/hJmcpKukvYVM
* @contributor saitamanodoruji http://let.hatelabo.jp/saitamanodoruji/let/hLHUpdyt-_4f (Fork of)
* @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 isDisplay = function(node) {
return document.defaultView.getComputedStyle(node).getPropertyValue('display') !== 'none';
};
var $q = function(sel) {
return Array.prototype.slice.call(document.querySelectorAll(sel));
};
// X-browser loose timestamp shim; c.f.
// https://gist.github.com/noromanba/6737784
var timestamp = (function() {
if (Date.prototype.toLocaleFormat) {
return function() {
return new Date().toLocaleFormat('%Y-%m-%d %T %Z');
};
}
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();
};
}
})();
var log = (function() {
if (!console || !console.log) return function() {};
var isChrome = navigator.userAgent.toLowerCase().indexOf('chrome/') > -1,
style = 'color: brown;';
// '%c': console style
// https://developers.google.com/chrome-developer-tools/docs/console-api
if (isChrome) {
return function(msg) { return console.log('%c' + msg, style); };
}
// Firefox not implemented yet?
// https://developer.mozilla.org/en-US/docs/Web/API/console.log
// https://developer.mozilla.org/en-US/docs/Web/API/console
return function(msg) { return console.log(msg); };
})();
// MutationObserver - Web API interfaces | MDN
// https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
var gcObserver = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (!isDisplay(mutation.target)) return;
mutation.target.click();
var popupTxt = '';
$q('#particles > div').some(function(p) {
if (isDisplay(p) && p.textContent !== 'Game saved') {
return !!(popupTxt = p.textContent);
}
});
log(['*Goleden Cookie was clicked', timestamp(), popupTxt].join(', '));
});
});
var goldenCookie = document.querySelector('#goldenCookie');
var gcConfig = { attributes: true, attributeFilter: ['style'] };
gcObserver.observe(goldenCookie, gcConfig);
// you can stop observing
//gcObserver.disconnect();
log('*Cookie Clicker clicker loaded');
})();
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。