firefox userChrome.js greasemonkeyスクリプトスレ

このエントリーをはてなブックマークに追加
377名無しさん@お腹いっぱい。
リンクもしくは選択文字列もしくは現在のURLをTubePlayerで開く
二行目をTubePlayerのインスコパスにあわせて設定してね☆

(function() {
var playerPath = 'C:\\Program Files\\TubePlayer\\TubePlayer.exe'
var cacm = document.getElementById('contentAreaContextMenu');
var mitem = cacm.insertBefore(document.createElement('menuitem'), cacm.firstChild);
mitem.setAttribute('label', 'TubePlayer\u3067\u958b\u304f');
mitem.setAttribute('accesskey', 'z');
mitem.setAttribute('oncommand', 'gContextMenu.openTubePlayer();');
var re = /youtube\.com|nicovideo\.jp/;
cacm.addEventListener('popupshowing', function() {
mitem.hidden = !re.test(gContextMenu.onLink ? gContextMenu.linkURL : gContextMenu.isContentSelected ? getBrowserSelection() : gContextMenu.docURL);
}, false);
nsContextMenu.prototype.openTubePlayer = function() {
var lf = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
lf.initWithPath(playerPath);
var proc = Components.classes["@mozilla.org/process/util;1"].getService(Components.interfaces.nsIProcess);
proc.init(lf);
var url = this.onLink ? this.linkURL : this.isContentSelected ? 'http://' + getBrowserSelection().replace(/^h?ttp:\/\//, '') : this.docURL;
proc.run(false, [url], 1);
};
})();