Top > LDRize > Extension > LDRizeIframe

LDRize/Extension/LDRizeIframe

Last-modified: 2008-04-08 (火) 17:22:34

LDRize IFrame Extension by 958 Edit

概要 Edit

  • LDRize for Seahorse に本家の i を追加する拡張

必須拡張 Edit

  • SeaHorse 1.1.1 以上
  • UserAction Extension 1.0.0 以上

動作確認環境 Edit

  • Windows XP SP2
  • Internet Explorer 7
  • Sleipnir 2.5.17
  • Seahorse 1.1.2
  • UserAction Extension 1.0.0

インストール Edit

  • ソースをコピーし、テキストエディタに貼り付け
  • sleipnir のインストールディレクトリ\plugins\scripts\LDRizeIFrame.js に保存
  • sleipnir のインストールディレクトリ\plugins\seahorse\LDRize\keybindex.js を開く(無い場合は作成)
  • 以下のコードをコピペ('i'の部分は他とかぶらないように。起動キーを変えたい場合は適当な文字に変更)
  1
  2
  3
-
|
!
KEYBIND['i'] = function() {
  sleipnir.RunScript(sleipnir.ScriptFullName.replace(sleipnir.ScriptName, '').replace(/\.js$/, '') + '..\\scripts\\LDRizeIFrame.js');
}

説明 Edit

  • インストール完了後、google とかで検索して i を押してみる
  • iframe が表示されたら スペース とか Shift+スペースを押してみる
  • さらに i を押してみる
  • iframe 表示中に j とか k を押してみる

制限事項 Edit

  • LDRize 0.12 以降対応
  • 本家みたいに j, k で iframe 内をスクロールすることは出来ない
  • 本家みたいにフォーカス遷移で iframe を閉じない

ソース Edit

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
-
|
|
|
-
|
|
|
|
-
-
|
!
!
|
|
|
!
|
|
|
|
|
|
|
|
|
-
-
|
|
|
|
|
|
|
|
|
!
|
|
|
|
!
|
|
-
|
|
|
|
|
-
|
-
|
|
-
|
|
|
|
!
!
!
|
|
-
|
-
|
|
|
|
|
-
|
!
|
|
!
|
!
!
|
!
(function () {
    var IFRAME_IGNORE = [/\.pdf$/, /\.m[0-9]a$/, /\.mp.$/, /\.wmv$/, /\.midi?$/];
 
    var iframe = _document.getElementById('ldrize_iframe');
    if (iframe) {
        _window.LDRize.removeKeyBind(' ');
        _window.LDRize.removeKeyBind('S- ');
        _document.body.focus();
        if (LDRize.jQuery.fn.hide)
            _window.execScript('(' + (function() {
                LDRize.jQuery('#ldrize_iframe').hide('normal', function() {
                    document.body.removeChild(document.getElementById('ldrize_iframe'));
                });
            }).toString() + ')()');
        else
            _document.body.removeChild(_document.getElementById('ldrize_iframe'));
        return;
    }
 
    if (!_window.LDRize) return;
    var paragraph = _window.LDRize.getCurrentParagraph(); if (!paragraph) return;
    var url = _window.LDRize.getParagraphLink(paragraph); if (url == '') return;
    for (var i = 0; i < IFRAME_IGNORE.length; i++)
        if (url.match(IFRAME_IGNORE[i]))
            return;
    var pos = LDRize.jQuery(paragraph).offset();
    var iframe = _document.createElement('iframe');
    try {
        with (iframe.style) {
            var doc = (document.compatMode == 'CSS1Compat') ? document.documentElement : document.body;
            width = doc.clientWidth - 20;
            height = doc.clientHeight - paragraph.offsetHeight - 40;
            position = 'absolute';
            zIndex = 1000;
            top = pos.top + paragraph.offsetHeight;
            left = document.body.scrollLeft + 10;
            border = '1px solid gray';
            display = 'none';
        }
        iframe.setAttribute('frameBorder', "0");
        iframe.id = 'ldrize_iframe';
        iframe.src = url;
        _document.body.appendChild(iframe);
    } catch(e) { return; }
 
    _window.sleipnir = sleipnir;
    _window.execScript('(' + (function() {
        if (LDRize.jQuery.fn.show)
            setTimeout(function() { LDRize.jQuery('#ldrize_iframe').show('normal'); }, 1);
        else
            document.getElementById('ldrize_iframe').style.display = 'block';
        var sleipnir = window.sleipnir;
        var spaceKey = function() {
                var iframe = document.getElementById('ldrize_iframe');
                if (iframe) {
                    iframe.contentWindow.focus();
                    setTimeout(
                        function() {
                            var sh = sleipnir.CreateObject('WScript.Shell')
                            sh.SendKeys(' ');
                            sh = null;
                            setTimeout(function() { document.body.focus(); }, 100);
                        }, 0);
                }
            };
        window.LDRize.addKeyBind(' ', spaceKey);
        window.LDRize.addKeyBind('S- ', spaceKey);
        setTimeout(function() {
            var iframe = document.getElementById('ldrize_iframe');
            var hide = function() {
                    window.detachEvent('onscroll', hide);
                    window.LDRize.removeKeyBind(' ');
                    window.LDRize.removeKeyBind('S- ');
                    window.document.focus();
                    if (LDRize.jQuery.fn.hide)
                        LDRize.jQuery('#ldrize_iframe').hide('normal', function() {
                            document.body.removeChild(document.getElementById('ldrize_iframe'));
                        });
                    else
                        document.body.removeChild(document.getElementById('ldrize_iframe'));
                };
            window.attachEvent('onscroll', hide);
        }, 100);
    }).toString() + ')()');
    _window.sleipnir = null;
})();