Changeset 32953

Show
Ignore:
Timestamp:
04/30/09 07:54:36 (4 years ago)
Author:
arccosine
Message:

キーイベント判定のところをちょっと変更。

Files:
1 modified

Legend:

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

    r30393 r32953  
    44// @include   http://zigsow.jp/* 
    55// @author    Arc Cosine 
    6 // @version   1.7 
     6// @version   1.8 
    77// ==/UserScript== 
    88 (function(){ 
     9 
     10    /** simple version of $X 
     11     * $X(exp); 
     12     * $X(exp, context); 
     13     * @source http://gist.github.com/3242.txt 
     14     */ 
     15   var $X = function (exp, context) { 
     16      context || (context = document); 
     17      var expr = (context.ownerDocument || context).createExpression(exp, function (prefix) { 
     18        return document.createNSResolver(context.documentElement || context).lookupNamespaceURI(prefix) || 
     19          context.namespaceURI || document.documentElement.namespaceURI || ""; 
     20        }); 
     21      var result = expr.evaluate(context, XPathResult.ANY_TYPE, null); 
     22        switch (result.resultType) { 
     23          case XPathResult.STRING_TYPE : return result.stringValue; 
     24          case XPathResult.NUMBER_TYPE : return result.numberValue; 
     25          case XPathResult.BOOLEAN_TYPE: return result.booleanValue; 
     26          case XPathResult.UNORDERED_NODE_ITERATOR_TYPE: 
     27            // not ensure the order. 
     28            var ret = [], i = null; 
     29            while (i = result.iterateNext()) ret.push(i); 
     30            return ret; 
     31        } 
     32      return null; 
     33    } 
     34 
     35 
    936  
    1037     if( typeof document.getElementsByClassName != 'function' ){ 
     
    4269  
    4370     function sendCool(){ 
    44          var o = document.getElementsByClassName('evaluation'); 
    45          if( o[0].firstChild.nodeName == 'A' ){ 
    46              location.href = o[0].firstChild; 
     71         var o = $X('//div[@class="evaluation"]/a'); 
     72         if( o[0].nodeName == 'A' ){ 
     73             location.href = o[0]; 
    4774         } 
    4875     } 
     
    85112            'c' : function(){ sendCool(); } 
    86113        }; 
    87         var t = e.target; 
    88         if( t.nodeType == 1 ){ 
    89            var tn = t.tagName.toLowerCase(); 
    90            if( tn == 'input' || tn == 'textarea' ){ 
    91                return; 
    92            } 
    93            var pressKey = String.fromCharCode(e.which); 
    94            if( typeof handler[pressKey] == "function" ){ 
    95                e.preventDefault();    //Stop Default Event 
    96                handler[pressKey].apply(); 
    97            } 
    98         } 
     114        if( e.target.tagName == 'INPUT' || e.target.tagName == 'TEXTAREA' ) return; 
     115        var pressKey= (e.ctrlKey?'C-':'') + String.fromCharCode(e.which) 
     116        if( typeof handler[pressKey] != "function" ) return; 
     117        try{ 
     118            e.preventDefault();    //Stop Default Event 
     119            handler[pressKey].apply(); 
     120        }catch(d){} 
    99121     }, false ); 
    100122 })();