<marquee> scramble

    @@ -1,6 +1,6 @@ /* * @title <marquee> scramble - * @description + * @description https://www.google.co.jp/maps/@35.659457,139.70051,3a,75y,135.41h,84.12t/data=!3m4!1e1!3m2!1sdJ-QZu5MLMbtAfqyoN4ShQ!2e0 * @include http://* * @license MIT License * @require
  • /*
     * @title <marquee> scramble
     * @description https://www.google.co.jp/maps/@35.659457,139.70051,3a,75y,135.41h,84.12t/data=!3m4!1e1!3m2!1sdJ-QZu5MLMbtAfqyoN4ShQ!2e0
     * @include http://*
     * @license MIT License
     * @require 
     */
    
    (function() {
      function randomDirection() {
        var directions = ['left', 'right', 'up', 'down'];
        return directions[Math.floor(Math.random() * 4)];
      }
    
      function randomBehavior(direction) {
        if (direction == 'up' || direction == 'down') {
          return 'scroll';
        } else {
          var behaviors = ['alternate', 'scroll'];
          return behaviors[Math.floor(Math.random() * 2)];
        }
      }
    
      function marquee(tagName) {
        var elements = document.getElementsByTagName(tagName);
        for (var i = 0,length = elements.length; i < length; i++) {
          var children = elements[i].querySelectorAll(tagName);
          if (!elements[i].hasAttribute('data-marquished') && (children == null || children.length == 0)) {
            var parent = elements[i].parentNode;
            var marquee = document.createElement('marquee');
            var direction = randomDirection();
            marquee.setAttribute('scrollamount', '15');
            marquee.setAttribute('direction', direction);
            marquee.setAttribute('behavior', randomBehavior(direction));
            parent.insertBefore(marquee, elements[i]);
            marquee.appendChild(elements[i]);
            elements[i].setAttribute('data-marquished', 'true');
          }
        }
      }
    
      function marqueeScramble() {
        var tags = ['div', 'p', 'ul', 'table', 'a', 'iframe', 'dt', 'dd', 'img', 'h1', 'h2', 'h3', 'h4', 'h5', 'span'];
        for (var i = 0; i < tags.length; i++) {
          marquee(tags[i]);
        }
      }
    
      var timer  = 0;
      document.addEventListener('DOMNodeInserted', function() {
        if(timer) return;
        timer = setTimeout(function() {
          marqueeScramble();
          timer = 0;
        }, 500);
      }, false);
    
      marqueeScramble();
    }());
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2015/09/11 14:24:08 - 2015-09-11
  2. 2014/05/17 11:56:56 - 2014-05-17
  3. 2014/05/17 00:39:08 - 2014-05-17
  4. 2014/05/17 00:30:08 - 2014-05-17
  5. 2014/05/16 20:02:31 - 2014-05-16
  6. 2014/05/16 19:42:27 - 2014-05-16
  7. 2014/05/16 19:41:33 - 2014-05-16
  8. 2014/05/16 19:06:36 - 2014-05-16
  9. 2014/05/16 19:06:14 - 2014-05-16
  10. 2014/05/16 18:53:26 - 2014-05-16