Mozilla Firefox 拡張機能スレッド Part10

このエントリーをはてなブックマークに追加
228名無しさん@お腹いっぱい。
JSActions用

//Winnyに登録.js
fx2SelWrd();
function fx2SelWrd(){
var WLRPath = "C:\\Program Files\\Winny2\\Tools\\WLR2\\WLR.exe"; //適宜変更、バックスラッシュは2つずつ
var DatPath = "C:\\PROGRA~1\\Winny2\\Tools\\WLR2\\SelWrd.dat"; //下に同じ、但し半角空白禁止
var strSelText;
if (_jsaCScript.context.isTextSelected){
strSelText = window.getSelection().toString();}
try {
var localFile = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
localFile.initWithPath(DatPath);
var uc = Components.classes['@mozilla.org/intl/scriptableunicodeconverter'].getService(Components.interfaces.nsIScriptableUnicodeConverter);
uc.charset = "SHIFT-JIS";
var strDoc = uc.ConvertFromUnicode(strSelText);
var DatPathS = uc.ConvertFromUnicode(DatPath);
var oStream = Components.classes['@mozilla.org/network/file-output-stream;1'].createInstance(Components.interfaces.nsIFileOutputStream);
oStream.init(localFile, 0x02 | 0x08 | 0x20, 644, 0);
var result = oStream.write(strDoc, strDoc.length);
oStream.close();
} catch(e) {
alert("error:\n" + e);
return false;
}
DatPathS = "-2 " + DatPathS;
_jsaCScript.exec(WLRPath,DatPathS);
}