アイコンの動かし方

  • /*
     * @title アイコンの動かし方
     * @description http://h.hatena.ne.jp/keyword/%E8%AA%B0%E3%81%8B%E3%80%81%E3%82%A2%E3%82%A4%E3%82%B3%E3%83%B3%E3%81%AE%E5%8B%95%E3%81%8B%E3%81%97%E6%96%B9%E3%81%8A%E3%81%97%E3%81%88%E3%81%A6%E3%81%91%E3%82%8C%E3%80%82
     * @include http://*
     * @license MIT License
     * @require 
     */
    
    (function(){
      var imgs = document.getElementsByTagName('img');
      var Icons = [];
      for(var i=0,l=imgs.length;i<l;i++){
        var img = imgs[i];
        if(img.className != 'profile-image') continue;
        Icons.push(img);
        var x = img.offsetLeft;
        var y = img.offsetTop;
        img.style.position = 'absolute';
        img.style.top = y + 'px';
        img.style.left = x + 'px';
      }
      var mv = function(){
         var xloop = arguments.callee;
         var tindex = Math.floor(Math.random() * Icons.length);
         var target = Icons[tindex];
         var L = 0;
         var x = Math.floor(Math.random() * 3) - 1;
         var y = Math.floor(Math.random() * 3) - 1;
         (function (){
           var iloop = arguments.callee;
           target.style.top  = (target.offsetTop + y) + 'px';
           target.style.left = (target.offsetLeft + x) + 'px';
           L++;
           setTimeout(L <= 30 ? iloop : xloop, 10);
         })();
      };
      mv();mv();mv();mv();mv();mv();mv();mv();mv();mv();
    })();
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2010/12/13 22:45:05 - 2010-12-13
  2. 2010/12/13 22:36:46 - 2010-12-13