Changeset 12016

Show
Ignore:
Timestamp:
05/20/08 03:15:45 (5 years ago)
Author:
nishio
Message:

lang/javascript/userscript/ogamemod.user.js: 探索の半自動化の途中、Inactiveな星を抽出してランキングと一緒にリスト表示

Files:
1 modified

Legend:

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

    r11940 r12016  
    66// @include        http://uni1.ogame.jp/* 
    77// ==/UserScript== 
    8  
    9 var Ogame = {}; // interface for Firebug 
    10 window.Ogame = Ogame; 
    118(function(){ 
     9    var ogame = {}; 
     10    unsafeWindow.ogame = ogame; 
     11 
     12    //--- utils 
    1213    function to_number(s){ 
    1314        return 1 * s.replace(".", "").replace(">", "").replace("<", ""); 
     
    2930        return req_time; 
    3031    } 
     32 
     33    function $x(xpath){ // single 
     34        return document.evaluate( 
     35            xpath, document, null, 9, null 
     36            ).singleNodeValue; 
     37    } 
     38 
     39    function $xs(xpath, func){ // multi 
     40        var xs = document 
     41            .evaluate(xpath, document, null,  
     42                      XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,  
     43                      null); 
     44        if(func){ 
     45            for(var i=0; i < xs.snapshotLength; i++ ){ 
     46                var e = xs.snapshotItem(i); 
     47                func(e); 
     48            } 
     49        } 
     50        return xs; 
     51    } 
     52 
     53     
     54    function gm_get(name, x){ 
     55        var xs = GM_getValue(name); 
     56        if(!xs){ 
     57            xs = []; 
     58        }else{ 
     59            xs = eval(xs); 
     60        } 
     61        return xs; 
     62    } 
     63 
     64    function gm_push(name, x){ 
     65        var xs = gm_get(name); 
     66        xs.push(x); 
     67        GM_setValue(name, xs.toSource()); 
     68    } 
     69 
     70    function gm_shift(name){ 
     71        var xs = gm_get(name); 
     72        x = xs.shift(); 
     73        GM_setValue(name, xs.toSource()); 
     74        return x; 
     75    } 
     76 
     77    //--- end utils 
     78 
    3179    var page = window.location.href.match(/page=([^&]+)&/); 
    3280    if(page) page = page[1]; 
     
    3583    if(page == "resources"){ 
    3684        // resource page 
    37         var tmp = document 
     85        var tmp = document 
    3886            .evaluate("//tr[contains(., '\u5408\u8a08:')]",  
    3987                      document, null, 9, null).singleNodeValue; 
     
    81129        .evaluate("//td[@class='l' and count(./br)!=1]", 
    82130                  document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); 
    83     console.log(tmp.snapshotLength); 
    84131    for(var i=0; i < tmp.snapshotLength; i++ ){ 
    85132        var e = tmp.snapshotItem(i); 
     
    134181 
    135182 
    136  
    137     data = document.body.innerHTML; 
    138     // $B%"%C%W%0%l!<%I(B 
    139     data = data.replace(/\u30a2\u30c3\u30d7\u30b0\u30ec\u30fc\u30c9/g, "up");  
    140     // $B%l%Y%k(B 
    141     data = data.replace(/\u30ec\u30d9\u30eb/g, "lv"); 
    142  
    143     data = data.replace(/level\s+/g, "lv"); 
    144     data = data.replace(/<table width="530">/g, "<table>"); 
    145  
    146     //document.body.innerHTML = data; 
     183    // $B<+F0C5:w(B 
     184    if(page == "galaxy"){ 
     185        // (i)$B$N@1$rC5$9(B 
     186        tmp = document 
     187            .evaluate("//tr[th[contains(., '(i')]]", 
     188                      document, null,  
     189                      XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,  
     190                      null); 
     191 
     192        console.log(tmp.snapshotLength); 
     193        var list = ""; 
     194        for(var i=0; i < tmp.snapshotLength; i++ ){ 
     195            var e = tmp.snapshotItem(i); 
     196            var data = e.innerHTML; 
     197            var rank = data.match( 
     198                /\u306f(\d+)\u306b\u30e9\u30f3\u30af/ //$B$O(B(\d+)$B$K%i%s%/(B 
     199                )[1]; 
     200 
     201            console.log(rank); 
     202            var pos = data.match(/\d+,(\d+),(\d+),(\d+),\d+,\d+/); 
     203            pos = pos[1] + ":" + pos[2] + ":" + pos[3]; 
     204            list += "<br>" + pos + " " + rank; 
     205        } 
     206        // $BOG@1$,?"L1CO2=(B 
     207        $x("//td[contains(., '\u60d1\u661f\u304c\u690d\u6c11\u5730\u5316')]").innerHTML += list;  
     208    } 
     209 
     210    /* 
     211 
     212//$x("//a[contains(@href, 'flotte')]") 
     213var spy_targets = eval(GM_getValue("OGAME_SPY_TARGETS")); 
     214 
     215// page == "flotten1" 
     216if(spy_targets){ 
     217 
     218  GM_setValue("OGAME_AUTO_SPY", true); 
     219// TODO: $B%9%Q%$A%$,$"$k$+%A%'%C%/!u$J$1$l$PBT$C$F%j%m!<%I(B 
     220  maxShip("ship210") 
     221  setTimeout(function(){ 
     222    $x("//input[@type='submit']")[0].click() 
     223  }, 1); 
     224 
     225}else{ 
     226  GM_setValue("OGAME_AUTO_SPY", false); 
     227} 
     228 
     229// page == "flotten2" 
     230if(GM_getValue("OGAME_AUTO_SPY")){ 
     231  var target = "1:127:11".split(":"); 
     232  $x("//th/input")[0].value = target[0] 
     233  $x("//th/input")[1].value = target[1] 
     234  $x("//th/input")[2].value = target[2] 
     235  $x("//th/input")[3].click() 
     236} 
     237 
     238// page == "flotten3" 
     239 
     240$x("//th/input[@type='radio']")[2].click() 
     241$x("//th/input[@type='submit']")[0].click() 
     242 
     243     */ 
     244 
    147245 
    148246