Changeset 7993

Show
Ignore:
Timestamp:
03/16/08 15:08:56 (5 years ago)
Author:
cho45
Message:

lang/javascript/userscripts/openfl.syncratewithldr.user.js:

ログインしたあと勝手に処理を継続するように

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/userscripts/openfl.syncratewithldr.user.js

    r7508 r7993  
    77// ==/UserScript== 
    88// OpenFL の set_rate をフックし、LDR にレート変更を反映させます。 
     9// 
     10// LDR にログインしていない場合 (ApiKey の取得に失敗した場合): 
     11//     1. GM_getValue をループさせ ApiKey がセットされるのを待つ 
     12//     2. Livedoor のログイン画面を別ウィンドウで表示させる 
     13//     3. ログインできると  http://www.livedoor.com/close に飛される。 
     14//     4. /close にフックして ApiKey を再度取得し、GM_setValue 
     15//     5. ログインウィンドウを閉じる 
     16//     6. OpenFL 側の GM に制御が戻り、継続が実行される 
    917 
    1018(function () { with (D()) { 
    11  
    12 if (location.href == "http://www.livedoor.com/close") { 
    13         window.close(); 
    14         return; 
    15 } 
    1619 
    1720function getApiKey () { 
     
    2427                        return api_key; 
    2528                } else { 
     29                        GM_setValue("ApiKey", ""); 
    2630                        callee._cache = null; 
    2731                        if (callee._cache === null) { 
    2832                                window.open("http://member.livedoor.com/login/?.next="+encodeURIComponent("http://www.livedoor.com/close")); 
    2933                        } 
    30                         throw "Getting ApiKey failed"; 
     34                        unsafeWindow.message("Getting ApiKey failed... Waiting for logging-in.."); 
     35                        return next(function () { 
     36                                var api_key = GM_getValue("ApiKey"); 
     37                                if (api_key) { 
     38                                        GM_setValue("ApiKey", ""); 
     39                                        return api_key; 
     40                                } else { 
     41                                        return wait(1).next(arguments.callee); 
     42                                } 
     43                        }); 
    3144                } 
    3245        }); 
     
    6578        }); 
    6679}; 
     80 
     81// ApiKey の取得に失敗し、ログイン画面を表示したあととばされる先 
     82// ApiKey をセットして制御を OpenFL 側にかえす 
     83if (location.href == "http://www.livedoor.com/close") { 
     84        getApiKey().next(function (api_key) { 
     85                GM_setValue("ApiKey", api_key); 
     86                window.close(); 
     87        }); 
     88        return; 
     89} 
    6790 
    6891