Winny補助ツール総合スレ Part11

このエントリーをはてなブックマークに追加
71/3
Firefox
userChrome.jsを使って、WLR登録する方法

(function() {
var mItem = document.createElement("menuitem");
mItem.setAttribute("label", "WLR\u3067\u767b\u9332");
mItem.setAttribute("accesskey", "w");
mItem.setAttribute("hidden", "true");
mItem.setAttribute("oncommand", "fx2SelWrd();");
var cMenu = document.getElementById("contentAreaContextMenu");
cMenu.insertBefore(mItem, cMenu.firstChild);
cMenu.addEventListener("popupshowing", function() {
if (gContextMenu.isTextSelected) {
var sel = document.commandDispatcher.focusedWindow.getSelection().toString();
} else if (gContextMenu.onTextInput) {
var start = gContextMenu.target.selectionStart, end = gContextMenu.target.selectionEnd;
if (start == end) { mItem.hidden = true; return;}
sel = gContextMenu.target.value.substring(start, end);
} else { mItem.hidden = true; return; }
mItem.hidden = /\b[0-9a-f]{32}?\b/.test(sel) ? false : true;
}, false);
})();
var fx2SelWrd = function () {
var Path = "F:\\Program Files\\WLR_Winny_List_Register"; //WLRのフォルダを指定 適宜変更、\は2つずつ
var exePath = Path + "\\WLR.exe";
var datPath = Path + "\\SelWrd.dat";
var dispatcher = document.commandDispatcher;
var strSelText = (dispatcher.focusedWindow.getSelection().toString() ||
dispatcher.focusedElement.value.substring(dispatcher.focusedElement.selectionStart, dispatcher.focusedElement.selectionEnd));
strSelText = strSelText.replace(/^\s+/, "").replace(/\s+$/, "");