Skip to content

Instantly share code, notes, and snippets.

@wenketel
Created November 28, 2014 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wenketel/aab31e26f0376753f6e7 to your computer and use it in GitHub Desktop.
Save wenketel/aab31e26f0376753f6e7 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Tab ContextMenu Tools
// @namespace http://tinyurl.com/7zs29o2
// @description タブのコンテキストメニューに新規メニューを追加する
// @include main
// @author zuzu
// @version 1.0.0
// ==/UserScript==
// --- 参考サイト
// http://www.xuldev.org/firegestures/getscripts.php
// http://www.xuldev.org/blog/?p=76
(function() {
// ----------config
var tabAddMenu = [
{
label : "separator",
},
{// すべてのタブを閉じる
label : "关闭所有标签页",
command : function () {
gBrowser.removeAllTabsBut(gBrowser.addTab("about:blank"));
},
},
{
label : "separator",
},
{// タブの複製
label : "复制标签",
command : function () {
openNewTabWith(gBrowser.currentURI.spec, null, null, null, false);
},
},
{// タブのタイトルを変更
label : "修改标签页标题",
command : function () {
var tab = document.popupNode;
var Tdocument = gBrowser.getBrowserForTab(tab).contentWindow.document;
title = window.prompt("Bitte geben Sie einen neuen Tabtitel", "");
if (title!=null && title!="") {
Tdocument.title = title;
}
},
},
{// タブを閉じて左のタブへフォーカス
label : "Tab schließen & nach links",
command : function () {
var tab = gBrowser.mCurrentTab;
if(tab.previousSibling)
gBrowser.mTabContainer.selectedIndex--;
gBrowser.removeTab(tab);
},
},
{// オプション
label : "设置",
command : function () {
openPreferences();
},
},
{// 履歴サイドバー
label : "历史侧边栏",
command : function () {
toggleSidebar("viewHistorySidebar");
},
},
{// セッションを保存して終了
label : "保存并退出会话",
command : function () {
var prefBranch = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
prefBranch.setBoolPref("browser.sessionstore.resume_session_once", true);
goQuitApplication();
},
},
{// ページ全体を翻訳する
label : "翻译页面",
command : function () {
const FROM = "en";
const TO = "zh-cn";
const DOMAIN = "translate.google.com";
const URL = "http://" + DOMAIN + "/translate?langpair="
+ FROM + "-" + TO + "&hl=" + TO + "&u=";
var curURL = gBrowser.currentURI.spec;
if (curURL.indexOf(DOMAIN) != -1)
BrowserReload();
else
gBrowser.loadURI(URL + encodeURIComponent(curURL));
},
},
// ----------configend
]
for (var i = 0; menu = tabAddMenu[i]; i++) {
if (menu.label == "separator") {
menuItem = document.createElement("menuseparator");
}
else {
menuItem = document.createElement("menuitem");
menuItem.setAttribute("label", menu.label);
menuItem.addEventListener("command", menu.command, false);
}
menuItem.id = "tabAddMenu_" + i;
gBrowser.mStrip.childNodes[1].appendChild(menuItem);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment