Changeset 20891

Show
Ignore:
Timestamp:
10/07/08 13:25:12 (6 weeks ago)
Author:
drry
Message:
  • fixed missing vars.
  • et cetera.
Location:
lang/javascript/userscripts
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/userscripts/vimlike.user.js

    r20883 r20891  
    1  // ==UserScript== 
    2  // @name      vimlike 
    3  // @namespace http://looxu.blogspot.com/ 
    4  // @author    Arc Cosine 
    5  // @version   1.0 
    6  // ==/UserScript== 
     1// ==UserScript== 
     2// @name      vimlike 
     3// @namespace http://looxu.blogspot.com/ 
     4// @author    Arc Cosine 
     5// @version   1.1 
     6// ==/UserScript== 
    77 (function(){ 
    8      ny = 30; 
    9  
     8     var ny = 30; 
     9  
    1010     function sendDw(){ 
    11         y = window.pageYOffset; 
     11        var y = window.pageYOffset; 
    1212        y = y + ny; 
    13         scroll(0,y); 
     13        scroll(0, y); 
    1414     } 
    15    
     15  
    1616     function sendUp(){ 
    17         y = window.pageYOffset; 
     17        var y = window.pageYOffset; 
    1818        y = y - ny; 
    19         scroll(0,y); 
     19        scroll(0, y); 
    2020     } 
    21  
     21  
    2222     function reLoad(){ 
    2323        location.reload(); 
    2424     } 
    25  
     25  
    2626     function delTab(){ 
    2727        window.opener = window; 
    28         var win=window.open(location.href,"_self"); 
     28        var win = window.open(location.href, "_self"); 
    2929        win.close(); 
    3030     } 
    31    
     31  
    3232     function hisBak(){ 
    3333        history.back(); 
    3434     } 
    35  
     35  
    3636     function hisFor(){ 
    3737        history.forward(); 
    3838     } 
    39  
     39  
    4040     function addKeyBind( keyChar, func, eve ){ 
    41          var pressKey = eve.which; 
    42          keyChar = keyChar.charCodeAt(keyChar); 
    43          if( pressKey == keyChar ){ 
    44              eve.preventDefault();    //Stop Default Event  
    45              eval(func); 
    46          } 
     41        var pressKey = eve.which; 
     42        keyChar = keyChar.charCodeAt(keyChar); 
     43        if( pressKey == keyChar ){ 
     44           eve.preventDefault();    //Stop Default Event 
     45           eval(func); 
     46        } 
    4747     } 
    4848  
    49      window.addEventListener( 'keypress', function(e){ 
    50          var t = e.target; 
    51          if( t.nodeType == 1){ 
    52          tn=t.tagName.toLowerCase(); 
    53              if( tn == 'input' || tn == 'textarea' ){ 
    54                  return; 
    55              } 
    56              addKeyBind( 'j', 'sendDw()', e ); 
    57              addKeyBind( 'k', 'sendUp()', e ); 
    58              addKeyBind( 'r', 'reLoad()', e ); 
    59              addKeyBind( 'd', 'delTab()', e ); 
    60              addKeyBind( 'z', 'hisBak()', e ); 
    61              addKeyBind( 'x', 'hisFor()', e ); 
    62          } 
    63      },false ); 
     49     window.addEventListener( 'keypress', function( e ){ 
     50        var t = e.target; 
     51        if( t.nodeType == 1 ){ 
     52           var tn = t.tagName.toLowerCase(); 
     53           if( tn == 'input' || tn == 'textarea' ){ 
     54              return; 
     55           } 
     56           addKeyBind( 'j', 'sendDw()', e ); 
     57           addKeyBind( 'k', 'sendUp()', e ); 
     58           addKeyBind( 'r', 'reLoad()', e ); 
     59           addKeyBind( 'd', 'delTab()', e ); 
     60           addKeyBind( 'z', 'hisBak()', e ); 
     61           addKeyBind( 'x', 'hisFor()', e ); 
     62        } 
     63     }, false ); 
    6464 })(); 
  • lang/javascript/userscripts/zigsow.user.js

    r20884 r20891  
    1  // ==UserScript== 
    2  // @name      zigsow shortcut 
    3  // @namespace http://looxu.blogspot.com/ 
    4  // @include   http://zigsow.jp/* 
    5  // @author    Arc Cosine 
    6  // @version   1.5 
    7  // ==/UserScript== 
     1// ==UserScript== 
     2// @name      zigsow shortcut 
     3// @namespace http://looxu.blogspot.com/ 
     4// @include   http://zigsow.jp/* 
     5// @author    Arc Cosine 
     6// @version   1.6 
     7// ==/UserScript== 
    88 (function(){ 
    99  
    10      if( !document.getElementsByClassName ){ 
    11          document.getElementsByClassName = function(className) { 
     10     if( typeof document.getElementsByClassName != 'function' ){ 
     11         document.getElementsByClassName = function( className ){ 
    1212             var elementsAll = document.getElementsByTagName('*') || document.all; 
    1313             var elements = new Array(); 
    14              for(var i = 0; i < elementsAll.length; i++) { 
    15                  var classNames = elementsAll[i].className.split(' '); 
    16                  for(var j = 0; j < classNames.length; j++) { 
    17                      if (classNames[j] == className) { 
     14             for(var i = 0, l = elementsAll.length; i < l; i++){ 
     15                 var classNames = elementsAll[i].className.split(/\s+/); 
     16                 for(var j = 0, m = classNames.length; j < m; j++){ 
     17                     if( classNames[j] == className ){ 
    1818                         elements[elements.length] = elementsAll[i]; 
    1919                         break; 
     
    2121                 } 
    2222             } 
    23               return elements; 
    24          } 
     23             return elements; 
     24         }; 
    2525     } 
    2626  
     
    3131             loc = document.getElementsByClassName(otherPage); 
    3232         } 
    33          if( !loc[0] ) loc=document.getElementsByClassName(userPage); 
     33         if( !loc[0] ) loc = document.getElementsByClassName(userPage); 
    3434         if( loc[0] ) location.href = loc[0].href; 
    3535         return; 
     
    5252         if( help != undefined ){ 
    5353             document.body.removeChild(help); 
    54              return;     
     54             return; 
    5555         } 
    5656         help = document.createElement('div'); 
     
    7474         keyChar = keyChar.charCodeAt(keyChar); 
    7575         if( pressKey == keyChar ){ 
    76              eve.preventDefault();    //Stop Default Event  
     76             eve.preventDefault();    //Stop Default Event 
    7777             eval(func); 
    7878         } 
     
    8181     window.addEventListener( 'keypress', function(e){ 
    8282         var t = e.target; 
    83          if( t.nodeType == 1){ 
    84          tn=t.tagName.toLowerCase(); 
     83         if( t.nodeType == 1 ){ 
     84             var tn = t.tagName.toLowerCase(); 
    8585             if( tn == 'input' || tn == 'textarea' ){ 
    8686                 return; 
     
    9393             addKeyBind( '?', 'showHelp()', e ); 
    9494             addKeyBind( 'i', 'location.href = "http://zigsow.jp/?m=pc&a=page_h_ranking_summary"', e ); 
    95              addKeyBind( 'o', 'sendOk()',e ); 
     95             addKeyBind( 'o', 'sendOk()', e ); 
    9696             addKeyBind( 'c', 'sendCool()', e ); 
    9797         } 
    98      },false ); 
     98     }, false ); 
    9999 })();