2013-09-22 4 views
1

업데이트 할 FF 확장 프로그램이 있습니다. 문제는 확장 프로그램 도구 모음이 더 이상 주소 표시 줄 옆에 배치되지 않는다는 것입니다. 나는 많은 것을 수색 해 왔고, 스크립팅 만이 그것을 할 수있는 유일한 방법 인 것처럼 보이지만 작동하게하는 방법을 찾지 못했습니다.Firefox 확장 프로그램의 툴바 아이콘

예를 들어 나는 방법을 탐색 모음에 대한 참조를 얻는 아무 생각이 없습니다.

나는이 시도했지만 운 : 당신은 대부분의 certanly 아이콘을 추가 할 수 있습니다

var navBar = document.getElementById('nav-bar'); 
    if (!navBar) { 
     return; 
    } 
    var btn = document.createElement('toolbarbutton'); 
    btn.setAttribute('id', 'mybutton-id'); 
    btn.setAttribute('type', 'button'); 
    btn.setAttribute('class', 'toolbarbutton-1'); 
    btn.setAttribute('image', data.url('bulb.png')); 
    btn.setAttribute('orient', 'horizontal'); 
    btn.setAttribute('label', 'My Button'); 
    navBar.appendChild(btn); 
+0

표준 addons.mozilla.org 거부 ca 응답 없음 : * 추가 ​​기능으로 인해 사용자가 툴바 버튼을 영구적으로 제거 할 수 없으며, 허용되지 않습니다. 첫 실행시 툴바 버튼을 삽입하는 것이 좋습니다.하지만 매번 시작할 때마다 툴바 버튼을 삽입하거나 이동하거나 제거 할 수 없도록하는 것은 아닙니다. * – nmaier

+0

작동하도록 만들었습니까? –

답변

2

는 탐색하지 바를 수 있습니다. 여기에 내가 코드를 사용하는 것 :

function installButton(toolbarId, id, afterId) { 
    if (!document.getElementById(id)) { 
     var toolbar = document.getElementById(toolbarId); 

     if (toolbar) { 
      // If no afterId is given, then append the item to the toolbar 
      var before = null; 
      if (afterId) { 
       var elem = document.getElementById(afterId); 
       if (elem && elem.parentNode == toolbar) 
        before = elem.nextElementSibling; 
      } 


      toolbar.insertItem(id, before); 
      toolbar.setAttribute("currentset", toolbar.currentSet); 
      document.persist(toolbar.id, "currentset"); 

      if (toolbarId == "addon-bar") 
       toolbar.collapsed = false; 
     } 

    } 
} 

당신은 이것을 호출 할 수 있습니다

installButton("nav-bar","YOURBUTTONID");

당신이 내부에 "YOURBUTTONID"을 가져야 기억하여 BrowserToolbarPalette

<toolbarpalette id="BrowserToolbarPalette"> 
    <toolbarbutton id="YOURBUTTONID" 
        image='...' 
        class="..." 
        oncommand="..." 
        tooltiptext=""> 

    </toolbarbutton> 
</toolbarpalette> 

참조 : Toolbar - Code snippets

관련 문제