西武バスロケーションシステムを GM で修正

西武バスロケーションシステムって IE 専用で Fx では動かないのね。

哀しい。ということで GreaseMonkey でどうにかしてみた。

// ==UserScript==
// @name           Seibu Bus Location System fixes
// @namespace      http://xworks.org/
// @include        http://loca.seibubus.co.jp/seibuloca/depArr/*
// ==/UserScript==

(function(){
    var w = (typeof unsafeWindow != 'undefined') ? unsafeWindow : window;
    w.btnClick = function (selId) {
        if( w.chkData() ){
            return;
        }
        var f = document.wrappedJSObject.DepArrInputForm;
        var depKey = f.DepKey.value;
        if(f.ArrKey) var arrKey = f.ArrKey.value;
        var DspURL;
        if (depKey != 0 && typeof arrKey == 'undefined'){ //depArr/DepArrInputPole.asp
            DspURL = "DepArrSeekDest.asp?DspKind=" + 1;
            DspURL = DspURL + "&StopKey=" + depKey;
            document.getElementsByTagName('iframe')[0].src = DspURL;
        } else if (depKey != 0 && arrKey != 0){ //depArr/DepArrInputStops.asp
            DspURL = "DepArrDspStatus.asp?DspKind=" + 1;
            DspURL = DspURL + "&DepKey=" + depKey;
            DspURL = DspURL + "&ArrKey=" + arrKey;
            document.getElementsByTagName('iframe')[0].src = DspURL;
        } else {
            f.submit();
        }
    }
})();

seibubuslocationsystem.user.js インストール

iframe 要素に name 属性を使って form のように document.name とアクセスしているのと iframe 内の URL の変更に location を使っているのが原因で動かない。良くできているのに勿体ないなぁ。