Cookie Clicker clicker

    @@ -10,13 +10,12 @@ (function() { - //// Auto Click the Big Cookie //// - - setInterval(function() { - document.querySelector('#bigCookie').click(); - }, 1000 / 16); // meijin - - //// Auto Click Golden Cookies //// + var autoClickBigCookie = function() { + setInterval(function() { + document.querySelector('#bigCookie').click(); + }, 1000 / 16); // meijin + }; + autoClickBigCookie(); var isDisplay = function(node) { return document.defaultView.getComputedStyle(node).getPropertyValue('display') !== 'none'; @@ -26,15 +25,23 @@ return Array.prototype.slice.call(document.querySelectorAll(sel)); }; - // X-browser loose datetime shim; c.f. + // X-browser loose datetime format shim; c.f. // https://gist.github.com/noromanba/6737784 - var datetime = (function() { + var toDatetimeString = (function() { + /* {{{ if (Date.prototype.toLocaleFormat) { return function() { - return new Date().toLocaleFormat('%Y-%m-%d %T %Z'); + return new Date().toLocaleFormat('%Y-%m-%d %T'); }; } + var toTimeString = (function() { + if (Date.prototype.toLocaleTimeString) { + return function(date) { return date.toLocaleTimeString('en-GB'); }; + } + return function(date) { date.toTimeString().slice(0, 8); }; + })(); + if (Date.prototype.toLocaleDateString) { return function() { var now = new Date(); @@ -42,16 +49,37 @@ year: 'numeric', month: '2-digit', day: '2-digit' - }).replace(/\//g, '-') + ' ' + now.toTimeString(); + }).replace(/\//g, '-') + ' ' + toTimeString(now); }; } + + return function() { + var now = new Date(); + return [ + new Date().getFullYear(), + '-', ('0' + (now.getMonth() + 1)).slice(-2), + '-', ('0' + now.getDay()).slice(-2), + ' ', toTimeString(now) + ].join(''); + }; + /*/ // or simplify, use this code }}} + return function() { + var now = new Date(); + return [ + new Date().getFullYear(), + '-', ('0' + (now.getMonth() + 1)).slice(-2), + '-', ('0' + now.getDay()).slice(-2), + ' ', now.toTimeString().slice(0, 8) + ].join(''); + }; + //*/ })(); var log = (function() { 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 @@ -65,8 +93,8 @@ return function(msg) { return console.log(msg); }; })(); - // MutationObserver - Web API interfaces | MDN // https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver + var MutationObserver = window.MutationObserver || window.WebKitMutationObserver; var gcObserver = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { if (!isDisplay(mutation.target)) return; @@ -79,18 +107,18 @@ return !!(popupTxt = p.textContent); } }); - log(['*Goleden Cookie was clicked', datetime(), popupTxt].join(', ')); + log(['*Goleden Cookie was clicked', toDatetimeString(), popupTxt].join(', ')); }); }); - var goldenCookie = document.querySelector('#goldenCookie'); - var gcConfig = { attributes: true, attributeFilter: ['style'] }; - - gcObserver.observe(goldenCookie, gcConfig); + var autoClickGoldenCookie = function() { + var goldenCookie = document.querySelector('#goldenCookie'); + var gcConfig = { attributes: true, attributeFilter: ['style'] }; - // you can stop observing - //gcObserver.disconnect(); + gcObserver.observe(goldenCookie, gcConfig); - log('*Cookie Clicker clicker loaded'); + log('*Cookie Clicker clicker loaded'); + }; + autoClickGoldenCookie(); })();
  • /*
     * @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() {
    
      var autoClickBigCookie = function() {
        setInterval(function() {
          document.querySelector('#bigCookie').click();
        }, 1000 / 16); // meijin
      };
      autoClickBigCookie();
    
      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 datetime format shim; c.f.
      // https://gist.github.com/noromanba/6737784
      var toDatetimeString = (function() {
        /* {{{
        if (Date.prototype.toLocaleFormat) {
          return function() {
            return new Date().toLocaleFormat('%Y-%m-%d %T');
          };
        }
    
        var toTimeString = (function() {
          if (Date.prototype.toLocaleTimeString) {
              return function(date) { return date.toLocaleTimeString('en-GB'); };
          }
          return function(date) { date.toTimeString().slice(0, 8); };
        })();
    
        if (Date.prototype.toLocaleDateString) {
          return function() {
            var now = new Date();
            return now.toLocaleDateString('ja', {
              year:  'numeric',
              month: '2-digit',
              day:   '2-digit'
            }).replace(/\//g, '-') + ' ' + toTimeString(now);
          };
        }
    
        return function() {
          var now = new Date();
          return [
            new Date().getFullYear(),
                '-', ('0' + (now.getMonth() + 1)).slice(-2),
                '-', ('0' + now.getDay()).slice(-2),
                ' ', toTimeString(now)
          ].join('');
        };
        /*/ // or simplify, use this code }}}
        return function() {
          var now = new Date();
          return [
            new Date().getFullYear(),
                '-', ('0' + (now.getMonth() + 1)).slice(-2),
                '-', ('0' + now.getDay()).slice(-2),
                ' ', now.toTimeString().slice(0, 8)
          ].join('');
        };
        //*/
      })();
    
      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); };
      })();
    
      // https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
      var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
      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', toDatetimeString(), popupTxt].join(', '));
        });
      });
    
      var autoClickGoldenCookie = function() {
        var goldenCookie = document.querySelector('#goldenCookie');
        var gcConfig = { attributes: true, attributeFilter: ['style'] };
    
        gcObserver.observe(goldenCookie, gcConfig);
    
        log('*Cookie Clicker clicker loaded');
      };
      autoClickGoldenCookie();
    
    })();
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2013/10/03 00:55:59 - 2013-10-03
  2. 2013/10/02 07:54:15 - 2013-10-02
  3. 2013/10/02 07:42:40 - 2013-10-02
  4. 2013/10/02 07:35:39 - 2013-10-02
  5. 2013/10/02 07:33:06 - 2013-10-02
  6. 2013/10/01 18:45:05 - 2013-10-01
  7. 2013/10/01 04:01:47 - 2013-10-01
  8. 2013/10/01 03:59:14 - 2013-10-01
  9. 2013/09/30 05:45:55 - 2013-09-30
  10. 2013/09/30 05:43:33 - 2013-09-30
  11. 2013/09/28 08:38:06 - 2013-09-28
  12. 2013/09/28 08:37:17 - 2013-09-28
  13. 2013/09/28 08:21:31 - 2013-09-28
  14. 2013/09/28 07:11:18 - 2013-09-28