Advertisement
Guest User

Untitled

a guest
Jan 28th, 2013
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. // ==UserScript==
  2. // @name tab_open_in_sidebar_menu_plus_0.4.uc.js
  3. // @namespace http://loda.jp/script/
  4. // @description コンテクスト・メニューに「サイドバーで開く」を追加
  5. // @include main
  6. // @compatibility Firefox 3.0 - 3.7a4pre
  7. // @compatibility userChrome.js 0.7 - 0.8 / userChromeJS 1.1
  8. // @compatibility Sub-Script/Overlay Loader v3.0.28mod
  9. // @author otokiti
  10. // @version 0.1: 09/04/03 初版
  11. // @version 0.2: 10/02/14 タブ以外の部分の右クリックでエラーが出るのを回避。
  12. // @version 0.3: 10/03/15 Bug 347930 - Tab strip should be a toolbar instead
  13. // @version 0.4: 10/03/27 Bug 554991 - allow tab context menu to be modified by normal XUL overlays
  14. // ==/UserScript==
  15. (function() {
  16. // Link
  17. var contentAreaContextMenu = document.getElementById("contentAreaContextMenu");
  18. var c_menu = document.createElement("menuitem");
  19. c_menu.setAttribute("id", "ucjs_openlinksidebar");
  20. c_menu.setAttribute("label", "Link in Sidebar öffnen");
  21. c_menu.addEventListener("command", function() {
  22. try {
  23. urlSecurityCheck(gContextMenu.linkURL, gContextMenu.target.ownerDocument.nodePrincipal);
  24. openWebPanel("Web Page", gContextMenu.linkURL);
  25. } catch(e) {}
  26. }, false);
  27. contentAreaContextMenu.insertBefore(c_menu, document.getElementById("context-sep-open"));
  28. contentAreaContextMenu.addEventListener("popupshowing",
  29. function() {
  30. document.getElementById("ucjs_openlinksidebar").hidden =
  31. document.getElementById("context-openlinkintab").hidden;
  32. } , false);
  33.  
  34. // Tab
  35. // -- Bug 554991 - allow tab context menu to be modified by normal XUL overlays
  36. var tabContextMenu =
  37. document.getAnonymousElementByAttribute(gBrowser, "anonid", "tabContextMenu")
  38. || gBrowser.tabContainer.contextMenu;
  39.  
  40. var t_menu = document.createElement("menuitem");
  41. t_menu.setAttribute("id", "ucjs_context_openTabInSidebar");
  42. t_menu.setAttribute("label", "Tab in Sidebar öffnen");
  43. t_menu.addEventListener("command", function() {
  44. var tab = document.popupNode;
  45. openWebPanel(tab.label, gBrowser.getBrowserForTab(tab).contentWindow.location.href);
  46. }, false);
  47. var TargetMenu = document.getElementById("context_openTabInWindow");
  48. if (!TargetMenu) // Fx3.0 only
  49. var TargetMenu = document.getElementById("context_reloadAllTabs");
  50. tabContextMenu.insertBefore(t_menu, TargetMenu.nextSibling);
  51. tabContextMenu.addEventListener("popupshowing",
  52. function() {
  53. var flg = true;
  54. try {
  55. flg = gBrowser.getBrowserForTab(document.popupNode).contentWindow.location.href == "about:blank";
  56. } catch(e) {}
  57. document.getElementById("ucjs_context_openTabInSidebar").setAttribute("disabled", flg);
  58. } , false);
  59.  
  60. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement