LDRize IFrame Extension by 958
概要
- LDRize for Seahorse に本家の i を追加する拡張
必須拡張
- SeaHorse 1.1.1 以上
- UserAction Extension 1.0.0 以上
動作確認環境
- Windows XP SP2
- Internet Explorer 7
- Sleipnir 2.5.17
- Seahorse 1.1.2
- UserAction Extension 1.0.0
インストール
- ソースをコピーし、テキストエディタに貼り付け
- sleipnir のインストールディレクトリ\plugins\scripts\LDRizeIFrame.js に保存
- sleipnir のインストールディレクトリ\plugins\seahorse\LDRize\keybindex.js を開く(無い場合は作成)
- 以下のコードをコピペ('i'の部分は他とかぶらないように。起動キーを変えたい場合は適当な文字に変更)
KEYBIND['i'] = function() {
sleipnir.RunScript(sleipnir.ScriptFullName.replace(sleipnir.ScriptName, '').replace(/\.js$/, '') + '..\\scripts\\LDRizeIFrame.js');
}
説明
- インストール完了後、google とかで検索して i を押してみる
- iframe が表示されたら スペース とか Shift+スペースを押してみる
- さらに i を押してみる
- iframe 表示中に j とか k を押してみる
制限事項
- LDRize 0.12 以降対応
- 本家みたいに j, k で iframe 内をスクロールすることは出来ない
- 本家みたいにフォーカス遷移で iframe を閉じない
ソース
(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;
})();