Полезная информация

Многие проблемы быстрее решаются поиском по форуму и чтением FAQ, чем созданием новой темы и томительным ожиданием ответа.

№357602-02-2012 18:08:59

Abricosio
Участник
 
Группа: Members
Зарегистрирован: 13-01-2011
Сообщений: 30
UA: Firefox 9.0
Веб-сайт

Re: Custom Buttons

Anton пишет

Abricosio пишет: Находимся на сайте1, на нем ссылка на сайт2 (который необходимо задать в кнопке заранее), как сделать красными ссылки от этого сайта2?Как сделать постоянно включенную данную функцию?Возможно я ошибаюсь, но мне кажется, это можно сделать вообще без расширений, через userContent.css.

А кто-нибудь может помочь, как это возможно реализовать через usercontent.css?
Спасибо

Отсутствует

 

№357702-02-2012 19:31:54

bunda1
Moderator
 
Группа: Moderators
Откуда: Латвия
Зарегистрирован: 09-02-2010
Сообщений: 4811
UA: Firefox 3.6

Re: Custom Buttons

okkamas_knife пишет

сделать так чтоб функция проверки данных запускалась каждые полчаса  с 12ч до 16ч а в остальное время просто дожидалась запуска

Может это поможет.
Stopwatch | custombuttons

Отсутствует

 

№357802-02-2012 19:54:32

Abricosio
Участник
 
Группа: Members
Зарегистрирован: 13-01-2011
Сообщений: 30
UA: Firefox 9.0
Веб-сайт

Re: Custom Buttons

okkamas_knife пишет

Abricosioну вот же!http://forum.mozilla-russia.org/viewtop … 35#p542935

Если можно напишите пожалуйста аналогичные варианты для:
1. любой ссылки, содержащей домен site.com
2. Для внешней ссылки != site.com
3. Для внутренней ссылки == site.com

Спасибо заранее огромное!

Отсутствует

 

№357902-02-2012 22:36:18

Anton
Участник
 
Группа: Extensions
Откуда: от верблюда
Зарегистрирован: 14-12-2004
Сообщений: 3057
UA: Firefox 10.0
Веб-сайт

Re: Custom Buttons

okkamas_knife

подскажи как сделать  а то я чтото с setInterval и setTimeout
никак не соображу как организовать следующее
есть функция проверки данных
её надо запускать с 12 до 16 раз в полчаса в остальное время ждать.

Ставишь таймаут на пол-часа. В функции, обрабатывающей таймаут проверяешь, попадает ли текущее время в заданный интервал и, если попадает, выполняешь нужные действия. Перед выходом из функции снова ставишь тайм-аут.

ps а есть какая нибудь штука просто следящая за временем и выполняющаяя действие в указанное время?

Не помню, чтобы я такое видел.

Добавлено 02-02-2012 22:38:39
Abricosio

Если можно напишите пожалуйста аналогичные варианты для:
1. любой ссылки, содержащей домен site.com
2. Для внешней ссылки != site.com
3. Для внутренней ссылки == site.com

Как-то так:

скрытый текст

Выделить код

Код:

/* 1 */
a[href*="site.com"] {
    color: yellow !important;
}
/* 2, 3 */
@-moz-document url-prefix(http://site.com) {
/* 2 */
a[href^="http"]:not([href*="site.com"]) {
    color: red !important;
}
/* 3 */
a[href*="site.com"],
a:not([href^="http"]) {
    color: green !important; }
}

Отредактировано Anton (02-02-2012 22:39:49)


Время настанет, время придет...
И лис кОнкурiентов на части порвет !!!

Отсутствует

 

№358003-02-2012 00:26:41

Abricosio
Участник
 
Группа: Members
Зарегистрирован: 13-01-2011
Сообщений: 30
UA: Firefox 9.0
Веб-сайт

Re: Custom Buttons

Anton
Спасибо большое!
Только ещё вопрос, я неправильно изначально спросил, а если мне необходимо 2-й и 3-й пункт, если я не знаю какой домен у меня открыт (т.е. для всех доменов), какой код необходимо применить?

Отсутствует

 

№358104-02-2012 11:26:24

Ste_pan
Участник
 
Группа: Members
Откуда: приморский край п.сибирцево
Зарегистрирован: 13-02-2011
Сообщений: 63
UA: Firefox 7.0

Re: Custom Buttons

Lenya1995 пишет

Всем здравствуйте! Ste_pan, а можно в эту кнопку добавить функцию поиска обновлений дополнений? Мне кажется, если бы это было бы реализовано, то данная кнопка могла бы быть очень востребована.

ну вообщем щас кнопка должна работать у всех, добавил кнопку "упдате" при нажатии проверяется наличие обнавления ,если нет оного имя аддона синеет
, если есть подчеркивается с низу и кнопка "упдате" становится кнопкой install/true щелчек по ней установить обновление,если установилось нармально имя аддона зеленет и кнопка "упдате" становится кнопкой "cancel",

скрытый текст

Выделить код

Код:

var s=Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
var pref=Application.prefs.get("lightweightThemes.isThemeSelected")
if(!(pref))
    s.setCharPref('lightweightThemes.isThemeSelected','true')
else
    pref.events.addListener("change", function() {s.setBoolPref('lightweightThemes.isThemeSelected', true)});
var val = this. getAttribute ("id"); 
var s=Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm"); 
this. x= function ()
    {
        var groupbox=
        <tabbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
        <tabs>
            <tab label="add-ons" image="11"/>
            <tab label="themes" image="11"/>
            <tab label="styles" image="11"/>
            <tab label="personas" image="11"/>
        </tabs>
        <tabpanels>
            <tabpanel class="add_on">
                <vbox class="add_on" hidden="false">
                    <hbox hidden="false">
                        <label value="Enable" onclick="var  style_=&quot;color:#000000;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#000000;&quot;&#xA;var style_sel ='color:#FF6600;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#6633FF'&#xA;var Node=this.parentNode.childNodes;&#xA;for (var i = 0; i &lt;3; i++)&#xA;&#x9;&#x9;{&#xA;&#x9;&#x9;&#x9;&#xA;Node[i]. setAttribute (&quot;style&quot;, style_)&#xA;&#x9;&#x9;};&#xA;this.setAttribute (&quot;style&quot;,style_sel)&#xA;var Node=this.parentNode.nextSibling .childNodes;&#xA;for (var i = 0; i &lt;3; i++)&#xA;&#x9;&#x9;{&#xA;&#x9;&#x9;&#xA;if(Node[i].className ==this.className){&#xA;&#x9;&#x9;&#x9;&#x9;Node[i].hidden=false}&#xA;&#x9;&#x9;&#x9;else{&#xA;&#x9;&#x9;&#x9;&#x9;Node[i].hidden=true}&#xA;&#x9;&#x9;};&#xA;&#x9;&#x9;&#xA;" class="Enable_"/>
                        <label value="Disable" onclick="var  style_=&quot;color:#000000;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#000000;&quot;&#xA;var style_sel ='color:#FF6600;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#6633FF'&#xA;var Node=this.parentNode.childNodes;&#xA;for (var i = 0; i &lt;3; i++)&#xA;&#x9;&#x9;{&#xA;&#x9;&#x9;&#x9;&#xA;Node[i]. setAttribute (&quot;style&quot;, style_)&#xA;&#x9;&#x9;};&#xA;this.setAttribute (&quot;style&quot;,style_sel)&#xA;var Node=this.parentNode.nextSibling .childNodes;&#xA;for (var i = 0; i &lt;3; i++)&#xA;&#x9;&#x9;{&#xA;&#x9;&#x9;&#xA;if(Node[i].className ==this.className){&#xA;&#x9;&#x9;&#x9;&#x9;Node[i].hidden=false}&#xA;&#x9;&#x9;&#x9;else{&#xA;&#x9;&#x9;&#x9;&#x9;Node[i].hidden=true}&#xA;&#x9;&#x9;};&#xA;&#x9;&#x9;&#xA;" class="Disable_"/>
                        <label value="False" onclick="var  style_=&quot;color:#000000;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#000000;&quot;&#xA;var style_sel ='color:#FF6600;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#6633FF'&#xA;var Node=this.parentNode.childNodes;&#xA;for (var i = 0; i &lt;3; i++)&#xA;&#x9;&#x9;{&#xA;&#x9;&#x9;&#x9;&#xA;Node[i]. setAttribute (&quot;style&quot;, style_)&#xA;&#x9;&#x9;};&#xA;this.setAttribute (&quot;style&quot;,style_sel)&#xA;var Node=this.parentNode.nextSibling .childNodes;&#xA;for (var i = 0; i &lt;3; i++)&#xA;&#x9;&#x9;{&#xA;&#x9;&#x9;&#xA;if(Node[i].className ==this.className){&#xA;&#x9;&#x9;&#x9;&#x9;Node[i].hidden=false}&#xA;&#x9;&#x9;&#x9;else{&#xA;&#x9;&#x9;&#x9;&#x9;Node[i].hidden=true}&#xA;&#x9;&#x9;};&#xA;&#x9;&#x9;&#xA;" class="False_"/>
                    </hbox>
                    <box>
                        <vbox class="Enable_" hidden="false"/>
                        <vbox class="Disable_" hidden="true"/>
                        <vbox hidden="true" class="False_"/>
                    </box>
                </vbox>
            </tabpanel>
            <tabpanel class="theme_"/>
            <tabpanel class="styles_">
                <vbox>
                    <vbox class="st_e"/>
                    <menuseparator/>
                    <vbox class="st_d"/>
                </vbox>
            </tabpanel>
            <tabpanel class="pesonas_"/>
        </tabpanels>
    </tabbox>
    groupbox =  cbu. makeXML(groupbox);
    
    return groupbox
    }
this. xulFav = function ()
    {
        var groupbox=
        
        <vbox onmouseout="this.firstChild.nextSibling.hidden=true" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
            <vbox onmouseover="this.nextSibling.hidden=false">
                <menuitem label="hjgjghjghj" class="menuitem-iconic bookmark-item"/>
            </vbox>
            <hbox hidden="true" onblur="this.hidden=true" onmouseup="this.hidden=true" onmouseover="this.hidden=false">
                <button label="Preview" orient="horizontal" onmouseover="this.parentNode.hidden=false" image="11"/>
                <button label="del" onmouseover="this.parentNode.hidden=false" image="11"/>
                <button label="-" onmouseover="this.parentNode.hidden=false" image="11"/>
            </hbox>
        </vbox>
    
    
    groupbox =  cbu. makeXML(groupbox);
    
    return groupbox
    }
this. xulFavSel = function ()
    {
        var groupbox=
        
        <vbox onmouseout="this.firstChild.nextSibling.hidden=true" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
            <vbox onmouseover="this.nextSibling.hidden=false">
                <menuitem label="hjgjghjghj" class="menuitem-iconic bookmark-item"/>
            </vbox>
            <hbox hidden="true" onblur="this.hidden=true" onmouseup="this.hidden=true" onmouseover="this.hidden=false">
                <button label="del" onmouseover="this.parentNode.hidden=false" image="11"/>
            </hbox>
            <menuseparator/>
        </vbox>
        

    groupbox =  cbu. makeXML(groupbox);
    
    return groupbox
    }

this. xul_ = function ()
    {
        var groupbox=
        
        <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onmouseout="this.firstChild.nextSibling.hidden=true" class="parent_">
        
        <vbox onmouseover="this.nextSibling.hidden=false">
            <menuitem label="hjgjghjghj" class="menuitem-iconic bookmark-item"/>
        </vbox>
        <hbox hidden="true" onblur="this.hidden=true" onmouseup="this.hidden=true" onmouseover="this.hidden=false">
            <button label="Preview" orient="horizontal" onmouseover="this.parentNode.hidden=false" image="11"/>
            <button label="del" onmouseover="this.parentNode.hidden=false" image="11"/>
            <button label="+" onmouseover="this.parentNode.hidden=false" image="11"/>
        </hbox>
    </vbox>
    
    groupbox = cbu. makeXML (groupbox);
    
    return groupbox
    }


this. xul_ex= function ()
    {
        var groupbox=
        
        <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onmouseout="this.firstChild.nextSibling.hidden=true" class="parent_">
        
        <vbox onmouseover="this.nextSibling.hidden=false">
            <menuitem label="hjgjghjghj" class="menuitem-iconic bookmark-item"/>
        </vbox>
        <hbox hidden="true"   onmouseover="this.hidden=false">
            <button label="on/of" orient="horizontal" onmouseover="this.parentNode.hidden=false" image="11"/>
            <button label="del" onmouseover="this.parentNode.hidden=false" image="11"/>
            <button label="open" onmouseover="this.parentNode.hidden=false" image="11"/>
            <button label="update" image="11"/>
        </hbox>
    </vbox>
    
    groupbox = cbu. makeXML (groupbox);
    
    return groupbox
    }
    
var menupopup= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menupopup");

if(s.getChildList('').indexOf('LightweightThemeManager.Favorites_')==-1)
    {
        
        s.setCharPref('LightweightThemeManager.Favorites_','')
    }
var fav=s.getCharPref('LightweightThemeManager.Favorites_');
var arr = LightweightThemeManager.usedThemes;
    if(!(LightweightThemeManager.currentTheme))
        {
            var currentTheme=0
        }
    else
        {
            var currentTheme=LightweightThemeManager.currentTheme.id
            
        }
    var groupbox= 
    <groupbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
        <caption label="Favorites" image="11"/>
    </groupbox>
    groupbox =  cbu. makeXML(groupbox);
    groupbox. setAttribute ("id",'groupbox_p');
    var box_= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "vbox");    
    box_. setAttribute ("id",'box_p');
    for (var i = 0; i < arr.length; i++)
    {
        if(!(fav==''))
            {
                var fl=0
                var data=fav.split(',')
                for (var j = 0; j < data.length; j++)
                {
                        if(data[j]==arr[i].id)
                        {    
                            if(currentTheme==arr[i].id)
                                {
                                    var xul=this. xulFavSel()
                                    var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                    menuItem. setAttribute ("src",arr[i]. iconURL);
                                    menuItem. setAttribute ("label",arr[i]. name);
                                    menuItem. setAttribute ("id",arr[i]. id);
                                    var b_= xul. getElementsByTagName ("button") [0];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)');
                                    groupbox.appendChild (xul);
                                    fl=1
                                }
                            else
                                {
                                    var xul=this. xulFav()
                                    var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                    menuItem. setAttribute ("src",arr[i]. iconURL);
                                    menuItem. setAttribute ("label",arr[i]. name);
                                    menuItem. setAttribute ("id",arr[i]. id);
                                    menuItem.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa._Changed(event)');
                                    var b_= xul. getElementsByTagName ("button") [0];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.Preview(event)');
                                    var b_= xul. getElementsByTagName ("button") [1];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)');
                                    var b_= xul. getElementsByTagName ("button") [2];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.favDel(event)');
                                    groupbox.appendChild (xul);
                                    fl=1
                                }
                        }
                }
                if(fl==0)
                    {
                        switch (arr[i].id)
                        {    
                            case currentTheme:
                                var xul=this. xulFavSel()
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("src",arr[i]. iconURL);
                                menuItem. setAttribute ("label",arr[i]. name);
                                menuItem. setAttribute ("id",arr[i]. id);
                                var b_= xul. getElementsByTagName ("button") [0];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)');
                                groupbox.appendChild (xul);
                            break;
                            default:
                                var xul=this. xul_()
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("src",arr[i]. iconURL);
                                menuItem. setAttribute ("label",arr[i]. name);
                                menuItem. setAttribute ("id",arr[i]. id);
                                menuItem.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa._Changed(event)');
                                var b_= xul. getElementsByTagName ("button") [2];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.favADD(event)');
                                var b_= xul. getElementsByTagName ("button") [1];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)')
                                var b_= xul. getElementsByTagName ("button") [0];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.Preview(event)');
                                box_.appendChild (xul);
                            break;
                        }
                    }
            }
        else
            {
                switch (arr[i].id)
                        {    
                            case currentTheme:
                                var xul=this. xulFavSel()
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("src",arr[i]. iconURL);
                                menuItem. setAttribute ("label",arr[i]. name);
                                menuItem. setAttribute ("id",arr[i]. id);
                                var b_= xul. getElementsByTagName ("button") [0];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)');
                                groupbox.appendChild (xul);
                            break;
                            default:
                                var xul=this. xul_()
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("src",arr[i]. iconURL);
                                menuItem. setAttribute ("label",arr[i]. name);
                                menuItem. setAttribute ("id",arr[i]. id);
                                var b_= xul. getElementsByTagName ("button") [2];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.favADD(event)');
                                var b_= xul. getElementsByTagName ("button") [1];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)');
                                var b_= xul. getElementsByTagName ("button") [0];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.Preview(event)');
                                box_.appendChild (xul);
                            break;
                        }
            }    
    }
var box_0=    this. x()
var boxx=    box_0.getElementsByClassName ("pesonas_")[0]
boxx.orient = "vertical";
    if(groupbox.childNodes.length==0)
        {
            boxx.appendChild (box_);
        }
    else
        {
            boxx.appendChild (groupbox);
            boxx.appendChild(document.createElement("menuseparator"));
            boxx.appendChild (box_);
        }
        
        
this. favDel= function (event)
    {
        
        
        var id= event. originalTarget.parentNode.previousSibling.firstChild.id;
        
        var node_vbox= event. originalTarget.parentNode.parentNode.parentNode.parentNode 
        var fav=s.getCharPref('LightweightThemeManager.Favorites_');
        var f=fav.indexOf(id)
        var n=fav.slice(0,f)
        var k=fav.slice(id.length+f)
        var n=n.slice(0,-1)
        if(n==0)
            {
                var k=k.slice(1)
            }
            
        var res=n+k
        s.setCharPref('LightweightThemeManager.Favorites_',res)
        el=event. originalTarget.parentNode.parentNode
        var Theme=LightweightThemeManager.getUsedTheme(id)
        var xul=this. xul_()
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("src",Theme. iconURL);
                                menuItem. setAttribute ("label",Theme. name);
                                menuItem. setAttribute ("id",Theme. id);
                                var b_= xul. getElementsByTagName ("button") [2];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.favADD(event)');
                                var b_= xul. getElementsByTagName ("button") [1];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)')
                                var b_= xul. getElementsByTagName ("button") [0];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.Preview(event)');
                                el. parentNode. removeChild (el);
        node_vbox.appendChild (xul);
    }
    
this. favADD= function (event)
    {
        
        var node_grup= event. originalTarget.parentNode.parentNode.parentNode.parentNode.firstChild
        var id= event. originalTarget.parentNode.previousSibling.firstChild.id;
        var fav=s.getCharPref('LightweightThemeManager.Favorites_');
        var res=fav+','+id
        s.setCharPref('LightweightThemeManager.Favorites_',res)
        el=event. originalTarget.parentNode.parentNode
        var Theme=LightweightThemeManager.getUsedTheme(id)
        var xul=this. xulFav()
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("src",Theme. iconURL);
                                menuItem. setAttribute ("label",Theme. name);
                                menuItem. setAttribute ("id",Theme. id);
                                var b_= xul. getElementsByTagName ("button") [0];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.Preview(event)');
                                    var b_= xul. getElementsByTagName ("button") [1];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)');
                                    var b_= xul. getElementsByTagName ("button") [2];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.favDel(event)');
        el. parentNode. removeChild (el);
        node_grup.appendChild (xul);
    }
this. unst= function (event)
    {
        var id= event. originalTarget.parentNode.previousSibling.firstChild.id;
        el=event. originalTarget.parentNode.parentNode
        if(!(el. hasAttribute ("class")))
            el=event. originalTarget.parentNode.parentNode.parentNode
        var Theme=LightweightThemeManager.getUsedTheme(id)
        
        Components.utils.import("resource://gre/modules/AddonManager.jsm");
        AddonManager.getAddonsByTypes(["theme"], function(addons) {
        for(var i = 0, l = addons.length; i < l; i++)
        {
            if(addons[i].id == id+'@personas.mozilla.org') 
                {
                    el. parentNode. removeChild (el);
                    addons[i].uninstall();
                }
        }
        });
    }            
this. Preview= function (event)
    {
        var id= event. originalTarget.parentNode.previousSibling.firstChild.id;
        var Theme=LightweightThemeManager.getUsedTheme(id)
        LightweightThemeManager.previewTheme(Theme)
    }
this. _Changed= function (event)
    {
        var int_=Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
        var id= event. originalTarget.id;
        var Theme=LightweightThemeManager.getUsedTheme(id)
        LightweightThemeManager.themeChanged(Theme)
        
        Components.utils.import("resource://gre/modules/AddonManager.jsm");
        AddonManager.getAddonsByTypes(["theme"], function(addons) {
        for(var i = 0, l = addons.length; i < l; i++)
        {
            if(addons[i].isActive  == true) 
                {
                    if(!(addons[i].id.slice(addons[i].id.length-21)=='@personas.mozilla.org'))
                        {
                            var res=addons[i]
                            var res0=addons[i].id
                            var THIS=this
                            AddonManager.addAddonListener({ onDisabled: function(res) 
                                {
                                    AddonManager.getAddonByID(res0,function(a) 
                                        {
                                            a.userDisabled=false
                                            Services.obs.notifyObservers(null, "lightweight-theme-styling-update",JSON.stringify(Theme));
                                            AddonManager.removeAddonListener({ onDisabled: function(a){}})
                                        })
                                }})
                            
                            res.userDisabled=false
                        }
                
                }
                
                
        }
        
        });
    
    }    
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var iconURL='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACV0lEQVR4Xi3OT2ibZQDH8c/7msT1pZqOtlQ32ulaGJVuB0UvMiyRCbZCT14MHUIzcaCCFcZAGOiKIB3UkyCeBBU86EGYiPZanTIZwnTWScdqbdM/U/vHN1mS5jGHHD637w9+TOM1vKrTtPe8419z7njflrmWt2yb9ocpE0p4CaW2KTjVdtKgkqsnloZCMYyHQjgeHguD4YndoeBDwagZpzCKsfbmNIzjZZxF0aiS+Qd/TUJvRRjYzQcf2DPhotP6TOBJTOE5FIlVPG/NZEvRpq6Wpcp/dR1RXlcmz5pUasWOUalJDQ+3AOC83aGb/SF7TfCdMHCzJ5zYHwjKghXhwC1NXwvmBbOCgheVMI4iGSOas0MXXfWTdWU/WnBjc5kKUqpZkUGibkIFC1IdetSdwZXInB3HJS7bUNR3aCQbr67VaeAuKthGNxbxhVcccNiw8275LbZgw+dm/OUFn/h5falODjVUUUeEHfQKjrhg0OueEunUH3nGfY7akwjWvWnSjEdxG3U0UEOKCAnu4l58605Gzq4EOWRsqLWDFI22/bY6AlJ0ATHOCR6XlcgogCruRx6dgDo6BGvYQQY1cazfu3p9atUlxxT0YxnXcQ2/o4I8yvjSx+ZdsYI9ucjbNj2rx3UMY9O+ryy67bKGX3R42hEnjXnIIr4xJvE3LuH7WCqSw1HUsOAfq96QdU63j+SdUTbrBhLUHJTzg7Ki4ELsHhlNVJHBiIMOOatTnwSRYYeVHEMT2n3WMqoZizZ8pmm/BWKxLQXbHlCxjkfUDGs98yeqUluoAf8DkrzrAnZsWyMAAAAASUVORK5CYII='        
Components.utils.import("resource://gre/modules/AddonManager.jsm");
var box_enable= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "groupbox");
var box_disable= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "groupbox");
var box_false= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "groupbox");
var THIS=this
AddonManager. getAddonsByTypes
(
        ["extension"],
        function (extensions)
        {
            var arr_enable = new Array();
            var arr_disable = new Array();
            var arr_false = new Array();
            var e=extensions
            for (var i = 0; i < extensions. length; i++)
                {
                    
                    if(e[i].userDisabled==true)
                        {
                            arr_disable.push(e[i])
                        }
                    else
                        {
                            arr_enable.push(e[i])
                        }
                    if(e[i].appDisabled==true)
                        {
                            arr_false.push(e[i])
                        }    
                }
            if(!(arr_disable.length==0))
                {
                    arr_disable. sort
                    (
                    function (a, b, c, d)
                        {
                            return a.name  > b.name;
                        }
                    );
                }    
            if(!(arr_enable.length==0))
                {
                    arr_enable. sort
                    (
                    function (a, b, c, d)
                        {
                            return a.name  > b.name;
                        }
                    );
                }    
            if(!(box_false.length==0))
                {
                    arr_enable. sort
                    (
                    function (a, b, c, d)
                        {
                            return a.name  > b.name;
                        }
                    );
                }        
            var sub_box=    box_0.getElementsByClassName ("add_on")[0]
            
            var Node=sub_box.firstChild.firstChild .firstChild ;
            var boxx=    box_0.getElementsByClassName ("Enable_")[1]    
            var boxx2=    box_0.getElementsByClassName ("Disable_")[1]    
            var boxx3=    box_0.getElementsByClassName ("False_")[1]    
            Node.setAttribute("value",Node.getAttribute("value")+'/'+arr_enable. length)
            Node.setAttribute("style",'color:#FF6600;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#6633FF;')
            Node.nextSibling .setAttribute("value",Node.nextSibling .getAttribute("value")+'/'+arr_disable. length)
            Node.nextSibling .setAttribute("style",'font-family:monospace;border-bottom-color:#000000;border-bottom-style:solid;border-bottom-width:1px;')
            Node.nextSibling .nextSibling.setAttribute("value",Node.nextSibling .nextSibling.getAttribute("value")+'/'+arr_false. length)
            Node.nextSibling .nextSibling.setAttribute("style",'font-family:monospace;border-bottom-color:#000000;border-bottom-style:solid;border-bottom-width:1px;')
            for (var i = 0; i < arr_enable. length; i++)
            {
                var xul=THIS. xul_ex()
                var b_=xul.lastChild
                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                menuItem. setAttribute ("src",arr_enable[i]. iconURL);
                menuItem. setAttribute ("label",arr_enable[i]. name);
                menuItem. setAttribute ("id_",arr_enable[i]. id);
                b_.firstChild.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="Disabled_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.open_(event)');
                b_.firstChild.nextSibling.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.but_u(event)');
                if (arr_enable[i]. iconURL)
                    {                        
                       menuItem. setAttribute ("src",arr_enable[i]. iconURL);
                    }
                else
                    {
                        menuItem. setAttribute ("src",iconURL);
                    }
                if (arr_enable[i]. optionsURL)
                    menuItem.setAttribute('oncommand', "window. openDialog ('" + arr_enable[i]. optionsURL + "', '', 'chrome,dialog=0,resizable,titlebar,toolbar,centerscreen');");
                 boxx. appendChild (xul)
            }
            for (var i = 0; i < arr_disable. length; i++)
            {
                var xul=THIS.xul_ex()
                var b_=xul.lastChild
                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                menuItem. setAttribute ("label",arr_disable[i]. name);
                menuItem. setAttribute ("id_",arr_disable[i]. id);
                b_.firstChild.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="Disabled_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.open_(event)');
                b_.firstChild.nextSibling.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.but_u(event)');
                if (arr_disable[i]. iconURL)
                    {                        
                       menuItem. setAttribute ("src",arr_disable[i]. iconURL);
                    }
                else
                    {
                        menuItem. setAttribute ("src",iconURL);
                    }
                if (arr_disable[i]. optionsURL)
                    menuItem.setAttribute('oncommand', "window. openDialog ('" + arr_disable[i]. optionsURL + "', '', 'chrome,dialog=0,resizable,titlebar,toolbar,centerscreen');");
                 boxx2. appendChild (xul)
            }
            for (var i = 0; i < arr_false. length; i++)
            {
                var xul=THIS. xul_ex()
                var b_=xul.lastChild
                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                menuItem. setAttribute ("label",arr_false[0]. name);
                menuItem. setAttribute ("id_",arr_false[0]. id);
                b_.firstChild.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="Disabled_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.open_(event)');
                b_.firstChild.nextSibling.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.but_u(event)');
                if (arr_false[i]. iconURL)
                    {                        
                       menuItem. setAttribute ("src",arr_false[i]. iconURL);
                    }
                else
                    {
                        menuItem. setAttribute ("src",iconURL);
                    }
                boxx3. appendChild (xul)
            }
        }
    )    
 
this. but_=function (event,class_) 
{
    var id= event. originalTarget.parentNode.previousSibling.firstChild. getAttribute ("id_")
    Components.utils.import("resource://gre/modules/AddonManager.jsm");
    AddonManager.getAllAddons
    (
        function(addons) 
            {                    
                for (var i = 0; i < addons. length; i++)
                {
                    if(addons[i].id==id)
                        {
                            if(class_=='Disabled_')
                                {
                                    
                                    addons[i].userDisabled = !addons[i].userDisabled;
                                }
                            if(class_=='_')
                                {
                                    addons[i].uninstall();
                                }
                            if(class_=='st_')
                                {
                                    window. openDialog ('chrome://stylish/content/edit.xul', addons[i].name, 'chrome,dialog=0,resizable,titlebar,toolbar,centerscreen;',addons[i])
                                }    
                        }
                    }            
                }
            );    
}

this.open_=function(event){
var id= event. originalTarget.parentNode.previousSibling.firstChild. getAttribute ("id_")
var file = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).
    get("ProfD", Components.interfaces.nsIFile);
file.append("extensions");
file.append(id);
var tr=file.exists()
if(tr==true)
    {
        let nsLocalFile = Components.Constructor("@mozilla.org/file/local;1",
                                           "nsILocalFile", "initWithPath");                                           
        new nsLocalFile(file.path).reveal();
    }
else
    {
        var id=id+'.xpi'
        var file = Components.classes["@mozilla.org/file/directory_service;1"].
            getService(Components.interfaces.nsIProperties).
            get("ProfD", Components.interfaces.nsIFile);
        file.append("extensions");
        file.append(id);
        var local = Components.classes["@mozilla.org/file/local;1"].
            createInstance(Components.interfaces.nsILocalFile);
        var process = Components.classes["@mozilla.org/process/util;1"].
            createInstance(Components.interfaces.nsIProcess);
        var args = [file.path]
        local.initWithPath("e:\\pro\\WinRAR\\WinRAR.exe");
        process.init(local);
        process.run(false, args, args.length);
    }}

 

var boxx=    box_0.getElementsByClassName ("theme_")[0]
AddonManager. getAddonsByTypes
(
        ["theme"],
        function (addons)
        {
            var box_on= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "vbox");
            var box_of= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "vbox");
            var box_sel= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "vbox");
            for (var i = 0; i < addons. length; i++)
                {
                    if(!(addons[i].id.slice(addons[i].id.length-21)=='@personas.mozilla.org'))
                        {
                            if(addons[i].isActive)
                                {
                                    var xul=THIS. xulFavSel()
                                    var b_=xul.lastChild.previousSibling
                                    var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                    menuItem. setAttribute ("label",addons[i]. name);
                                    menuItem. setAttribute ("id_",addons[i]. id);
                                    b_.firstChild.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="_";tqa.but_(event,class_)');
                                    
                                    if (addons[i]. iconURL)
                                        {                        
                                            menuItem. setAttribute ("src",addons[i]. iconURL);
                                        }
                                    else
                                        {
                                            menuItem. setAttribute ("src",iconURL);
                                        }
                                    
                                    box_sel. appendChild (xul)                                     
                                }
                            else
                            {
                                var xul=THIS. xul_ex()
                                var b_=xul.lastChild
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("label",addons[i]. name);
                                menuItem. setAttribute ("id_",addons[i]. id);
                                b_.firstChild.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="Disabled_";tqa.but_(event,class_)');
                                b_.firstChild.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="_";tqa.but_(event,class_)');
                                b_.firstChild.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.open_(event)');                
                                b_.firstChild.nextSibling.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.but_u(event)');
                                if (addons[i]. iconURL)
                                {                        
                                    menuItem. setAttribute ("src",addons[i]. iconURL);
                                }
                                else
                                {
                                    menuItem. setAttribute ("src",iconURL);
                                }
                                
                                if (addons[i].appDisabled==true)
                                {                        
                                    menuItem.setAttribute("disabled","true")
                                    box_of. appendChild (xul)    
                                }
                                if (addons[i].appDisabled==false)
                                {
                                    box_on. appendChild (xul)    
                                }    
                            }
                                    
                        }
                
                }
            boxx.orient = "vertical";
            boxx. appendChild (box_sel)
            boxx. appendChild (box_on)
            if(box_of.childNodes.length>0)
            {
                boxx. appendChild (document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuseparator"));
                boxx. appendChild (box_of)    
            }
            
        }
)    



            

var st_e=    box_0.getElementsByClassName ("st_e")[0]
var st_d=    box_0.getElementsByClassName ("st_d")[0]    
AddonManager. getAddonsByTypes
(
        ["userstyle"],
        function (addons)
        {
            for (var i = 0; i < addons. length; i++)
            {
                var xul=THIS.  xul_ex()
                var b_=xul.lastChild
                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                menuItem. setAttribute ("src",addons[i]. iconURL);
                menuItem. setAttribute ("label",addons[i]. name);
                menuItem. setAttribute ("id_",addons[i]. id);
                b_.firstChild.nextSibling.nextSibling.setAttribute("label","edit")
                b_.firstChild.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="Disabled_";tqa.but_(event,class_);tqa.st_(event);');
                b_.firstChild.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="_";tqa.but_(event,class_);tqa.st_(event);');
                b_.firstChild.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="st_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.but_u(event)');
                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                if (addons[i]. iconURL)
                {                        
                    menuItem. setAttribute ("src",addons[i]. iconURL);
                }
                else
                {
                    menuItem. setAttribute ("src",iconURL);
                }
                if (addons[i] .userDisabled)
                {                        
                    menuItem.setAttribute("disabled","true")
                    st_d. appendChild (xul)
                }
                else
                {
                    menuItem.setAttribute("disabled","false")
                    st_e. appendChild (xul)
                }
                                     
            }
                                
        }
)
this. st_=function (event) 
{
    
    var m= event. originalTarget.parentNode.previousSibling.firstChild
    var obj= event. originalTarget.parentNode.parentNode
    var b= event. originalTarget.parentNode.parentNode.parentNode
    
    if(m.getAttribute("disabled")=='true')
    {
        
        b.previousSibling .previousSibling .  appendChild (obj)
        m.setAttribute("disabled","false")
        
    }
    else
    {
        m.setAttribute("disabled","true")
        b.nextSibling .nextSibling. appendChild (obj)
    }
}    

this. but_u=function (event) 
    {
        var id= event. originalTarget.parentNode.previousSibling.firstChild. getAttribute ("id_")
        var info = Components.classes["@mozilla.org/xre/app-info;1"] 
            .getService(Components.interfaces.nsIXULAppInfo);   
        Components.utils.import("resource://gre/modules/AddonManager.jsm");
        AddonManager.getAddonByID(id, function(aAddon) {
            aAddon.findUpdates(UpdateListener, 1, window.navigator.appVersion, info.platformVersion);
        });  
 
 
        var UpdateListener = 
        {
            onUpdateAvailable: function(addon,install) 
            {
                install.addListener
                (
                    { 
                        onInstallEnded: function () 
                        {                    
                            install.removeListener({onInstallEnded: function (){}})
                            event. originalTarget.parentNode.previousSibling.firstChild.setAttribute("style","color:#006600;")
                            event. originalTarget.setAttribute("oncommand",'this.install.cancel();this.install=null;this.parentNode.previousSibling.firstChild.setAttribute("style","color:#000000;")')
                            event. originalTarget.setAttribute("label","cancel")
                        }
                    }
                    
                );
                install.addListener
                (
                    { 
                        onDownloadFailed: function ()
                        {
                            install.removeListener({onDownloadFailed: function (){}})
                            event. originalTarget.parentNode.previousSibling.firstChild.setAttribute("style","color:#FF0000;")
                            event. originalTarget.setAttribute("label","error")
                        }
                    }
                )
                install.addListener
                (
                    { 
                        onInstallFailed: function ()
                        {
                            install.removeListener({onInstallFailed: function (){}})
                            event. originalTarget.parentNode.previousSibling.firstChild.setAttribute("style","color:#FF0000;")
                            event. originalTarget.setAttribute("label","error")
                        }    
                    }
                )    
                event. originalTarget.parentNode.previousSibling.firstChild.setAttribute("style","text-decoration:underline;")
                event. originalTarget.setAttribute("label","install/true")
                event. originalTarget.install=install
                event. originalTarget.setAttribute('onclick','this.install.install()');
            },
            onNoUpdateAvailable: function(addon) 
            {
                 if(event. originalTarget.getAttribute("label")=='install/true'||event. originalTarget.getAttribute("label")=='cancel')
                    return
                 event. originalTarget.setAttribute("label","install/false")
                 event. originalTarget.parentNode.previousSibling.firstChild.setAttribute("style","color:#6666CC;")
                 return;
            },
            onCompatibilityUpdateAvailable: function(addon) 
            {                  
                return;
            },
            onNoCompatibilityUpdateAvailable: function(addon) 
            {
                return;
            },
            onUpdateFinished: function(addon,err) 
            {
   
                return;
            }
        }
    }
                        
this. type = "menu-button";
this.orient = "horizontal";
this. appendChild (menupopup);
menupopup.appendChild (box_0);


если произошла ошибка краснеет

Отсутствует

 

№358204-02-2012 12:25:27

mserv
Участник
 
Группа: Members
Зарегистрирован: 15-11-2008
Сообщений: 1025
UA: Nightly 13.0

Re: Custom Buttons

Ste_pan пишет

ну вообщем щас кнопка должна работать у всех, добавил кнопку "упдате" при нажатии проверяется наличие обнавления ,если нет оного имя аддона синеет
, если есть подчеркивается с низу и кнопка "упдате" становится кнопкой install/true щелчек по ней установить обновление,если установилось нармально имя аддона зеленет и кнопка "упдате" становится кнопкой "cancel",

Спасибо, всё работает.  Кнопка действительно стала прикольная. Пожелания, если возможно. Сделайте,  чтобы при нажатие на кнопку обновлялись все дополнения, темы…, а  иконка кнопки, которую надо прикрутить, при наличие обновлений меняла бы свой цвет. И ещё добавьте в кнопку вкладки со списком Плагинов и установленных скриптов для Greasemonkey . Плиз. :beer:

Добавлено 04-02-2012 12:45:54
Ste_pan
Ещё заметил маленький недостаток, сортировка дополнений производится с учётом регистра.  Поэтому у меня два дополнения оказались не отсортированными. Поправьте плиз.

Отредактировано mserv (04-02-2012 12:45:54)

Отсутствует

 

№358304-02-2012 13:44:54

vv07
Участник
 
Группа: Members
Зарегистрирован: 07-11-2007
Сообщений: 689
UA: Firefox 10.0

Re: Custom Buttons

Ste_pan
FF 10 не работает. Уточняю, тормозно работает. Не сразу открывается выпадающее меню.
При кликах на кнопку, рядом создаются какие белые полосы.5O7PkkFk.png

Отредактировано vv07 (04-02-2012 13:50:17)

Отсутствует

 

№358404-02-2012 13:57:10

Ste_pan
Участник
 
Группа: Members
Откуда: приморский край п.сибирцево
Зарегистрирован: 13-02-2011
Сообщений: 63
UA: Firefox 7.0

Re: Custom Buttons

кнопка в выподающем меню выводит списки аддонов,тем,персон,и стилей
при клике по menuitem в аддонах -опции аддона,в персонах -выбрать данную персону(если тема не стандартная все равно выбирается (не надо менять не чего в about:config и перезагружатся))
что-бы работпла кнопка open в коде надо поменять путь
к program files на свой
local.initWithPath("e:\\pro\\WinRAR\\WinRAR.exe");

скрытый текст

Выделить код

Код:

var s=Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
var pref=Application.prefs.get("lightweightThemes.isThemeSelected")
if(!(pref))
    s.setCharPref('lightweightThemes.isThemeSelected','true')
else
    pref.events.addListener("change", function() {s.setBoolPref('lightweightThemes.isThemeSelected', true)});
var val = this. getAttribute ("id"); 
var s=Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm"); 
this. x= function ()
    {
        var groupbox=
        <tabbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
        <tabs>
            <tab label="add-ons" image="11"/>
            <tab label="themes" image="11"/>
            <tab label="styles" image="11"/>
            <tab label="personas" image="11"/>
        </tabs>
        <tabpanels>
            <tabpanel class="add_on">
                <vbox class="add_on" hidden="false">
                    <hbox hidden="false">
                        <label value="Enable" onclick="var  style_=&quot;color:#000000;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#000000;&quot;&#xA;var style_sel ='color:#FF6600;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#6633FF'&#xA;var Node=this.parentNode.childNodes;&#xA;for (var i = 0; i &lt;3; i++)&#xA;&#x9;&#x9;{&#xA;&#x9;&#x9;&#x9;&#xA;Node[i]. setAttribute (&quot;style&quot;, style_)&#xA;&#x9;&#x9;};&#xA;this.setAttribute (&quot;style&quot;,style_sel)&#xA;var Node=this.parentNode.nextSibling .childNodes;&#xA;for (var i = 0; i &lt;3; i++)&#xA;&#x9;&#x9;{&#xA;&#x9;&#x9;&#xA;if(Node[i].className ==this.className){&#xA;&#x9;&#x9;&#x9;&#x9;Node[i].hidden=false}&#xA;&#x9;&#x9;&#x9;else{&#xA;&#x9;&#x9;&#x9;&#x9;Node[i].hidden=true}&#xA;&#x9;&#x9;};&#xA;&#x9;&#x9;&#xA;" class="Enable_"/>
                        <label value="Disable" onclick="var  style_=&quot;color:#000000;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#000000;&quot;&#xA;var style_sel ='color:#FF6600;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#6633FF'&#xA;var Node=this.parentNode.childNodes;&#xA;for (var i = 0; i &lt;3; i++)&#xA;&#x9;&#x9;{&#xA;&#x9;&#x9;&#x9;&#xA;Node[i]. setAttribute (&quot;style&quot;, style_)&#xA;&#x9;&#x9;};&#xA;this.setAttribute (&quot;style&quot;,style_sel)&#xA;var Node=this.parentNode.nextSibling .childNodes;&#xA;for (var i = 0; i &lt;3; i++)&#xA;&#x9;&#x9;{&#xA;&#x9;&#x9;&#xA;if(Node[i].className ==this.className){&#xA;&#x9;&#x9;&#x9;&#x9;Node[i].hidden=false}&#xA;&#x9;&#x9;&#x9;else{&#xA;&#x9;&#x9;&#x9;&#x9;Node[i].hidden=true}&#xA;&#x9;&#x9;};&#xA;&#x9;&#x9;&#xA;" class="Disable_"/>
                        <label value="False" onclick="var  style_=&quot;color:#000000;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#000000;&quot;&#xA;var style_sel ='color:#FF6600;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#6633FF'&#xA;var Node=this.parentNode.childNodes;&#xA;for (var i = 0; i &lt;3; i++)&#xA;&#x9;&#x9;{&#xA;&#x9;&#x9;&#x9;&#xA;Node[i]. setAttribute (&quot;style&quot;, style_)&#xA;&#x9;&#x9;};&#xA;this.setAttribute (&quot;style&quot;,style_sel)&#xA;var Node=this.parentNode.nextSibling .childNodes;&#xA;for (var i = 0; i &lt;3; i++)&#xA;&#x9;&#x9;{&#xA;&#x9;&#x9;&#xA;if(Node[i].className ==this.className){&#xA;&#x9;&#x9;&#x9;&#x9;Node[i].hidden=false}&#xA;&#x9;&#x9;&#x9;else{&#xA;&#x9;&#x9;&#x9;&#x9;Node[i].hidden=true}&#xA;&#x9;&#x9;};&#xA;&#x9;&#x9;&#xA;" class="False_"/>
                    </hbox>
                    <box>
                        <vbox class="Enable_" hidden="false"/>
                        <vbox class="Disable_" hidden="true"/>
                        <vbox hidden="true" class="False_"/>
                    </box>
                </vbox>
            </tabpanel>
            <tabpanel class="theme_"/>
            <tabpanel class="styles_">
                <vbox>
                    <vbox class="st_e"/>
                    <menuseparator/>
                    <vbox class="st_d"/>
                </vbox>
            </tabpanel>
            <tabpanel class="pesonas_"/>
        </tabpanels>
    </tabbox>
    groupbox =  cbu. makeXML(groupbox);
    
    return groupbox
    }
this. xulFav = function ()
    {
        var groupbox=
        
        <vbox onmouseout="this.firstChild.nextSibling.hidden=true" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
            <vbox onmouseover="this.nextSibling.hidden=false">
                <menuitem label="hjgjghjghj" class="menuitem-iconic bookmark-item"/>
            </vbox>
            <hbox hidden="true" onblur="this.hidden=true" onmouseup="this.hidden=true" onmouseover="this.hidden=false">
                <button label="Preview" orient="horizontal" onmouseover="this.parentNode.hidden=false" image="11"/>
                <button label="del" onmouseover="this.parentNode.hidden=false" image="11"/>
                <button label="-" onmouseover="this.parentNode.hidden=false" image="11"/>
            </hbox>
        </vbox>
    
    
    groupbox =  cbu. makeXML(groupbox);
    
    return groupbox
    }
this. xulFavSel = function ()
    {
        var groupbox=
        
        <vbox onmouseout="this.firstChild.nextSibling.hidden=true" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
            <vbox onmouseover="this.nextSibling.hidden=false">
                <menuitem label="hjgjghjghj" class="menuitem-iconic bookmark-item"/>
            </vbox>
            <hbox hidden="true" onblur="this.hidden=true" onmouseup="this.hidden=true" onmouseover="this.hidden=false">
                <button label="del" onmouseover="this.parentNode.hidden=false" image="11"/>
            </hbox>
            <menuseparator/>
        </vbox>
        

    groupbox =  cbu. makeXML(groupbox);
    
    return groupbox
    }

this. xul_ = function ()
    {
        var groupbox=
        
        <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onmouseout="this.firstChild.nextSibling.hidden=true" class="parent_">
        
        <vbox onmouseover="this.nextSibling.hidden=false">
            <menuitem label="hjgjghjghj" class="menuitem-iconic bookmark-item"/>
        </vbox>
        <hbox hidden="true" onblur="this.hidden=true" onmouseup="this.hidden=true" onmouseover="this.hidden=false">
            <button label="Preview" orient="horizontal" onmouseover="this.parentNode.hidden=false" image="11"/>
            <button label="del" onmouseover="this.parentNode.hidden=false" image="11"/>
            <button label="+" onmouseover="this.parentNode.hidden=false" image="11"/>
        </hbox>
    </vbox>
    
    groupbox = cbu. makeXML (groupbox);
    
    return groupbox
    }


this. xul_ex= function ()
    {
        var groupbox=
        
        <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onmouseout="this.firstChild.nextSibling.hidden=true" class="parent_">
        
        <vbox onmouseover="this.nextSibling.hidden=false">
            <menuitem label="hjgjghjghj" class="menuitem-iconic bookmark-item"/>
        </vbox>
        <hbox hidden="true"   onmouseover="this.hidden=false">
            <button label="on/of" orient="horizontal" onmouseover="this.parentNode.hidden=false" image="11"/>
            <button label="del" onmouseover="this.parentNode.hidden=false" image="11"/>
            <button label="open" onmouseover="this.parentNode.hidden=false" image="11"/>
            <button label="update" image="11"/>
        </hbox>
    </vbox>
    
    groupbox = cbu. makeXML (groupbox);
    
    return groupbox
    }
    
var menupopup= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menupopup");

if(s.getChildList('').indexOf('LightweightThemeManager.Favorites_')==-1)
    {
        
        s.setCharPref('LightweightThemeManager.Favorites_','')
    }
var fav=s.getCharPref('LightweightThemeManager.Favorites_');
var arr = LightweightThemeManager.usedThemes;
    if(!(LightweightThemeManager.currentTheme))
        {
            var currentTheme=0
        }
    else
        {
            var currentTheme=LightweightThemeManager.currentTheme.id
            
        }
    var groupbox= 
    <groupbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
        <caption label="Favorites" image="11"/>
    </groupbox>
    groupbox =  cbu. makeXML(groupbox);
    groupbox. setAttribute ("id",'groupbox_p');
    var box_= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "vbox");    
    box_. setAttribute ("id",'box_p');
    for (var i = 0; i < arr.length; i++)
    {
        if(!(fav==''))
            {
                var fl=0
                var data=fav.split(',')
                for (var j = 0; j < data.length; j++)
                {
                        if(data[j]==arr[i].id)
                        {    
                            if(currentTheme==arr[i].id)
                                {
                                    var xul=this. xulFavSel()
                                    var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                    menuItem. setAttribute ("src",arr[i]. iconURL);
                                    menuItem. setAttribute ("label",arr[i]. name);
                                    menuItem. setAttribute ("id",arr[i]. id);
                                    var b_= xul. getElementsByTagName ("button") [0];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)');
                                    groupbox.appendChild (xul);
                                    fl=1
                                }
                            else
                                {
                                    var xul=this. xulFav()
                                    var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                    menuItem. setAttribute ("src",arr[i]. iconURL);
                                    menuItem. setAttribute ("label",arr[i]. name);
                                    menuItem. setAttribute ("id",arr[i]. id);
                                    menuItem.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa._Changed(event)');
                                    var b_= xul. getElementsByTagName ("button") [0];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.Preview(event)');
                                    var b_= xul. getElementsByTagName ("button") [1];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)');
                                    var b_= xul. getElementsByTagName ("button") [2];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.favDel(event)');
                                    groupbox.appendChild (xul);
                                    fl=1
                                }
                        }
                }
                if(fl==0)
                    {
                        switch (arr[i].id)
                        {    
                            case currentTheme:
                                var xul=this. xulFavSel()
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("src",arr[i]. iconURL);
                                menuItem. setAttribute ("label",arr[i]. name);
                                menuItem. setAttribute ("id",arr[i]. id);
                                var b_= xul. getElementsByTagName ("button") [0];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)');
                                groupbox.appendChild (xul);
                            break;
                            default:
                                var xul=this. xul_()
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("src",arr[i]. iconURL);
                                menuItem. setAttribute ("label",arr[i]. name);
                                menuItem. setAttribute ("id",arr[i]. id);
                                menuItem.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa._Changed(event)');
                                var b_= xul. getElementsByTagName ("button") [2];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.favADD(event)');
                                var b_= xul. getElementsByTagName ("button") [1];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)')
                                var b_= xul. getElementsByTagName ("button") [0];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.Preview(event)');
                                box_.appendChild (xul);
                            break;
                        }
                    }
            }
        else
            {
                switch (arr[i].id)
                        {    
                            case currentTheme:
                                var xul=this. xulFavSel()
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("src",arr[i]. iconURL);
                                menuItem. setAttribute ("label",arr[i]. name);
                                menuItem. setAttribute ("id",arr[i]. id);
                                var b_= xul. getElementsByTagName ("button") [0];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)');
                                groupbox.appendChild (xul);
                            break;
                            default:
                                var xul=this. xul_()
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("src",arr[i]. iconURL);
                                menuItem. setAttribute ("label",arr[i]. name);
                                menuItem. setAttribute ("id",arr[i]. id);
                                var b_= xul. getElementsByTagName ("button") [2];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.favADD(event)');
                                var b_= xul. getElementsByTagName ("button") [1];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)');
                                var b_= xul. getElementsByTagName ("button") [0];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.Preview(event)');
                                box_.appendChild (xul);
                            break;
                        }
            }    
    }
var box_0=    this. x()
var boxx=    box_0.getElementsByClassName ("pesonas_")[0]
boxx.orient = "vertical";
    if(groupbox.childNodes.length==0)
        {
            boxx.appendChild (box_);
        }
    else
        {
            boxx.appendChild (groupbox);
            boxx.appendChild(document.createElement("menuseparator"));
            boxx.appendChild (box_);
        }
        
        
this. favDel= function (event)
    {
        
        
        var id= event. originalTarget.parentNode.previousSibling.firstChild.id;
        
        var node_vbox= event. originalTarget.parentNode.parentNode.parentNode.parentNode 
        var fav=s.getCharPref('LightweightThemeManager.Favorites_');
        var f=fav.indexOf(id)
        var n=fav.slice(0,f)
        var k=fav.slice(id.length+f)
        var n=n.slice(0,-1)
        if(n==0)
            {
                var k=k.slice(1)
            }
            
        var res=n+k
        s.setCharPref('LightweightThemeManager.Favorites_',res)
        el=event. originalTarget.parentNode.parentNode
        var Theme=LightweightThemeManager.getUsedTheme(id)
        var xul=this. xul_()
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("src",Theme. iconURL);
                                menuItem. setAttribute ("label",Theme. name);
                                menuItem. setAttribute ("id",Theme. id);
                                var b_= xul. getElementsByTagName ("button") [2];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.favADD(event)');
                                var b_= xul. getElementsByTagName ("button") [1];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)')
                                var b_= xul. getElementsByTagName ("button") [0];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.Preview(event)');
                                el. parentNode. removeChild (el);
        node_vbox.appendChild (xul);
    }
    
this. favADD= function (event)
    {
        
        var node_grup= event. originalTarget.parentNode.parentNode.parentNode.parentNode.firstChild
        var id= event. originalTarget.parentNode.previousSibling.firstChild.id;
        var fav=s.getCharPref('LightweightThemeManager.Favorites_');
        var res=fav+','+id
        s.setCharPref('LightweightThemeManager.Favorites_',res)
        el=event. originalTarget.parentNode.parentNode
        var Theme=LightweightThemeManager.getUsedTheme(id)
        var xul=this. xulFav()
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("src",Theme. iconURL);
                                menuItem. setAttribute ("label",Theme. name);
                                menuItem. setAttribute ("id",Theme. id);
                                var b_= xul. getElementsByTagName ("button") [0];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.Preview(event)');
                                    var b_= xul. getElementsByTagName ("button") [1];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)');
                                    var b_= xul. getElementsByTagName ("button") [2];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.favDel(event)');
        el. parentNode. removeChild (el);
        node_grup.appendChild (xul);
    }
this. unst= function (event)
    {
        var id= event. originalTarget.parentNode.previousSibling.firstChild.id;
        el=event. originalTarget.parentNode.parentNode
        if(!(el. hasAttribute ("class")))
            el=event. originalTarget.parentNode.parentNode.parentNode
        var Theme=LightweightThemeManager.getUsedTheme(id)
        
        Components.utils.import("resource://gre/modules/AddonManager.jsm");
        AddonManager.getAddonsByTypes(["theme"], function(addons) {
        for(var i = 0, l = addons.length; i < l; i++)
        {
            if(addons[i].id == id+'@personas.mozilla.org') 
                {
                    el. parentNode. removeChild (el);
                    addons[i].uninstall();
                }
        }
        });
    }            
this. Preview= function (event)
    {
        var id= event. originalTarget.parentNode.previousSibling.firstChild.id;
        var Theme=LightweightThemeManager.getUsedTheme(id)
        LightweightThemeManager.previewTheme(Theme)
    }
this. _Changed= function (event)
    {
        var int_=Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
        var id= event. originalTarget.id;
        var Theme=LightweightThemeManager.getUsedTheme(id)
        LightweightThemeManager.themeChanged(Theme)
        
        Components.utils.import("resource://gre/modules/AddonManager.jsm");
        AddonManager.getAddonsByTypes(["theme"], function(addons) {
        for(var i = 0, l = addons.length; i < l; i++)
        {
            if(addons[i].isActive  == true) 
                {
                    if(!(addons[i].id.slice(addons[i].id.length-21)=='@personas.mozilla.org'))
                        {
                            var res=addons[i]
                            var res0=addons[i].id
                            var THIS=this
                            AddonManager.addAddonListener({ onDisabled: function(res) 
                                {
                                    AddonManager.getAddonByID(res0,function(a) 
                                        {
                                            a.userDisabled=false
                                            Services.obs.notifyObservers(null, "lightweight-theme-styling-update",JSON.stringify(Theme));
                                            AddonManager.removeAddonListener({ onDisabled: function(a){}})
                                        })
                                }})
                            
                            res.userDisabled=false
                        }
                
                }
                
                
        }
        
        });
    
    }    
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var iconURL='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACV0lEQVR4Xi3OT2ibZQDH8c/7msT1pZqOtlQ32ulaGJVuB0UvMiyRCbZCT14MHUIzcaCCFcZAGOiKIB3UkyCeBBU86EGYiPZanTIZwnTWScdqbdM/U/vHN1mS5jGHHD637w9+TOM1vKrTtPe8419z7njflrmWt2yb9ocpE0p4CaW2KTjVdtKgkqsnloZCMYyHQjgeHguD4YndoeBDwagZpzCKsfbmNIzjZZxF0aiS+Qd/TUJvRRjYzQcf2DPhotP6TOBJTOE5FIlVPG/NZEvRpq6Wpcp/dR1RXlcmz5pUasWOUalJDQ+3AOC83aGb/SF7TfCdMHCzJ5zYHwjKghXhwC1NXwvmBbOCgheVMI4iGSOas0MXXfWTdWU/WnBjc5kKUqpZkUGibkIFC1IdetSdwZXInB3HJS7bUNR3aCQbr67VaeAuKthGNxbxhVcccNiw8275LbZgw+dm/OUFn/h5falODjVUUUeEHfQKjrhg0OueEunUH3nGfY7akwjWvWnSjEdxG3U0UEOKCAnu4l58605Gzq4EOWRsqLWDFI22/bY6AlJ0ATHOCR6XlcgogCruRx6dgDo6BGvYQQY1cazfu3p9atUlxxT0YxnXcQ2/o4I8yvjSx+ZdsYI9ucjbNj2rx3UMY9O+ryy67bKGX3R42hEnjXnIIr4xJvE3LuH7WCqSw1HUsOAfq96QdU63j+SdUTbrBhLUHJTzg7Ki4ELsHhlNVJHBiIMOOatTnwSRYYeVHEMT2n3WMqoZizZ8pmm/BWKxLQXbHlCxjkfUDGs98yeqUluoAf8DkrzrAnZsWyMAAAAASUVORK5CYII='        
Components.utils.import("resource://gre/modules/AddonManager.jsm");
var box_enable= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "groupbox");
var box_disable= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "groupbox");
var box_false= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "groupbox");
var THIS=this
AddonManager. getAddonsByTypes
(
        ["extension"],
        function (extensions)
        {
            var arr_enable = new Array();
            var arr_disable = new Array();
            var arr_false = new Array();
            var e=extensions
            for (var i = 0; i < extensions. length; i++)
                {
                    
                    if(e[i].userDisabled==true)
                        {
                            arr_disable.push(e[i])
                        }
                    else
                        {
                            arr_enable.push(e[i])
                        }
                    if(e[i].appDisabled==true)
                        {
                            arr_false.push(e[i])
                        }    
                }
            if(!(arr_disable.length==0))
                {
                    arr_disable. sort
                    (
                    function (a, b, c, d)
                        {
                            return a.name  > b.name;
                        }
                    );
                }    
            if(!(arr_enable.length==0))
                {
                    arr_enable. sort
                    (
                    function (a, b, c, d)
                        {
                            return a.name. toLowerCase ()  > b.name. toLowerCase ();
                        }
                    );
                }    
            if(!(box_false.length==0))
                {
                    arr_enable. sort
                    (
                    function (a, b, c, d)
                        {
                            return a.name  > b.name;
                        }
                    );
                }        
            var sub_box=    box_0.getElementsByClassName ("add_on")[0]
            
            var Node=sub_box.firstChild.firstChild .firstChild ;
            var boxx=    box_0.getElementsByClassName ("Enable_")[1]    
            var boxx2=    box_0.getElementsByClassName ("Disable_")[1]    
            var boxx3=    box_0.getElementsByClassName ("False_")[1]    
            Node.setAttribute("value",Node.getAttribute("value")+'/'+arr_enable. length)
            Node.setAttribute("style",'color:#FF6600;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#6633FF;')
            Node.nextSibling .setAttribute("value",Node.nextSibling .getAttribute("value")+'/'+arr_disable. length)
            Node.nextSibling .setAttribute("style",'font-family:monospace;border-bottom-color:#000000;border-bottom-style:solid;border-bottom-width:1px;')
            Node.nextSibling .nextSibling.setAttribute("value",Node.nextSibling .nextSibling.getAttribute("value")+'/'+arr_false. length)
            Node.nextSibling .nextSibling.setAttribute("style",'font-family:monospace;border-bottom-color:#000000;border-bottom-style:solid;border-bottom-width:1px;')
            for (var i = 0; i < arr_enable. length; i++)
            {
                var xul=THIS. xul_ex()
                var b_=xul.lastChild
                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                menuItem. setAttribute ("src",arr_enable[i]. iconURL);
                menuItem. setAttribute ("label",arr_enable[i]. name);
                menuItem. setAttribute ("id_",arr_enable[i]. id);
                b_.firstChild.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="Disabled_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.open_(event)');
                b_.firstChild.nextSibling.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.but_u(event)');
                if (arr_enable[i]. iconURL)
                    {                        
                       menuItem. setAttribute ("src",arr_enable[i]. iconURL);
                    }
                else
                    {
                        menuItem. setAttribute ("src",iconURL);
                    }
                if (arr_enable[i]. optionsURL)
                    menuItem.setAttribute('oncommand', "window. openDialog ('" + arr_enable[i]. optionsURL + "', '', 'chrome,dialog=0,resizable,titlebar,toolbar,centerscreen');");
                 boxx. appendChild (xul)
            }
            for (var i = 0; i < arr_disable. length; i++)
            {
                var xul=THIS.xul_ex()
                var b_=xul.lastChild
                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                menuItem. setAttribute ("label",arr_disable[i]. name);
                menuItem. setAttribute ("id_",arr_disable[i]. id);
                b_.firstChild.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="Disabled_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.open_(event)');
                b_.firstChild.nextSibling.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.but_u(event)');
                if (arr_disable[i]. iconURL)
                    {                        
                       menuItem. setAttribute ("src",arr_disable[i]. iconURL);
                    }
                else
                    {
                        menuItem. setAttribute ("src",iconURL);
                    }
                if (arr_disable[i]. optionsURL)
                    menuItem.setAttribute('oncommand', "window. openDialog ('" + arr_disable[i]. optionsURL + "', '', 'chrome,dialog=0,resizable,titlebar,toolbar,centerscreen');");
                 boxx2. appendChild (xul)
            }
            for (var i = 0; i < arr_false. length; i++)
            {
                var xul=THIS. xul_ex()
                var b_=xul.lastChild
                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                menuItem. setAttribute ("label",arr_false[0]. name);
                menuItem. setAttribute ("id_",arr_false[0]. id);
                b_.firstChild.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="Disabled_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.open_(event)');
                b_.firstChild.nextSibling.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.but_u(event)');
                if (arr_false[i]. iconURL)
                    {                        
                       menuItem. setAttribute ("src",arr_false[i]. iconURL);
                    }
                else
                    {
                        menuItem. setAttribute ("src",iconURL);
                    }
                boxx3. appendChild (xul)
            }
        }
    )    
 
this. but_=function (event,class_) 
{
    var id= event. originalTarget.parentNode.previousSibling.firstChild. getAttribute ("id_")
    Components.utils.import("resource://gre/modules/AddonManager.jsm");
    AddonManager.getAllAddons
    (
        function(addons) 
            {                    
                for (var i = 0; i < addons. length; i++)
                {
                    if(addons[i].id==id)
                        {
                            if(class_=='Disabled_')
                                {
                                    
                                    addons[i].userDisabled = !addons[i].userDisabled;
                                }
                            if(class_=='_')
                                {
                                    addons[i].uninstall();
                                }
                            if(class_=='st_')
                                {
                                    window. openDialog ('chrome://stylish/content/edit.xul', addons[i].name, 'chrome,dialog=0,resizable,titlebar,toolbar,centerscreen;',addons[i])
                                }    
                        }
                    }            
                }
            );    
}

this.open_=function(event){
var id= event. originalTarget.parentNode.previousSibling.firstChild. getAttribute ("id_")
var file = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).
    get("ProfD", Components.interfaces.nsIFile);
file.append("extensions");
file.append(id);
var tr=file.exists()
if(tr==true)
    {
        let nsLocalFile = Components.Constructor("@mozilla.org/file/local;1",
                                           "nsILocalFile", "initWithPath");                                           
        new nsLocalFile(file.path).reveal();
    }
else
    {
        var id=id+'.xpi'
        var file = Components.classes["@mozilla.org/file/directory_service;1"].
            getService(Components.interfaces.nsIProperties).
            get("ProfD", Components.interfaces.nsIFile);
        file.append("extensions");
        file.append(id);
        var local = Components.classes["@mozilla.org/file/local;1"].
            createInstance(Components.interfaces.nsILocalFile);
        var process = Components.classes["@mozilla.org/process/util;1"].
            createInstance(Components.interfaces.nsIProcess);
        var args = [file.path]
        local.initWithPath("e:\\pro\\WinRAR\\WinRAR.exe");
        process.init(local);
        process.run(false, args, args.length);
    }}

 

var boxx=    box_0.getElementsByClassName ("theme_")[0]
AddonManager. getAddonsByTypes
(
        ["theme"],
        function (addons)
        {
            var box_on= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "vbox");
            var box_of= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "vbox");
            var box_sel= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "vbox");
            for (var i = 0; i < addons. length; i++)
                {
                    if(!(addons[i].id.slice(addons[i].id.length-21)=='@personas.mozilla.org'))
                        {
                            if(addons[i].isActive)
                                {
                                    var xul=THIS. xulFavSel()
                                    var b_=xul.lastChild.previousSibling
                                    var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                    menuItem. setAttribute ("label",addons[i]. name);
                                    menuItem. setAttribute ("id_",addons[i]. id);
                                    b_.firstChild.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="_";tqa.but_(event,class_)');
                                    
                                    if (addons[i]. iconURL)
                                        {                        
                                            menuItem. setAttribute ("src",addons[i]. iconURL);
                                        }
                                    else
                                        {
                                            menuItem. setAttribute ("src",iconURL);
                                        }
                                    
                                    box_sel. appendChild (xul)                                     
                                }
                            else
                            {
                                var xul=THIS. xul_ex()
                                var b_=xul.lastChild
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("label",addons[i]. name);
                                menuItem. setAttribute ("id_",addons[i]. id);
                                b_.firstChild.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="Disabled_";tqa.but_(event,class_)');
                                b_.firstChild.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="_";tqa.but_(event,class_)');
                                b_.firstChild.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.open_(event)');                
                                b_.firstChild.nextSibling.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.but_u(event)');
                                if (addons[i]. iconURL)
                                {                        
                                    menuItem. setAttribute ("src",addons[i]. iconURL);
                                }
                                else
                                {
                                    menuItem. setAttribute ("src",iconURL);
                                }
                                
                                if (addons[i].appDisabled==true)
                                {                        
                                    menuItem.setAttribute("disabled","true")
                                    box_of. appendChild (xul)    
                                }
                                if (addons[i].appDisabled==false)
                                {
                                    box_on. appendChild (xul)    
                                }    
                            }
                                    
                        }
                
                }
            boxx.orient = "vertical";
            boxx. appendChild (box_sel)
            boxx. appendChild (box_on)
            if(box_of.childNodes.length>0)
            {
                boxx. appendChild (document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuseparator"));
                boxx. appendChild (box_of)    
            }
            
        }
)    



            

var st_e=    box_0.getElementsByClassName ("st_e")[0]
var st_d=    box_0.getElementsByClassName ("st_d")[0]    
AddonManager. getAddonsByTypes
(
        ["userstyle"],
        function (addons)
        {
            for (var i = 0; i < addons. length; i++)
            {
                var xul=THIS.  xul_ex()
                var b_=xul.lastChild
                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                menuItem. setAttribute ("src",addons[i]. iconURL);
                menuItem. setAttribute ("label",addons[i]. name);
                menuItem. setAttribute ("id_",addons[i]. id);
                b_.firstChild.nextSibling.nextSibling.setAttribute("label","edit")
                b_.firstChild.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="Disabled_";tqa.but_(event,class_);tqa.st_(event);');
                b_.firstChild.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="_";tqa.but_(event,class_);event. originalTarget.parentNode.parentNode.parentNode.removeChild(event. originalTarget.parentNode.parentNode);');
                b_.firstChild.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="st_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.but_u(event)');
                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                if (addons[i]. iconURL)
                {                        
                    menuItem. setAttribute ("src",addons[i]. iconURL);
                }
                else
                {
                    menuItem. setAttribute ("src",iconURL);
                }
                if (addons[i] .userDisabled)
                {                        
                    menuItem.setAttribute("disabled","true")
                    st_d. appendChild (xul)
                }
                else
                {
                    menuItem.setAttribute("disabled","false")
                    st_e. appendChild (xul)
                }
                                     
            }
                                
        }
)
this. st_=function (event) 
{
    
    var m= event. originalTarget.parentNode.previousSibling.firstChild
    var obj= event. originalTarget.parentNode.parentNode
    var b= event. originalTarget.parentNode.parentNode.parentNode
    
    if(m.getAttribute("disabled")=='true')
    {
        
        b.previousSibling .previousSibling .  appendChild (obj)
        m.setAttribute("disabled","false")
        
    }
    else
    {
        m.setAttribute("disabled","true")
        b.nextSibling .nextSibling. appendChild (obj)
    }
}    

this. but_u=function (event) 
    {
        var id= event. originalTarget.parentNode.previousSibling.firstChild. getAttribute ("id_")
        var info = Components.classes["@mozilla.org/xre/app-info;1"] 
            .getService(Components.interfaces.nsIXULAppInfo);   
        Components.utils.import("resource://gre/modules/AddonManager.jsm");
        AddonManager.getAddonByID(id, function(aAddon) {
            aAddon.findUpdates(UpdateListener, 1, window.navigator.appVersion, info.platformVersion);
        });  
 
 
        var UpdateListener = 
        {
            onUpdateAvailable: function(addon,install) 
            {
                install.addListener
                (
                    { 
                        onInstallEnded: function () 
                        {                    
                            install.removeListener({onInstallEnded: function (){}})
                            event. originalTarget.parentNode.previousSibling.firstChild.setAttribute("style","color:#006600;")
                            event. originalTarget.setAttribute("oncommand",'this.install.cancel();this.install=null;this.parentNode.previousSibling.firstChild.setAttribute("style","color:#000000;")')
                            event. originalTarget.setAttribute("label","cancel")
                        }
                    }
                    
                );
                install.addListener
                (
                    { 
                        onDownloadFailed: function ()
                        {
                            install.removeListener({onDownloadFailed: function (){}})
                            event. originalTarget.parentNode.previousSibling.firstChild.setAttribute("style","color:#FF0000;")
                            event. originalTarget.setAttribute("label","error")
                        }
                    }
                )
                install.addListener
                (
                    { 
                        onInstallFailed: function ()
                        {
                            install.removeListener({onInstallFailed: function (){}})
                            event. originalTarget.parentNode.previousSibling.firstChild.setAttribute("style","color:#FF0000;")
                            event. originalTarget.setAttribute("label","error")
                        }    
                    }
                )    
                event. originalTarget.parentNode.previousSibling.firstChild.setAttribute("style","text-decoration:underline;")
                event. originalTarget.setAttribute("label","install/true")
                event. originalTarget.install=install
                event. originalTarget.setAttribute('onclick','this.install.install()');
            },
            onNoUpdateAvailable: function(addon) 
            {
                 if(event. originalTarget.getAttribute("label")=='install/true'||event. originalTarget.getAttribute("label")=='cancel')
                    return
                 event. originalTarget.setAttribute("label","install/false")
                 event. originalTarget.parentNode.previousSibling.firstChild.setAttribute("style","color:#6666CC;")
                 return;
            },
            onCompatibilityUpdateAvailable: function(addon) 
            {                  
                return;
            },
            onNoCompatibilityUpdateAvailable: function(addon) 
            {
                return;
            },
            onUpdateFinished: function(addon,err) 
            {
   
                return;
            }
        }
    }
                        
this. type = "menu-button";
this.orient = "horizontal";
this. appendChild (menupopup);
menupopup.appendChild (box_0);


сортировку поправил ,добовлять плагины и т.п пока нет желания,может потом...

Добавлено 04-02-2012 13:59:12

vv07 пишет

При кликах на кнопку, рядом создаются какие белые полосы.

код вставлять в инализацию

Отредактировано Ste_pan (04-02-2012 14:06:49)

Отсутствует

 

№358504-02-2012 14:04:12

vv07
Участник
 
Группа: Members
Зарегистрирован: 07-11-2007
Сообщений: 689
UA: Firefox 10.0

Re: Custom Buttons

Ste_pan
Исправил, но бога ради,сделайте подтверждение на кнопке удаления. Совершенно случайно нажал вместо редактирования и снес стиль, а какой убей не запомнил.:(

Отсутствует

 

№358604-02-2012 14:13:54

mserv
Участник
 
Группа: Members
Зарегистрирован: 15-11-2008
Сообщений: 1025
UA: Nightly 13.0

Re: Custom Buttons

Ste_pan пишет

сортировку поправил

Ничего не изменилось, всё равно сортирует с учётом регистра.

Добавлено 04-02-2012 14:20:48
Кстати, а стили вообще не сортируются.

Отредактировано mserv (04-02-2012 14:20:48)

Отсутствует

 

№358704-02-2012 14:47:29

vitalii201
Участник
 
Группа: Members
Зарегистрирован: 24-03-2011
Сообщений: 679
UA: Firefox 10.0

Re: Custom Buttons

Ste_pan
у меня названия аддонов почему-то видны только при наведении курсора

скрытый текст
image004vz.png

Отсутствует

 

№358804-02-2012 15:05:12

Ste_pan
Участник
 
Группа: Members
Откуда: приморский край п.сибирцево
Зарегистрирован: 13-02-2011
Сообщений: 63
UA: Firefox 7.0

Re: Custom Buttons

mserv пишет

Ничего не изменилось, всё равно сортирует с учётом регистра.

щас все сортирует

скрытый текст

Выделить код

Код:

var s=Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
var pref=Application.prefs.get("lightweightThemes.isThemeSelected")
if(!(pref))
    s.setCharPref('lightweightThemes.isThemeSelected','true')
else
    pref.events.addListener("change", function() {s.setBoolPref('lightweightThemes.isThemeSelected', true)});
var val = this. getAttribute ("id"); 
var s=Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm"); 
this. x= function ()
    {
        var groupbox=
        <tabbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
        <tabs>
            <tab label="add-ons" image="11"/>
            <tab label="themes" image="11"/>
            <tab label="styles" image="11"/>
            <tab label="personas" image="11"/>
        </tabs>
        <tabpanels>
            <tabpanel class="add_on">
                <vbox class="add_on" hidden="false">
                    <hbox hidden="false">
                        <label value="Enable" onclick="var  style_=&quot;color:#000000;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#000000;&quot;&#xA;var style_sel ='color:#FF6600;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#6633FF'&#xA;var Node=this.parentNode.childNodes;&#xA;for (var i = 0; i &lt;3; i++)&#xA;&#x9;&#x9;{&#xA;&#x9;&#x9;&#x9;&#xA;Node[i]. setAttribute (&quot;style&quot;, style_)&#xA;&#x9;&#x9;};&#xA;this.setAttribute (&quot;style&quot;,style_sel)&#xA;var Node=this.parentNode.nextSibling .childNodes;&#xA;for (var i = 0; i &lt;3; i++)&#xA;&#x9;&#x9;{&#xA;&#x9;&#x9;&#xA;if(Node[i].className ==this.className){&#xA;&#x9;&#x9;&#x9;&#x9;Node[i].hidden=false}&#xA;&#x9;&#x9;&#x9;else{&#xA;&#x9;&#x9;&#x9;&#x9;Node[i].hidden=true}&#xA;&#x9;&#x9;};&#xA;&#x9;&#x9;&#xA;" class="Enable_"/>
                        <label value="Disable" onclick="var  style_=&quot;color:#000000;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#000000;&quot;&#xA;var style_sel ='color:#FF6600;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#6633FF'&#xA;var Node=this.parentNode.childNodes;&#xA;for (var i = 0; i &lt;3; i++)&#xA;&#x9;&#x9;{&#xA;&#x9;&#x9;&#x9;&#xA;Node[i]. setAttribute (&quot;style&quot;, style_)&#xA;&#x9;&#x9;};&#xA;this.setAttribute (&quot;style&quot;,style_sel)&#xA;var Node=this.parentNode.nextSibling .childNodes;&#xA;for (var i = 0; i &lt;3; i++)&#xA;&#x9;&#x9;{&#xA;&#x9;&#x9;&#xA;if(Node[i].className ==this.className){&#xA;&#x9;&#x9;&#x9;&#x9;Node[i].hidden=false}&#xA;&#x9;&#x9;&#x9;else{&#xA;&#x9;&#x9;&#x9;&#x9;Node[i].hidden=true}&#xA;&#x9;&#x9;};&#xA;&#x9;&#x9;&#xA;" class="Disable_"/>
                        <label value="False" onclick="var  style_=&quot;color:#000000;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#000000;&quot;&#xA;var style_sel ='color:#FF6600;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#6633FF'&#xA;var Node=this.parentNode.childNodes;&#xA;for (var i = 0; i &lt;3; i++)&#xA;&#x9;&#x9;{&#xA;&#x9;&#x9;&#x9;&#xA;Node[i]. setAttribute (&quot;style&quot;, style_)&#xA;&#x9;&#x9;};&#xA;this.setAttribute (&quot;style&quot;,style_sel)&#xA;var Node=this.parentNode.nextSibling .childNodes;&#xA;for (var i = 0; i &lt;3; i++)&#xA;&#x9;&#x9;{&#xA;&#x9;&#x9;&#xA;if(Node[i].className ==this.className){&#xA;&#x9;&#x9;&#x9;&#x9;Node[i].hidden=false}&#xA;&#x9;&#x9;&#x9;else{&#xA;&#x9;&#x9;&#x9;&#x9;Node[i].hidden=true}&#xA;&#x9;&#x9;};&#xA;&#x9;&#x9;&#xA;" class="False_"/>
                    </hbox>
                    <box>
                        <vbox class="Enable_" hidden="false"/>
                        <vbox class="Disable_" hidden="true"/>
                        <vbox hidden="true" class="False_"/>
                    </box>
                </vbox>
            </tabpanel>
            <tabpanel class="theme_"/>
            <tabpanel class="styles_">
                <vbox>
                    <vbox class="st_e"/>
                    <menuseparator/>
                    <vbox class="st_d"/>
                </vbox>
            </tabpanel>
            <tabpanel class="pesonas_"/>
        </tabpanels>
    </tabbox>
    groupbox =  cbu. makeXML(groupbox);
    
    return groupbox
    }
this. xulFav = function ()
    {
        var groupbox=
        
        <vbox onmouseout="this.firstChild.nextSibling.hidden=true" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
            <vbox onmouseover="this.nextSibling.hidden=false">
                <menuitem label="hjgjghjghj" class="menuitem-iconic bookmark-item"/>
            </vbox>
            <hbox hidden="true" onblur="this.hidden=true" onmouseup="this.hidden=true" onmouseover="this.hidden=false">
                <button label="Preview" orient="horizontal" onmouseover="this.parentNode.hidden=false" image="11"/>
                <button label="del" onmouseover="this.parentNode.hidden=false" image="11"/>
                <button label="-" onmouseover="this.parentNode.hidden=false" image="11"/>
            </hbox>
        </vbox>
    
    
    groupbox =  cbu. makeXML(groupbox);
    
    return groupbox
    }
this. xulFavSel = function ()
    {
        var groupbox=
        
        <vbox onmouseout="this.firstChild.nextSibling.hidden=true" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
            <vbox onmouseover="this.nextSibling.hidden=false">
                <menuitem label="hjgjghjghj" class="menuitem-iconic bookmark-item"/>
            </vbox>
            <hbox hidden="true" onblur="this.hidden=true" onmouseup="this.hidden=true" onmouseover="this.hidden=false">
                <button label="del" onmouseover="this.parentNode.hidden=false" image="11"/>
            </hbox>
            <menuseparator/>
        </vbox>
        

    groupbox =  cbu. makeXML(groupbox);
    
    return groupbox
    }

this. xul_ = function ()
    {
        var groupbox=
        
        <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onmouseout="this.firstChild.nextSibling.hidden=true" class="parent_">
        
        <vbox onmouseover="this.nextSibling.hidden=false">
            <menuitem label="hjgjghjghj" class="menuitem-iconic bookmark-item"/>
        </vbox>
        <hbox hidden="true" onblur="this.hidden=true" onmouseup="this.hidden=true" onmouseover="this.hidden=false">
            <button label="Preview" orient="horizontal" onmouseover="this.parentNode.hidden=false" image="11"/>
            <button label="del" onmouseover="this.parentNode.hidden=false" image="11"/>
            <button label="+" onmouseover="this.parentNode.hidden=false" image="11"/>
        </hbox>
    </vbox>
    
    groupbox = cbu. makeXML (groupbox);
    
    return groupbox
    }


this. xul_ex= function ()
    {
        var groupbox=
        
        <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onmouseout="this.firstChild.nextSibling.hidden=true" class="parent_">
        
        <vbox onmouseover="this.nextSibling.hidden=false">
            <menuitem label="hjgjghjghj" class="menuitem-iconic bookmark-item"/>
        </vbox>
        <hbox hidden="true"   onmouseover="this.hidden=false">
            <button label="on/of" orient="horizontal" onmouseover="this.parentNode.hidden=false" image="11"/>
            <button label="del" onmouseover="this.parentNode.hidden=false" image="11"/>
            <button label="open" onmouseover="this.parentNode.hidden=false" image="11"/>
            <button label="update" image="11"/>
        </hbox>
    </vbox>
    
    groupbox = cbu. makeXML (groupbox);
    
    return groupbox
    }
    
var menupopup= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menupopup");

if(s.getChildList('').indexOf('LightweightThemeManager.Favorites_')==-1)
    {
        
        s.setCharPref('LightweightThemeManager.Favorites_','')
    }
var fav=s.getCharPref('LightweightThemeManager.Favorites_');
var arr = LightweightThemeManager.usedThemes;
    if(!(LightweightThemeManager.currentTheme))
        {
            var currentTheme=0
        }
    else
        {
            var currentTheme=LightweightThemeManager.currentTheme.id
            
        }
    var groupbox= 
    <groupbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
        <caption label="Favorites" image="11"/>
    </groupbox>
    groupbox =  cbu. makeXML(groupbox);
    groupbox. setAttribute ("id",'groupbox_p');
    var box_= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "vbox");    
    box_. setAttribute ("id",'box_p');
    for (var i = 0; i < arr.length; i++)
    {
        arr. sort
                    (
                    function (a, b, c, d)
                        {
                            return a.name. toLowerCase ()  > b.name. toLowerCase ();
                        }
                    );
        if(!(fav==''))
            {
                var fl=0
                var data=fav.split(',')
                for (var j = 0; j < data.length; j++)
                {
                        if(data[j]==arr[i].id)
                        {    
                            if(currentTheme==arr[i].id)
                                {
                                    var xul=this. xulFavSel()
                                    var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                    menuItem. setAttribute ("src",arr[i]. iconURL);
                                    menuItem. setAttribute ("label",arr[i]. name);
                                    menuItem. setAttribute ("id",arr[i]. id);
                                    var b_= xul. getElementsByTagName ("button") [0];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)');
                                    groupbox.appendChild (xul);
                                    fl=1
                                }
                            else
                                {
                                    var xul=this. xulFav()
                                    var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                    menuItem. setAttribute ("src",arr[i]. iconURL);
                                    menuItem. setAttribute ("label",arr[i]. name);
                                    menuItem. setAttribute ("id",arr[i]. id);
                                    menuItem.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa._Changed(event)');
                                    var b_= xul. getElementsByTagName ("button") [0];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.Preview(event)');
                                    var b_= xul. getElementsByTagName ("button") [1];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)');
                                    var b_= xul. getElementsByTagName ("button") [2];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.favDel(event)');
                                    groupbox.appendChild (xul);
                                    fl=1
                                }
                        }
                }
                if(fl==0)
                    {
                        switch (arr[i].id)
                        {    
                            case currentTheme:
                                var xul=this. xulFavSel()
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("src",arr[i]. iconURL);
                                menuItem. setAttribute ("label",arr[i]. name);
                                menuItem. setAttribute ("id",arr[i]. id);
                                var b_= xul. getElementsByTagName ("button") [0];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)');
                                groupbox.appendChild (xul);
                            break;
                            default:
                                var xul=this. xul_()
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("src",arr[i]. iconURL);
                                menuItem. setAttribute ("label",arr[i]. name);
                                menuItem. setAttribute ("id",arr[i]. id);
                                menuItem.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa._Changed(event)');
                                var b_= xul. getElementsByTagName ("button") [2];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.favADD(event)');
                                var b_= xul. getElementsByTagName ("button") [1];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)')
                                var b_= xul. getElementsByTagName ("button") [0];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.Preview(event)');
                                box_.appendChild (xul);
                            break;
                        }
                    }
            }
        else
            {
                switch (arr[i].id)
                        {    
                            case currentTheme:
                                var xul=this. xulFavSel()
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("src",arr[i]. iconURL);
                                menuItem. setAttribute ("label",arr[i]. name);
                                menuItem. setAttribute ("id",arr[i]. id);
                                var b_= xul. getElementsByTagName ("button") [0];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)');
                                groupbox.appendChild (xul);
                            break;
                            default:
                                var xul=this. xul_()
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("src",arr[i]. iconURL);
                                menuItem. setAttribute ("label",arr[i]. name);
                                menuItem. setAttribute ("id",arr[i]. id);
                                var b_= xul. getElementsByTagName ("button") [2];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.favADD(event)');
                                var b_= xul. getElementsByTagName ("button") [1];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)');
                                var b_= xul. getElementsByTagName ("button") [0];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.Preview(event)');
                                box_.appendChild (xul);
                            break;
                        }
            }    
    }
var box_0=    this. x()
var boxx=    box_0.getElementsByClassName ("pesonas_")[0]
boxx.orient = "vertical";
    if(groupbox.childNodes.length==0)
        {
            boxx.appendChild (box_);
        }
    else
        {
            boxx.appendChild (groupbox);
            boxx.appendChild(document.createElement("menuseparator"));
            boxx.appendChild (box_);
        }
        
        
this. favDel= function (event)
    {
        
        
        var id= event. originalTarget.parentNode.previousSibling.firstChild.id;
        
        var node_vbox= event. originalTarget.parentNode.parentNode.parentNode.parentNode 
        var fav=s.getCharPref('LightweightThemeManager.Favorites_');
        var f=fav.indexOf(id)
        var n=fav.slice(0,f)
        var k=fav.slice(id.length+f)
        var n=n.slice(0,-1)
        if(n==0)
            {
                var k=k.slice(1)
            }
            
        var res=n+k
        s.setCharPref('LightweightThemeManager.Favorites_',res)
        el=event. originalTarget.parentNode.parentNode
        var Theme=LightweightThemeManager.getUsedTheme(id)
        var xul=this. xul_()
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("src",Theme. iconURL);
                                menuItem. setAttribute ("label",Theme. name);
                                menuItem. setAttribute ("id",Theme. id);
                                var b_= xul. getElementsByTagName ("button") [2];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.favADD(event)');
                                var b_= xul. getElementsByTagName ("button") [1];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)')
                                var b_= xul. getElementsByTagName ("button") [0];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.Preview(event)');
                                el. parentNode. removeChild (el);
        node_vbox.appendChild (xul);
    }
    
this. favADD= function (event)
    {
        
        var node_grup= event. originalTarget.parentNode.parentNode.parentNode.parentNode.firstChild
        var id= event. originalTarget.parentNode.previousSibling.firstChild.id;
        var fav=s.getCharPref('LightweightThemeManager.Favorites_');
        var res=fav+','+id
        s.setCharPref('LightweightThemeManager.Favorites_',res)
        el=event. originalTarget.parentNode.parentNode
        var Theme=LightweightThemeManager.getUsedTheme(id)
        var xul=this. xulFav()
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("src",Theme. iconURL);
                                menuItem. setAttribute ("label",Theme. name);
                                menuItem. setAttribute ("id",Theme. id);
                                var b_= xul. getElementsByTagName ("button") [0];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.Preview(event)');
                                    var b_= xul. getElementsByTagName ("button") [1];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)');
                                    var b_= xul. getElementsByTagName ("button") [2];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.favDel(event)');
        el. parentNode. removeChild (el);
        node_grup.appendChild (xul);
    }
this. unst= function (event)
    {
        var id= event. originalTarget.parentNode.previousSibling.firstChild.id;
        el=event. originalTarget.parentNode.parentNode
        if(!(el. hasAttribute ("class")))
            el=event. originalTarget.parentNode.parentNode.parentNode
        var Theme=LightweightThemeManager.getUsedTheme(id)
        
        Components.utils.import("resource://gre/modules/AddonManager.jsm");
        AddonManager.getAddonsByTypes(["theme"], function(addons) {
        for(var i = 0, l = addons.length; i < l; i++)
        {
            if(addons[i].id == id+'@personas.mozilla.org') 
                {
                    el. parentNode. removeChild (el);
                    addons[i].uninstall();
                }
        }
        });
    }            
this. Preview= function (event)
    {
        var id= event. originalTarget.parentNode.previousSibling.firstChild.id;
        var Theme=LightweightThemeManager.getUsedTheme(id)
        LightweightThemeManager.previewTheme(Theme)
    }
this. _Changed= function (event)
    {
        var int_=Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
        var id= event. originalTarget.id;
        var Theme=LightweightThemeManager.getUsedTheme(id)
        LightweightThemeManager.themeChanged(Theme)
        
        Components.utils.import("resource://gre/modules/AddonManager.jsm");
        AddonManager.getAddonsByTypes(["theme"], function(addons) {
        for(var i = 0, l = addons.length; i < l; i++)
        {
            if(addons[i].isActive  == true) 
                {
                    if(!(addons[i].id.slice(addons[i].id.length-21)=='@personas.mozilla.org'))
                        {
                            var res=addons[i]
                            var res0=addons[i].id
                            var THIS=this
                            AddonManager.addAddonListener({ onDisabled: function(res) 
                                {
                                    AddonManager.getAddonByID(res0,function(a) 
                                        {
                                            a.userDisabled=false
                                            Services.obs.notifyObservers(null, "lightweight-theme-styling-update",JSON.stringify(Theme));
                                            AddonManager.removeAddonListener({ onDisabled: function(a){}})
                                        })
                                }})
                            
                            res.userDisabled=false
                        }
                
                }
                
                
        }
        
        });
    
    }    
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var iconURL='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACV0lEQVR4Xi3OT2ibZQDH8c/7msT1pZqOtlQ32ulaGJVuB0UvMiyRCbZCT14MHUIzcaCCFcZAGOiKIB3UkyCeBBU86EGYiPZanTIZwnTWScdqbdM/U/vHN1mS5jGHHD637w9+TOM1vKrTtPe8419z7njflrmWt2yb9ocpE0p4CaW2KTjVdtKgkqsnloZCMYyHQjgeHguD4YndoeBDwagZpzCKsfbmNIzjZZxF0aiS+Qd/TUJvRRjYzQcf2DPhotP6TOBJTOE5FIlVPG/NZEvRpq6Wpcp/dR1RXlcmz5pUasWOUalJDQ+3AOC83aGb/SF7TfCdMHCzJ5zYHwjKghXhwC1NXwvmBbOCgheVMI4iGSOas0MXXfWTdWU/WnBjc5kKUqpZkUGibkIFC1IdetSdwZXInB3HJS7bUNR3aCQbr67VaeAuKthGNxbxhVcccNiw8275LbZgw+dm/OUFn/h5falODjVUUUeEHfQKjrhg0OueEunUH3nGfY7akwjWvWnSjEdxG3U0UEOKCAnu4l58605Gzq4EOWRsqLWDFI22/bY6AlJ0ATHOCR6XlcgogCruRx6dgDo6BGvYQQY1cazfu3p9atUlxxT0YxnXcQ2/o4I8yvjSx+ZdsYI9ucjbNj2rx3UMY9O+ryy67bKGX3R42hEnjXnIIr4xJvE3LuH7WCqSw1HUsOAfq96QdU63j+SdUTbrBhLUHJTzg7Ki4ELsHhlNVJHBiIMOOatTnwSRYYeVHEMT2n3WMqoZizZ8pmm/BWKxLQXbHlCxjkfUDGs98yeqUluoAf8DkrzrAnZsWyMAAAAASUVORK5CYII='        
Components.utils.import("resource://gre/modules/AddonManager.jsm");
var box_enable= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "groupbox");
var box_disable= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "groupbox");
var box_false= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "groupbox");
var THIS=this
AddonManager. getAddonsByTypes
(
        ["extension"],
        function (extensions)
        {
            var arr_enable = new Array();
            var arr_disable = new Array();
            var arr_false = new Array();
            var e=extensions
            for (var i = 0; i < extensions. length; i++)
                {
                    
                    if(e[i].userDisabled==true)
                        {
                            arr_disable.push(e[i])
                        }
                    else
                        {
                            arr_enable.push(e[i])
                        }
                    if(e[i].appDisabled==true)
                        {
                            arr_false.push(e[i])
                        }    
                }
            if(!(arr_disable.length==0))
                {
                    arr_disable. sort
                    (
                    function (a, b, c, d)
                        {
                            return a.name. toLowerCase ()  > b.name. toLowerCase ();
                        }
                    );
                }    
            if(!(arr_enable.length==0))
                {
                    arr_enable. sort
                    (
                    function (a, b, c, d)
                        {
                            return a.name. toLowerCase ()  > b.name. toLowerCase ();
                        }
                    );
                }    
            if(!(box_false.length==0))
                {
                    arr_enable. sort
                    (
                    function (a, b, c, d)
                        {
                            return a.name. toLowerCase ()  > b.name. toLowerCase ();
                        }
                    );
                }        
            var sub_box=    box_0.getElementsByClassName ("add_on")[0]
            
            var Node=sub_box.firstChild.firstChild .firstChild ;
            var boxx=    box_0.getElementsByClassName ("Enable_")[1]    
            var boxx2=    box_0.getElementsByClassName ("Disable_")[1]    
            var boxx3=    box_0.getElementsByClassName ("False_")[1]    
            Node.setAttribute("value",Node.getAttribute("value")+'/'+arr_enable. length)
            Node.setAttribute("style",'color:#FF6600;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#6633FF;')
            Node.nextSibling .setAttribute("value",Node.nextSibling .getAttribute("value")+'/'+arr_disable. length)
            Node.nextSibling .setAttribute("style",'font-family:monospace;border-bottom-color:#000000;border-bottom-style:solid;border-bottom-width:1px;')
            Node.nextSibling .nextSibling.setAttribute("value",Node.nextSibling .nextSibling.getAttribute("value")+'/'+arr_false. length)
            Node.nextSibling .nextSibling.setAttribute("style",'font-family:monospace;border-bottom-color:#000000;border-bottom-style:solid;border-bottom-width:1px;')
            for (var i = 0; i < arr_enable. length; i++)
            {
                var xul=THIS. xul_ex()
                var b_=xul.lastChild
                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                menuItem. setAttribute ("src",arr_enable[i]. iconURL);
                menuItem. setAttribute ("label",arr_enable[i]. name);
                menuItem. setAttribute ("id_",arr_enable[i]. id);
                b_.firstChild.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="Disabled_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.open_(event)');
                b_.firstChild.nextSibling.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.but_u(event)');
                if (arr_enable[i]. iconURL)
                    {                        
                       menuItem. setAttribute ("src",arr_enable[i]. iconURL);
                    }
                else
                    {
                        menuItem. setAttribute ("src",iconURL);
                    }
                if (arr_enable[i]. optionsURL)
                    menuItem.setAttribute('oncommand', "window. openDialog ('" + arr_enable[i]. optionsURL + "', '', 'chrome,dialog=0,resizable,titlebar,toolbar,centerscreen');");
                 boxx. appendChild (xul)
            }
            for (var i = 0; i < arr_disable. length; i++)
            {
                var xul=THIS.xul_ex()
                var b_=xul.lastChild
                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                menuItem. setAttribute ("label",arr_disable[i]. name);
                menuItem. setAttribute ("id_",arr_disable[i]. id);
                b_.firstChild.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="Disabled_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.open_(event)');
                b_.firstChild.nextSibling.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.but_u(event)');
                if (arr_disable[i]. iconURL)
                    {                        
                       menuItem. setAttribute ("src",arr_disable[i]. iconURL);
                    }
                else
                    {
                        menuItem. setAttribute ("src",iconURL);
                    }
                if (arr_disable[i]. optionsURL)
                    menuItem.setAttribute('oncommand', "window. openDialog ('" + arr_disable[i]. optionsURL + "', '', 'chrome,dialog=0,resizable,titlebar,toolbar,centerscreen');");
                 boxx2. appendChild (xul)
            }
            for (var i = 0; i < arr_false. length; i++)
            {
                var xul=THIS. xul_ex()
                var b_=xul.lastChild
                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                menuItem. setAttribute ("label",arr_false[0]. name);
                menuItem. setAttribute ("id_",arr_false[0]. id);
                b_.firstChild.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="Disabled_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.open_(event)');
                b_.firstChild.nextSibling.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.but_u(event)');
                if (arr_false[i]. iconURL)
                    {                        
                       menuItem. setAttribute ("src",arr_false[i]. iconURL);
                    }
                else
                    {
                        menuItem. setAttribute ("src",iconURL);
                    }
                boxx3. appendChild (xul)
            }
        }
    )    
 
this. but_=function (event,class_) 
{
    var id= event. originalTarget.parentNode.previousSibling.firstChild. getAttribute ("id_")
    Components.utils.import("resource://gre/modules/AddonManager.jsm");
    AddonManager.getAllAddons
    (
        function(addons) 
            {                    
                for (var i = 0; i < addons. length; i++)
                {
                    if(addons[i].id==id)
                        {
                            if(class_=='Disabled_')
                                {
                                    
                                    addons[i].userDisabled = !addons[i].userDisabled;
                                }
                            if(class_=='_')
                                {
                                    addons[i].uninstall();
                                }
                            if(class_=='st_')
                                {
                                    window. openDialog ('chrome://stylish/content/edit.xul', addons[i].name, 'chrome,dialog=0,resizable,titlebar,toolbar,centerscreen;',addons[i])
                                }    
                        }
                    }            
                }
            );    
}

this.open_=function(event){
var id= event. originalTarget.parentNode.previousSibling.firstChild. getAttribute ("id_")
var file = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).
    get("ProfD", Components.interfaces.nsIFile);
file.append("extensions");
file.append(id);
var tr=file.exists()
if(tr==true)
    {
        let nsLocalFile = Components.Constructor("@mozilla.org/file/local;1",
                                           "nsILocalFile", "initWithPath");                                           
        new nsLocalFile(file.path).reveal();
    }
else
    {
        var id=id+'.xpi'
        var file = Components.classes["@mozilla.org/file/directory_service;1"].
            getService(Components.interfaces.nsIProperties).
            get("ProfD", Components.interfaces.nsIFile);
        file.append("extensions");
        file.append(id);
        var local = Components.classes["@mozilla.org/file/local;1"].
            createInstance(Components.interfaces.nsILocalFile);
        var process = Components.classes["@mozilla.org/process/util;1"].
            createInstance(Components.interfaces.nsIProcess);
        var args = [file.path]
        local.initWithPath("e:\\pro\\WinRAR\\WinRAR.exe");
        process.init(local);
        process.run(false, args, args.length);
    }}

 

var boxx=    box_0.getElementsByClassName ("theme_")[0]
AddonManager. getAddonsByTypes
(
        ["theme"],
        function (addons)
        {
            addons. sort
                    (
                    function (a, b, c, d)
                        {
                            return a.name. toLowerCase ()  > b.name. toLowerCase ();
                        }
                    );
            
            var box_on= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "vbox");
            var box_of= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "vbox");
            var box_sel= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "vbox");
            for (var i = 0; i < addons. length; i++)
                {
                    if(!(addons[i].id.slice(addons[i].id.length-21)=='@personas.mozilla.org'))
                        {
                            if(addons[i].isActive)
                                {
                                    var xul=THIS. xulFavSel()
                                    var b_=xul.lastChild.previousSibling
                                    var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                    menuItem. setAttribute ("label",addons[i]. name);
                                    menuItem. setAttribute ("id_",addons[i]. id);
                                    b_.firstChild.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="_";tqa.but_(event,class_)');
                                    
                                    if (addons[i]. iconURL)
                                        {                        
                                            menuItem. setAttribute ("src",addons[i]. iconURL);
                                        }
                                    else
                                        {
                                            menuItem. setAttribute ("src",iconURL);
                                        }
                                    
                                    box_sel. appendChild (xul)                                     
                                }
                            else
                            {
                                var xul=THIS. xul_ex()
                                var b_=xul.lastChild
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("label",addons[i]. name);
                                menuItem. setAttribute ("id_",addons[i]. id);
                                b_.firstChild.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="Disabled_";tqa.but_(event,class_)');
                                b_.firstChild.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="_";tqa.but_(event,class_)');
                                b_.firstChild.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.open_(event)');                
                                b_.firstChild.nextSibling.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.but_u(event)');
                                if (addons[i]. iconURL)
                                {                        
                                    menuItem. setAttribute ("src",addons[i]. iconURL);
                                }
                                else
                                {
                                    menuItem. setAttribute ("src",iconURL);
                                }
                                
                                if (addons[i].appDisabled==true)
                                {                        
                                    menuItem.setAttribute("disabled","true")
                                    box_of. appendChild (xul)    
                                }
                                if (addons[i].appDisabled==false)
                                {
                                    box_on. appendChild (xul)    
                                }    
                            }
                                    
                        }
                
                }
            boxx.orient = "vertical";
            boxx. appendChild (box_sel)
            boxx. appendChild (box_on)
            if(box_of.childNodes.length>0)
            {
                boxx. appendChild (document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuseparator"));
                boxx. appendChild (box_of)    
            }
            
        }
)    



            

var st_e=    box_0.getElementsByClassName ("st_e")[0]
var st_d=    box_0.getElementsByClassName ("st_d")[0]
var st_d_arr=new Array();
var st_e_arr=new Array();    
AddonManager. getAddonsByTypes
(
        ["userstyle"],
        function (addons)
        {
            
            
            for (var i = 0; i < addons. length; i++)
            {
                var xul=THIS.  xul_ex()
                var b_=xul.lastChild
                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                menuItem. setAttribute ("src",addons[i]. iconURL);
                menuItem. setAttribute ("label",addons[i]. name);
                menuItem. setAttribute ("id_",addons[i]. id);
                b_.firstChild.nextSibling.nextSibling.setAttribute("label","edit")
                b_.firstChild.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="Disabled_";tqa.but_(event,class_);tqa.st_(event);');
                b_.firstChild.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="_";tqa.but_(event,class_);event. originalTarget.parentNode.parentNode.parentNode.removeChild(event. originalTarget.parentNode.parentNode);');
                b_.firstChild.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="st_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.but_u(event)');
                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                if (addons[i]. iconURL)
                {                        
                    menuItem. setAttribute ("src",addons[i]. iconURL);
                }
                else
                {
                    menuItem. setAttribute ("src",iconURL);
                }
                if (addons[i] .userDisabled)
                {                        
                    menuItem.setAttribute("disabled","true")
                    st_d_arr.push(xul)
                }
                else
                {
                    menuItem.setAttribute("disabled","false")
                    st_e_arr.push(xul)
                }
                                     
            }
            
        st_e_arr. sort
                    (
                    function (a, b, c, d)
                        {
                            return a.getElementsByTagName ("menuitem") [0]. getAttribute ("label"). toLowerCase ()  > b.getElementsByTagName ("menuitem") [0]. getAttribute ("label"). toLowerCase () ;
                        }
                    );    
        st_d_arr. sort
                    (
                    function (a, b, c, d)
                        {
                            return a.getElementsByTagName ("menuitem") [0]. getAttribute ("label"). toLowerCase ()  > b.getElementsByTagName ("menuitem") [0]. getAttribute ("label"). toLowerCase () ;
                        }
                    );                
        for (var i = 0; i < st_d_arr. length; i++)
            {    
                st_d. appendChild (st_d_arr[i])
            }    
        for (var i = 0; i < st_d_arr. length; i++)
            {    
                st_e. appendChild (st_e_arr[i])
            }        
        }
)
this. st_=function (event) 
{
    
    var m= event. originalTarget.parentNode.previousSibling.firstChild
    var obj= event. originalTarget.parentNode.parentNode
    var b= event. originalTarget.parentNode.parentNode.parentNode
    
    if(m.getAttribute("disabled")=='true')
    {
        
        b.previousSibling .previousSibling .  appendChild (obj)
        m.setAttribute("disabled","false")
        
    }
    else
    {
        m.setAttribute("disabled","true")
        b.nextSibling .nextSibling. appendChild (obj)
    }
}    

this. but_u=function (event) 
    {
        var id= event. originalTarget.parentNode.previousSibling.firstChild. getAttribute ("id_")
        var info = Components.classes["@mozilla.org/xre/app-info;1"] 
            .getService(Components.interfaces.nsIXULAppInfo);   
        Components.utils.import("resource://gre/modules/AddonManager.jsm");
        AddonManager.getAddonByID(id, function(aAddon) {
            aAddon.findUpdates(UpdateListener, 1, window.navigator.appVersion, info.platformVersion);
        });  
 
 
        var UpdateListener = 
        {
            onUpdateAvailable: function(addon,install) 
            {
                install.addListener
                (
                    { 
                        onInstallEnded: function () 
                        {                    
                            install.removeListener({onInstallEnded: function (){}})
                            event. originalTarget.parentNode.previousSibling.firstChild.setAttribute("style","color:#006600;")
                            event. originalTarget.setAttribute("oncommand",'this.install.cancel();this.install=null;this.parentNode.previousSibling.firstChild.setAttribute("style","color:#000000;")')
                            event. originalTarget.setAttribute("label","cancel")
                        }
                    }
                    
                );
                install.addListener
                (
                    { 
                        onDownloadFailed: function ()
                        {
                            install.removeListener({onDownloadFailed: function (){}})
                            event. originalTarget.parentNode.previousSibling.firstChild.setAttribute("style","color:#FF0000;")
                            event. originalTarget.setAttribute("label","error")
                        }
                    }
                )
                install.addListener
                (
                    { 
                        onInstallFailed: function ()
                        {
                            install.removeListener({onInstallFailed: function (){}})
                            event. originalTarget.parentNode.previousSibling.firstChild.setAttribute("style","color:#FF0000;")
                            event. originalTarget.setAttribute("label","error")
                        }    
                    }
                )    
                event. originalTarget.parentNode.previousSibling.firstChild.setAttribute("style","text-decoration:underline;")
                event. originalTarget.setAttribute("label","install/true")
                event. originalTarget.install=install
                event. originalTarget.setAttribute('onclick','this.install.install()');
            },
            onNoUpdateAvailable: function(addon) 
            {
                 if(event. originalTarget.getAttribute("label")=='install/true'||event. originalTarget.getAttribute("label")=='cancel')
                    return
                 event. originalTarget.setAttribute("label","install/false")
                 event. originalTarget.parentNode.previousSibling.firstChild.setAttribute("style","color:#6666CC;")
                 return;
            },
            onCompatibilityUpdateAvailable: function(addon) 
            {                  
                return;
            },
            onNoCompatibilityUpdateAvailable: function(addon) 
            {
                return;
            },
            onUpdateFinished: function(addon,err) 
            {
   
                return;
            }
        }
    }
                        
this. type = "menu-button";
this.orient = "horizontal";
this. appendChild (menupopup);
menupopup.appendChild (box_0);

Добавлено 04-02-2012 15:07:26

vitalii201 пишет

у меня названия аддонов почему-то видны только при наведении курсора

я не знаю почему...

Отредактировано Ste_pan (04-02-2012 15:07:26)

Отсутствует

 

№358904-02-2012 15:49:59

mserv
Участник
 
Группа: Members
Зарегистрирован: 15-11-2008
Сообщений: 1025
UA: Nightly 13.0

Re: Custom Buttons

Ste_pan пишет

щас все сортирует

Да, всё сортируется, но отображаются не все стили, уменьшилось окно, и пропала прокрутка.

Отсутствует

 

№359004-02-2012 16:06:41

SendInfo
.
 
Группа: Members
Зарегистрирован: 14-02-2011
Сообщений: 271
UA: unknown 0.0

Re: Custom Buttons

Ste_pan пишет

что-бы работпла кнопка open в коде надо поменять путь
к program files на свой

Выделить код

Код:

local.initWithPath("e:\\pro\\WinRAR\\WinRAR.exe");

Для Ubuntu:

Выделить код

Код:

local.initWithPath("/usr/bin/file-roller");

Убрать стрелку возле кнопки(дропмейкер):

Выделить код

Код:

this. type = "menu-button";

заменить на

Выделить код

Код:

this. type = "menu";

В кнопке имеется баг: у меня помимо дефолтной используется установленная тема. Естественно дефолтная тема находится в отключенном состоянии. Для установленной темы показывается только кнопка "del", для дефолтной темы - кнопки "on/off","del","open","update". А должно быть наоборот . Причем для дефолтной темы должна быть только одна кнопка "on/off", а для установленнных тем -кнопки "on/off", "del", "open", "update", вне зависимости от их состояния.

Отсутствует

 

№359104-02-2012 18:33:41

SendInfo
.
 
Группа: Members
Зарегистрирован: 14-02-2011
Сообщений: 271
UA: Firefox 10.0

Re: Custom Buttons

bunda1 пишет

SendInfoВот CB код каторый заменяет greasemonkey.Скрипты сохраняй в папку \Profile\chrome\UserScriptLoader, скрипт в папке должен быть вот таким 47007.userКод саздает на панеле дополнений кнопку  которая открывает меню для управление скриптами: 

скрытый текст
Код:
//User Script Loader.......................

(function() {

const OPEN_FOLDER_MENU = false;
const SAVE_SCRIPT_MENU = true;
const USE_STORAGE_NAME = ['cache', 'cacheInfo']; // ????? pref ? storage ?????

// User setting (pref.js ?????????????)
const EDITOR = 'C:\\Program Files\\EmEditor\\EmEditor.exe'; //\>\\
const SCRIPTS_FOLDER = ''; // ???? chrome\\UserScriptLoader ????
                            // ?: 'D:\\UserScriptLoader'


const ON_IMAGE = "data:image/png;base64," +
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACOElEQVQ4ja3Q3UtTcRgH8N8f" +
"4K11FaRrVGumlTXndPYiyQqkCyPoLroOCbyJSCGJUhOGUSnShVqtFpYlW/lCKiPmy5zinObZ" +
"dJtn29nZcW7nnB39TapvF+WdI4W+95/n+zwPIf8zwnRFt+AyIj5VDn7CAN5ZiphDD25Mh+jI" +
"aUSGixEePAnWXhTaeYCr/OdWogMZoR2Z2DPQyBNsrpqxEWiF4muG4LwK9nOhvCOOT5Y1iks3" +
"sSV0IP29CrLnAkS3EalxPRR/CxJTN8Dai35kXZ+fNGQyfBs2Q7chz1dCcp9FasIAxd+E5Gwt" +
"woNl8H3QqnZuHy+tSc5fRybejvTCRUiz55CaKoPsvQV5sR7ciAnBvoJLWdtjTn1aCTWARlsh" +
"z52HOG1E0lkCxd+C+LdrCH7S1mXHjhLd2nQ1MvxzyF4TxJlKpCYrsD6mQ3rpEUL92l+BPg1d" +
"6T1Kl98dpr43asq8OkSZ7nyeEEII59DzElMHGm3DJmvGRvAxFH8TFF8T0osPIXkaIc7UI+W6" +
"i+TEHbD9VWC68hRPx4E//+BGz6QiX4tpeOgUZQdO0FV7IQ3ZCqi8+ACC7TjWhkwQ3Q2IfrmC" +
"ZcsxMF0HX2Q9ZzuBj9rRdVctpLn7EN33ELaZwPSoRE/nvv3/xIQQEnivgeRpBDdcg5W3BWB6" +
"8s27gn/xDDdUjejAZfheqxOezrzdtRJCiNeamxPo1WLFqgHzUtW8a7idZesRr9+i5r1Pc3P2" +
"jAkhhLGodXs1vwEkf3FKAtNVEwAAAABJRU5ErkJggg==";

const OFF_IMAGE = "data:image/png;base64," +
"iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACrElEQVQ4ja2QXUhTARzFb3f5" +
"5kuB2EOBplLJTCtrzs/pJNHEJ03orXyIHkQkFSvSSKTmB5hRKfWSVJZhWX5MvZIuiemc05zT" +
"3Obm3Ny8m7rP6+7MdnoIQWF76zwe+J3z/x+C+J+yTWd02OTpsE6lgZ5MAS1Nxvo4HxYJD+bR" +
"i1gbSYRp+DyMAwmGwAHytD87m+3w2drgW38Odu0pvKst2NY3g9E0wCYtglEc7w4IW2Wpdc6l" +
"EuzY2uH5lQO3UginIh2OCT4YbSM2p67DOJCwG/R8Wpbi89Gt8BrK4Z7PhkshgGMyBYxWBPts" +
"GUzDqdB85kYFbp9ILrTPX4PP2gbPwmW4ZjPhmEqFW1UK92INLKO5WOmJywvavi7lexhDLVhz" +
"M9xzWXBOp8MuTQKjbYT1RzFWvnIrgsPjSbyN6QL46Bdwq3LhnMmGQ5aBLQkPnqXHMPRy/fqe" +
"WFbXfYZd/niK1byPYdVvo1l1x0maIAiCsIzzaZe6Aqy5FV5jC7ZXmsBoRWA0IngWH8GlrINz" +
"pgYO+T3YJ+/A2JsD9etIRtl+4t8elrFLjrVviayJusAah86xqwPxrKE/jnUv1sPWfxYbVC6c" +
"ilosNCThe/FRUJmHMZhNroqzyeqgb+m/cMe25GVwzT2EU3EfKlEift7mwdvXBP+CGExnOWS3" +
"uLtDWWRp4IBPsXAp62AZKYTuQxyovBDHdl8T8CQfqDoC1EfAJsrAoJDUBYJnLFQBzENXoHkX" +
"s6l8GRlOCTh+/3Q39steEw5KwPEfgFVdYaH6bi50XbFQv4lq2PPFQtLoeXUDqAkHW0lgq5KA" +
"4SYHYiFpOhCw3HVape2MoVXPwkL3+5Krxx5MlET/NldFwFodguWSQ6DyObsDQvLugQB1Zwwv" +
"2LCSouPVYiGppwQcv1hIGvfgv6X5zFaYeSAgAAAAAElFTkSuQmCC";



var useDocumentStart = (function(){
var version = Cc['@mozilla.org/xre/app-info;1'].getService(Ci.nsIXULAppInfo).version;
var vc = Cc["@mozilla.org/xpcom/version-comparator;1"].getService(Ci.nsIVersionComparator);
return vc.compare(version, '3.6.12') >= 0;
})();

var observer = !useDocumentStart? null :(function(){
let list = Cc['@mozilla.org/appshell/window-mediator;1']
.getService(Ci.nsIWindowMediator)
.getEnumerator('navigator:browser');
while(list.hasMoreElements()) {
let win = list.getNext();
if (win.UserScriptLoader && win.UserScriptLoader.observer) {
return win.UserScriptLoader.observer;
}
}

return {
disabled: true,
observerService: Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService),
observe: function(subject, topic, data){
var doc = subject.document;
var evt = doc.createEvent("Events");
evt.initEvent("USL_DocumentStart", true, false);
doc.dispatchEvent(evt);
},
register: function(){
this.observerService.addObserver(this, "content-document-global-created", false);
this.disabled = false;
this.log('USL observer start');
},
unregister: function(){
this.observerService.removeObserver(this, "content-document-global-created");
this.disabled = true;
this.log('USL observer end');
},
log: log
};

})();


if (typeof window.UserScriptLoader != 'undefined') {
window.UserScriptLoader.theEnd();
}

var ns = window.UserScriptLoader = {
OPEN_FOLDER_MENU : OPEN_FOLDER_MENU,
SAVE_SCRIPT_MENU : SAVE_SCRIPT_MENU,
HIDE_EXCLUDE : false,
DEBUG : false,
USE_STORAGE_NAME : USE_STORAGE_NAME,
SCRIPTS_FOLDER : SCRIPTS_FOLDER,
ON_IMAGE : ON_IMAGE,
OFF_IMAGE : OFF_IMAGE,
EDITOR : EDITOR,
AUTO_REBUILD : false,
useDocumentStart : useDocumentStart,

readScripts : [],
runAtStartScripts: [],
runAtEndScripts : [],

disabled_scripts : [],
_disabled : null,
observer : observer,

get disabled () this._disabled,
set disabled (bool) {
this._disabled = bool;
if (bool) {
//$('sidebar').removeEventListener('DOMContentLoaded', this.sidebarContentLoaded, false);
gBrowser.mPanelContainer.removeEventListener('DOMContentLoaded', this.domContentLoaded, false);
gBrowser.mPanelContainer.removeEventListener('USL_DocumentStart', this.onDocumentStart, false);
this.icon.style.textDecoration = 'line-through';
this.icon.setAttribute('src', this.OFF_IMAGE);
} else {
//$('sidebar').addEventListener('DOMContentLoaded', this.sidebarContentLoaded, false);
gBrowser.mPanelContainer.addEventListener('DOMContentLoaded', this.domContentLoaded, false);
gBrowser.mPanelContainer.addEventListener('USL_DocumentStart', this.onDocumentStart, false);
this.icon.style.textDecoration = 'none';
this.icon.setAttribute('src', this.ON_IMAGE);
}
return bool;
},
fxver: parseFloat(Cc['@mozilla.org/xre/app-info;1'].getService(Ci.nsIXULAppInfo).version),
getFocusedWindow: function(){
var win = document.commandDispatcher.focusedWindow;
if (!win || win == window)
win = content;
return win;
},
init: function() {

// ????????????????
["require", "resourceText", "resourceURL"].forEach(function(name){
var s = window.globalStorage['UserScriptLoader.' + name];
for (var n in s) { s.removeItem(n) }
});

this.pref = new PrefManager();
try {
let ds = this.pref.getValue('script.disabled', '');
if (ds)
ns.disabled_scripts = ds.split('|');
ns._disabled = this.pref.getValue('disabled', ns._disabled);
ns.SCRIPTS_FOLDER = this.pref.getValue('SCRIPTS_FOLDER', ns.SCRIPTS_FOLDER);
ns.EDITOR = this.pref.getValue('EDITOR', ns.EDITOR);
ns.HIDE_EXCLUDE = this.pref.getValue('HIDE_EXCLUDE', false);
ns.DEBUG = this.pref.getValue('DEBUG', ns.DEBUG);
} catch(ex) { log(ex) }

ns.icon = $('status-bar').appendChild($E(
<statusbarpanel id="UserScriptLoader-icon"
class="statusbarpanel-iconic"
context="UserScriptLoader-popup"
onclick="UserScriptLoader.iconClick(event);"
style="text-decoration: none;"/>
));

ns.popup = $('mainPopupSet').appendChild($E(
<menupopup id="UserScriptLoader-popup"
onpopupshowing="UserScriptLoader.onPopupShowing(event);"
onpopuphidden="UserScriptLoader.onPopupHidden(event);"
onclick="UserScriptLoader.menuClick(event);">
<menuseparator id="UserScriptLoader-menuseparator"/>
<menu label="User Script Command"
id="UserScriptLoader-register-menu" accesskey="C">
<menupopup id="UserScriptLoader-register-popup"/>
</menu>
<menuitem label="Save Script"
id="UserScriptLoader-saveMenu"
accesskey="S"
oncommand="UserScriptLoader.saveScript();"
collapsed={!ns.SAVE_SCRIPT_MENU}/>
<menu label="Menu" id="UserScriptLoader-submenu">
<menupopup id="UserScriptLoader-submenu-popup">
<menuitem label="delete resource / require" oncommand="UserScriptLoader.deleteStorage('resource');"/>
<menuitem label="delete pref storage" oncommand="UserScriptLoader.deleteStorage('pref');"/>
<menuseparator/>
<menuitem label="Hide exclude script"
id="UserScriptLoader-hide-exclude"
accesskey="N"
type="checkbox"
checked={ns.HIDE_EXCLUDE}
oncommand="UserScriptLoader.HIDE_EXCLUDE = !UserScriptLoader.HIDE_EXCLUDE;"/>
<menuitem label="Open Scripts Folder"
id="UserScriptLoader-openFolderMenu"
accesskey="O"
oncommand="UserScriptLoader.openFolder();"
collapsed={!ns.OPEN_FOLDER_MENU}/>
<menuitem label="Rebuild"
accesskey="R"
oncommand="UserScriptLoader.rebuild();"/>
<menuitem label="Auto Rebuild"
id="UserScriptLoader-auto-rebuild"
accesskey="A"
type="checkbox"
checked={ns.AUTO_REBUILD}
oncommand="UserScriptLoader.AUTO_REBUILD = !UserScriptLoader.AUTO_REBUILD;"/>
</menupopup>
</menu>
</menupopup>
));

ns.menuseparator = $('UserScriptLoader-menuseparator');
ns.registMenu = $('UserScriptLoader-register-menu');
ns.registPopup = $('UserScriptLoader-register-popup');
ns.openFolderMenu = $('UserScriptLoader-openFolderMenu');
ns.saveMenu = $('UserScriptLoader-saveMenu');
ns.hideExcludeMenu = $('UserScriptLoader-hide-exclude');
ns.autoRebuildMenu = $('UserScriptLoader-auto-rebuild');

ns.importScripts();
ns.disabled = ns._disabled;
window.addEventListener('unload', ns.uninit, false);
if (this.observer.disabled)
this.observer.register();
},
uninit: function(event) {
let disabledScripts = ns.readScripts.reduce(function(ret, script) {
if (script._disabled)
ret.push(script._leafName);
return ret;
}, []);
var pref = ns.pref || new PrefManager();
pref.setValue('script.disabled', disabledScripts.join('|'));
pref.setValue('disabled', ns._disabled);
pref.setValue('HIDE_EXCLUDE', ns.HIDE_EXCLUDE);
if (!ns.disabled) ns.disabled = true;
if (event) {
let list = Cc['@mozilla.org/appshell/window-mediator;1']
.getService(Ci.nsIWindowMediator)
.getEnumerator('navigator:browser');
while(list.hasMoreElements()) {
if (list.getNext() != window)
return
}
ns.observer.unregister();
}
},
theEnd: function() {
ns.uninit();
ns.icon.parentNode.removeChild(ns.icon);
ns.popup.parentNode.removeChild(ns.popup);
//delete window.UserScriptLoader;
},
importScripts: function() {
let aFolder = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsILocalFile)
if (!ns.SCRIPTS_FOLDER) {
let UChrm = Cc["@mozilla.org/file/directory_service;1"]
.getService(Ci.nsIProperties)
.get("UChrm", Ci.nsIFile);
ns.SCRIPTS_FOLDER = UChrm.path;
aFolder.initWithPath(ns.SCRIPTS_FOLDER);
aFolder.appendRelativePath('UserScriptLoader');
}
else {
aFolder.initWithPath(ns.SCRIPTS_FOLDER);
}

try {
if( !aFolder.exists() || !aFolder.isDirectory() ) {
aFolder.append("");
aFolder.create(Ci.nsIFile.DIRECTORY_TYPE, 0664);
}
} catch (e) {
return error('importScripts error.')
}

ns.readScripts = [];
ns.runAtStartScripts = [];
ns.runAtEndScripts = [];
let ext = /\.user\.js$/i;
let files = aFolder.directoryEntries.QueryInterface(Ci.nsISimpleEnumerator);
while (files.hasMoreElements()) {
let file = files.getNext().QueryInterface(Ci.nsIFile);
if (ext.test(file.leafName))
ns.loadScript(file);
}
},
rebuild: function() {
let disabledScripts = ns.readScripts.reduce(function(ret, script) {
if (script._disabled)
ret.push(script._leafName);
return ret;
}, []);
ns.disabled_scripts = disabledScripts;
ns.importScripts();
ns.DEBUG = this.pref.getValue('DEBUG', ns.DEBUG);
},
openFolder: function() {
var file = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsILocalFile);
file.initWithPath(ns.SCRIPTS_FOLDER);
file.launch();
},
saveScript: function() {
var win = ns.getFocusedWindow();

var url = win.location.href;
var doc = win.document;
var pre = doc.querySelector('body > pre');
var filename = pre && /@name\s+([^\n]+)/i.test(pre.textContent)?
RegExp.$1 + '.user.js':
/[^/]+$/i.exec(url)[0];

var lastDir = gPrefService.getCharPref('browser.download.lastDir');
gPrefService.setCharPref('browser.download.lastDir', ns.SCRIPTS_FOLDER);
saveURL( url, filename, null, true, false, makeURI(url, doc.characterSet) );
gPrefService.setCharPref('browser.download.lastDir', lastDir);
},
deleteStorage: function(type) {
var storage = new StorageManager(type);
var list = storage.listValues();
if (list.length == 0)
return alert(type + ' is none.');

list.push('All ' + type);
var prompts = Cc["@mozilla.org/embedcomp/prompt-service;1"].getService(Ci.nsIPromptService);
var selected = {};
var ok = prompts.select(
window,
"UserScriptLoader " + type,
"Select delete URL.",
list.length,
list,
selected
);

if (!ok) return;
if (selected.value == list.length -1) {
list.pop();
list.forEach(function(url, i, a) {
storage.deleteValue(url);
});
return;
}
storage.deleteValue(list[selected.value]);
},
loadScript: function(aFile) {
var script = new ScriptEntry(aFile);
script._disabled = ns.disabled_scripts.indexOf(script._leafName) >= 0;
ns.readScripts.push(script);
var runat = script['run-at'];
if (runat === 'document-start') {
ns.runAtStartScripts.push(script);
}
else {
ns.runAtEndScripts.push(script);
}
return;
},
onPopupShowing: function(event) {
var win = ns.getFocusedWindow();
var popup = event.target;
var data = GrieverWindowStore.get(win);

switch(popup.id) {
case 'UserScriptLoader-popup':
var run = data.USL_run;
ns.readScripts.forEach(function(script) {
if (ns.HIDE_DISABLED_SCRIPT && script._disabled) return;
if (ns.HIDE_EXCLUDE && !script._isURLMatching(win.location.href)) return;

let m = document.createElement('menuitem');
m.setAttribute('label', script.name || script._leafName);
m.setAttribute('checked', !script._disabled);
m.setAttribute('type', 'checkbox');
m.setAttribute('oncommand', 'this.script._disabled = !this.script._disabled;');
m.script = script;

if (run && run.indexOf(script) >= 0)
m.style.fontWeight = 'bold';
ns.popup.insertBefore(m, ns.menuseparator);
}, ns);

ns.saveMenu.hidden = win.location.href.indexOf('.js') == -1;
ns.registMenu.hidden = data.USL_registerCommands && data.USL_registerCommands.length == 0;
break;

case 'UserScriptLoader-register-popup':
var registers = data.USL_registerCommands;
if (!registers) return;
registers.forEach(function(item, i, a) {
let m = document.createElement('menuitem');
m.setAttribute('label', item.label);
m.setAttribute('tooltiptext', item.tooltiptext);
m.setAttribute('oncommand', 'this.registCommand();');
m.registCommand = item.func;
popup.appendChild(m);
}, ns);
break;

case 'UserScriptLoader-submenu-popup':
ns.hideExcludeMenu.setAttribute('checked', ns.HIDE_EXCLUDE);
ns.autoRebuildMenu.setAttribute('checked', ns.AUTO_REBUILD);
break;
}
},
onPopupHidden: function(event) {
var popup = event.target;
switch(popup.id) {
case 'UserScriptLoader-popup':
case 'UserScriptLoader-register-popup':
var child = popup.firstChild;
while (child && child.localName == 'menuitem') {
popup.removeChild(child);
child = popup.firstChild;
}
break;
}
},
menuClick: function(event){
var menuitem = event.target;
if (event.button == 0 || menuitem.getAttribute('type') != 'checkbox')
return;

event.preventDefault();
event.stopPropagation();
if (event.button == 1) {
menuitem.doCommand();
menuitem.setAttribute('checked', menuitem.getAttribute('checked') == 'true'? 'false' : 'true');
}else if (event.button == 2 && ns.EDITOR && menuitem.script) {
var app = Cc['@mozilla.org/file/local;1'].createInstance(Ci.nsILocalFile);
app.initWithPath(ns.EDITOR);
var process = Cc['@mozilla.org/process/util;1'].createInstance(Ci.nsIProcess);
process.init(app);
process.run(false, [menuitem.script._path], 1);
}
},
iconClick: function(event){
if (event.button == 0) {
ns.disabled = !ns.disabled;
ns.pref.setValue('disabled', ns.disabled);
} else if (event.button == 1)
ns.rebuild();
},
domContentLoaded: function(event) {
var doc = event.target;
if (!/^(?:https?|data|file|chrome):/.test(doc.location.protocol))
return;
// document-start ????????? DOMContentLoaded ?????
if (!ns.useDocumentStart)
ns.injectScripts(ns.runAtStartScripts, doc);
ns.injectScripts(ns.runAtEndScripts, doc);
},
sidebarContentLoaded: function(event) {
return;
var doc = event.target;
if (!/^(?:https?):/.test(doc.location.protocol))
return;
if (!ns.useDocumentStart)
ns.injectScripts(ns.runAtStartScripts, doc);
ns.injectScripts(ns.runAtEndScripts, doc);
},
onDocumentStart: function(event) {
var doc = event.target;
if (!/^(?:https?|data|file|chrome):/.test(doc.location.protocol))
return;
if (doc.documentElement) {
ns.injectScripts(ns.runAtStartScripts, doc);
} else {
doc.addEventListener('DOMNodeInserted', function(event){
event.currentTarget.removeEventListener(event.type, arguments.callee, false);
ns.injectScripts(ns.runAtStartScripts, doc);
}, false);
}
},
sidebarDocumentStart: function(event) {
return;
var doc = event.target;
if (!/^(?:https?):/.test(doc.location.protocol))
return;
ns.injectScripts(ns.runAtStartScripts, doc);
},
injectScripts: function(scripts, aDocument) {
if (scripts.length === 0) return;
var contentWindow = aDocument.defaultView;
var locationHref = contentWindow.location.href;
var data = GrieverWindowStore.get(contentWindow);

var unsafeWindow = contentWindow.wrappedJSObject || contentWindow;
var wrappedWindow = new XPCNativeWrapper(unsafeWindow);
var safeWindow = ns.fxver >= 4?
{
wrappedJSObject: unsafeWindow,
__proto__: wrappedWindow
}:
wrappedWindow;

if ("AutoPagerize" in data)
safeWindow.AutoPagerize = data.AutoPagerize;
var sbWindow = ns.fxver >= 4? window: wrappedWindow;
var console = unsafeWindow.console || new Console();

if (!data.USL_registerCommands)
data.USL_registerCommands = [];
if (!data.USL_run)
data.USL_run = [];

scripts.filter(function(script) {
if ("noframes" in script && contentWindow.frameElement instanceof HTMLIFrameElement)
return false;

if (!script._isURLMatching(locationHref))
return false;

if (data.USL_run.indexOf(script) >= 0) {
log('DABUTTAYO!!!!! ' + script.name);
return false;
}

let sandbox = new Cu.Sandbox(sbWindow);
sandbox.GM_log = log;
sandbox.GM_xmlhttpRequest = GM_xmlhttpRequest;
sandbox.GM_openInTab = function(url) { openNewTabWith(url); };
sandbox.GM_registerMenuCommand = function(label, func) {
data.USL_registerCommands.push({ label:label, func:func, tooltiptext:(script.name || script._leafName) });
}
sandbox.GM_getResourceText = function(name) {
let obj = script._resourceValues[name];
if (obj.bytes) {
return obj.bytes;
}
}
sandbox.GM_getResourceURL = function(name) {
let obj = script._resourceValues[name];
if (obj) {
return 'data:' + obj.contentType + ';base64,' + btoa(obj.bytes);
}
}
sandbox.GM_addStyle = function(code) GM_addStyle(code, sandbox.document);
sandbox.GM_setValue = function(name, value) {
return ns.USE_STORAGE_NAME.indexOf(name) >= 0?
script._storage.setValue(script._prefName + name, value):
script._pref.setValue(name, value);
}
sandbox.GM_getValue = function(name, def) {
return ns.USE_STORAGE_NAME.indexOf(name) >= 0?
script._storage.getValue(script._prefName + name, def):
script._pref.getValue(name, def);
}
sandbox.GM_listValues = function() {
var p = script._pref.listValues();
var s = script._storage.listValues(script._prefName + name).filter(function(e) e.indexOf(script._prefName) == 0);
s.forEach(function(e, i, a) a[i] = e.replace(script._prefName, ''));
p.push.apply(p, s);
return p;
}
sandbox.GM_deleteValue = function(name) {
return ns.USE_STORAGE_NAME.indexOf(name) >= 0?
script._storage.deleteValue(script._prefName + name):
script._pref.deleteValue(name);
}
sandbox.GM_setClipboard = function(str) {
if (str.constructor === String ||
str.constructor === Number) {
Cc['@mozilla.org/widget/clipboardhelper;1'].getService(Ci.nsIClipboardHelper).copyString(str);
return;
}
return error('GM_setClipboard error.');
}
sandbox.unsafeWindow = unsafeWindow;
sandbox.window = safeWindow;
sandbox.document = safeWindow.document;
sandbox.XPathResult = Ci.nsIDOMXPathResult;
sandbox.console = console;
sandbox.__proto__ = safeWindow;
if (script['run-at'] === 'document-start') {
if (aDocument.documentElement) {
ns.evalInSandbox(script, sandbox);
} else {
aDocument.addEventListener('readystatechange', function(event){
if (aDocument.readyState !== 'loading') {
event.currentTarget.removeEventListener(event.type, arguments.callee, false);
ns.evalInSandbox(script, sandbox);
}
}, false);
}
} else if (script['run-at'] === 'document-idle') {
setTimeout(ns.evalInSandbox, 0, script, sandbox);
} else {
ns.evalInSandbox(script, sandbox);
}
data.USL_run.push(script);
return true;
});

},
evalInSandbox: function(aScript, aSandbox) {
try{
Cu.evalInSandbox('(function() {' + aScript._requireSrc + aScript._code + '})();', aSandbox, "1.8");
} catch(e) {
if (e.stack) {
var evalErr = parseInt(e.stack.match(/\d+\s*$/)) || 0;
var req = aScript._requireSrc?
aScript._requireSrc.split('\n').length:
0;
var line = e.lineNumber - evalErr - req + 2;
error(aScript.name + ' / line:' + line + '\n' + e);
} else {
error(aScript._leafName + '\n' + e);
}
}
},
}


// Class
function PrefManager(str) {
var root = 'UserScriptLoader.';
if (str)
root += str;
this.pref = Cc["@mozilla.org/preferences-service;1"]
.getService(Ci.nsIPrefService)
.getBranch(root);
}
PrefManager.prototype = {
setValue: function(name, value) {
try {
switch(typeof value) {
case 'string' :
var str = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
str.data = value;
this.pref.setComplexValue(name, Ci.nsISupportsString, str);
break;
case 'number' : this.pref.setIntPref(name, value); break;
case 'boolean': this.pref.setBoolPref(name, value); break;
}
} catch(e) { }
},
getValue: function(name, defaultValue){
var value = defaultValue;
try {
switch(this.pref.getPrefType(name)) {
case Ci.nsIPrefBranch.PREF_STRING: value = this.pref.getComplexValue(name, Ci.nsISupportsString).data; break;
case Ci.nsIPrefBranch.PREF_INT : value = this.pref.getIntPref(name); break;
case Ci.nsIPrefBranch.PREF_BOOL : value = this.pref.getBoolPref(name); break;
}
} catch(e) { }
return value;
},
deleteValue: function(name) {
try {
this.pref.deleteBranch(name);
} catch(e) { }
},
listValues: function() this.pref.getChildList("", {}),
};

function StorageManager(name) {
this.storage = window.globalStorage['UserScriptLoader.' + (name || '')];
}
StorageManager.prototype = {
setValue: function(key, value) {
this.storage.setItem(key, value);
},
getValue: function(key, defaultValue) {
var value = defaultValue;
try {
value = this.storage.getItem(key).value;
} catch (e) { }
return value;
},
deleteValue: function(key) {
this.storage.removeItem(key);
},
listValues: function() {
var st = this.storage;
var h = [];
for (var n in st) {
h.push(n);
}
return h;
},
}

function ScriptEntry(aFile) {
this._readFile(aFile);
this._getMetadata();
this._init();

this._includeRegExp = !this.include || this.include == '*'?
new RegExp("^https?://") :
this._createRegExp(this.include);
this._excludeRegExp = !this.exclude || this.exclude == '*'?
null :
this._createRegExp(this.exclude);
this._prefName = 'scriptival.' + (this.namespace || 'nonamespace/') + '/' + (this.name || this._leafName) + '.';

this._getResource();
}
ScriptEntry.prototype = {
_init: function() {
this._disabled = false;
this._requires = this.require? this.require.split('\n') : [];
this._requireSrc = '';
this._resources = {};
this._resourceValues = {};
if (!this['run-at'])
this['run-at'] = 'document-end';
if (this.resource) {
let resource = this.resource.split('\n');
for (let i = 0, l = resource.length; i < l; i++) {
let res = resource[i].split(/\s+/);
this._resources[res[0]] = res[1];
}
}

this.__defineGetter__('_storage', function() {
delete this._storage;
return this._storage = new StorageManager('pref');
});
this.__defineGetter__('_pref', function() {
delete this._pref;
return this._pref = new PrefManager(this._prefName);
});
this.__defineGetter__('_resourceStorage', function() {
delete this._resourceStorage;
return this._resourceStorage = new StorageManager('resource');
});
},
_readFile: function(aFile) {
var stream = Cc['@mozilla.org/network/file-input-stream;1'].createInstance(Ci.nsIFileInputStream);
stream.init(aFile,1,0,false);
var ss = Cc['@mozilla.org/scriptableinputstream;1'].createInstance(Ci.nsIScriptableInputStream);
ss.init(stream);
var data = ss.read(ss.available());
ss.close();
stream.close();
try {
data = decodeURIComponent(escape(data));
} catch(e) { }
this._code = data;
this._leafName = aFile.leafName;
this._path = aFile.path;
},
_getMetadata: function() {
let m = this._code.match(/\/\/\s*==UserScript==[\s\S]+?\/\/\s*==\/UserScript==/);
if (!m)
return;
m = (m+'').split(/[\r\n]+/);
for (let i = 0; i < m.length; i++) {
if (!/\/\/\s*?@(\S+)($|\s+([^\r\n]+))/.test(m[i]))
continue;
let name = RegExp.$1;
let value = RegExp.$3;
if (this[name]) {
this[name] += '\n' + value;
} else {
this[name] = value;
}
}
},
_createRegExp: function(urlstr) {
let regstr = urlstr.split('\n').map(function(str) {
var res = '^' + str.replace(/([()[\]{}|+.,^$?\\])/g, "\\$1").replace(/\*/g, '.*');

// from UCJSToolkit wildcardToRegex
var tldRegExp = new RegExp("^(\\^(?:[^/]*)(?://)?(?:[^/]*))(\\\\\\.tld)((?:/.*)?)$");
var tldRes = res.match(tldRegExp);
if (tldRes) {
var tldStr = "\.(?:demon\\.co\\.uk|esc\\.edu\\.ar|(?:c[oi]\\.)?[^\\.]\\.(?:vt|ne|ks|il|hi|sc|nh|ia|wy|or|ma|vi|tn|in|az|id|nc|co|dc|nd|me|al|ak|de|wv|nm|mo|pr|nj|sd|md|va|ri|ut|ct|pa|ok|ky|mt|ga|la|oh|ms|wi|wa|gu|mi|tx|fl|ca|ar|mn|ny|nv)\\.us|[^\\.]\\.(?:(?:pvt\\.)?k12|cc|tec|lib|state|gen)\\.(?:vt|ne|ks|il|hi|sc|nh|ia|wy|or|ma|vi|tn|in|az|id|nc|co|dc|nd|me|al|ak|de|wv|nm|mo|pr|nj|sd|md|va|ri|ut|ct|pa|ok|ky|mt|ga|la|oh|ms|wi|wa|gu|mi|tx|fl|ca|ar|mn|ny|nv)\\.us|[^\\.]\\.vt|ne|ks|il|hi|sc|nh|ia|wy|or|ma|vi|tn|in|az|id|nc|co|dc|nd|me|al|ak|de|wv|nm|mo|pr|nj|sd|md|va|ri|ut|ct|pa|ok|ky|mt|ga|la|oh|ms|wi|wa|gu|mi|tx|fl|ca|ar|mn|ny|nvus|ne|gg|tr|mm|ki|biz|sj|my|hn|gl|ro|tn|co|br|coop|cy|bo|ck|tc|bv|ke|aero|cs|dm|km|bf|af|mv|ls|tm|jm|pg|ky|ga|pn|sv|mq|hu|za|se|uy|iq|ai|com|ve|na|ba|ph|xxx|no|lv|tf|kz|ma|in|id|si|re|om|by|fi|gs|ir|li|tz|td|cg|pa|am|tv|jo|bi|ee|cd|pk|mn|gd|nz|as|lc|ae|cn|ag|mx|sy|cx|cr|vi|sg|bm|kh|nr|bz|vu|kw|gf|al|uz|eh|int|ht|mw|gm|bg|gu|info|aw|gy|ac|ca|museum|sk|ax|es|kp|bb|sa|et|ie|tl|org|tj|cf|im|mk|de|pro|md|fm|cl|jp|bn|vn|gp|sm|ar|dj|bd|mc|ug|nu|ci|dk|nc|rw|aq|name|st|hm|mo|gq|ps|ge|ao|gr|va|is|mt|gi|la|bh|ms|bt|gb|it|wf|sb|ly|ng|gt|lu|il|pt|mh|eg|kg|pf|um|fr|sr|vg|fj|py|pm|sn|sd|au|sl|gh|us|mr|dz|ye|kn|cm|arpa|bw|lk|mg|tk|su|sc|ru|travel|az|ec|mz|lb|ml|bj|edu|pr|fk|lr|nf|np|do|mp|bs|to|cu|ch|yu|eu|mu|ni|pw|pl|gov|pe|an|ua|uk|gw|tp|kr|je|tt|net|fo|jobs|yt|cc|sh|io|zm|hk|th|so|er|cz|lt|mil|hr|gn|be|qa|cv|vc|tw|ws|ad|sz|at|tg|zw|nl|info\\.tn|org\\.sd|med\\.sd|com\\.hk|org\\.ai|edu\\.sg|at\\.tt|mail\\.pl|net\\.ni|pol\\.dz|hiroshima\\.jp|org\\.bh|edu\\.vu|net\\.im|ernet\\.in|nic\\.tt|com\\.tn|go\\.cr|jersey\\.je|bc\\.ca|com\\.la|go\\.jp|com\\.uy|tourism\\.tn|com\\.ec|conf\\.au|dk\\.org|shizuoka\\.jp|ac\\.vn|matsuyama\\.jp|agro\\.pl|yamaguchi\\.jp|edu\\.vn|yamanashi\\.jp|mil\\.in|sos\\.pl|bj\\.cn|net\\.au|ac\\.ae|psi\\.br|sch\\.ng|org\\.mt|edu\\.ai|edu\\.ck|ac\\.yu|org\\.ws|org\\.ng|rel\\.pl|uk\\.tt|com\\.py|aomori\\.jp|co\\.ug|video\\.hu|net\\.gg|org\\.pk|id\\.au|gov\\.zw|mil\\.tr|net\\.tn|org\\.ly|re\\.kr|mil\\.ye|mil\\.do|com\\.bb|net\\.vi|edu\\.na|co\\.za|asso\\.re|nom\\.pe|edu\\.tw|name\\.et|jl\\.cn|gov\\.ye|ehime\\.jp|miyazaki\\.jp|kanagawa\\.jp|gov\\.au|nm\\.cn|he\\.cn|edu\\.sd|mod\\.om|web\\.ve|edu\\.hk|medecin\\.fr|org\\.cu|info\\.au|edu\\.ve|nx\\.cn|alderney\\.gg|net\\.cu|org\\.za|mb\\.ca|com\\.ye|edu\\.pa|fed\\.us|ac\\.pa|alt\\.na|mil\\.lv|fukuoka\\.jp|gen\\.in|gr\\.jp|gov\\.br|gov\\.ac|id\\.fj|fukui\\.jp|hu\\.com|org\\.gu|net\\.ae|mil\\.ph|ltd\\.je|alt\\.za|gov\\.np|edu\\.jo|net\\.gu|g12\\.br|org\\.tn|store\\.co|fin\\.tn|ac\\.nz|gouv\\.fr|gov\\.il|org\\.ua|org\\.do|org\\.fj|sci\\.eg|gov\\.tt|cci\\.fr|tokyo\\.jp|net\\.lv|gov\\.lc|ind\\.br|ca\\.tt|gos\\.pk|hi\\.cn|net\\.do|co\\.tv|web\\.co|com\\.pa|com\\.ng|ac\\.ma|gov\\.bh|org\\.zw|csiro\\.au|lakas\\.hu|gob\\.ni|gov\\.fk|org\\.sy|gov\\.lb|gov\\.je|ed\\.cr|nb\\.ca|net\\.uy|com\\.ua|media\\.hu|com\\.lb|nom\\.pl|org\\.br|hk\\.cn|co\\.hu|org\\.my|gov\\.dz|sld\\.pa|gob\\.pk|net\\.uk|guernsey\\.gg|nara\\.jp|telememo\\.au|k12\\.tr|org\\.nz|pub\\.sa|edu\\.ac|com\\.dz|edu\\.lv|edu\\.pk|com\\.ph|net\\.na|net\\.et|id\\.lv|au\\.com|ac\\.ng|com\\.my|net\\.cy|unam\\.na|nom\\.za|net\\.np|info\\.pl|priv\\.hu|rec\\.ve|ac\\.uk|edu\\.mm|go\\.ug|ac\\.ug|co\\.dk|net\\.tt|oita\\.jp|fi\\.cr|org\\.ac|aichi\\.jp|org\\.tt|edu\\.bh|us\\.com|ac\\.kr|js\\.cn|edu\\.ni|com\\.mt|fam\\.pk|experts-comptables\\.fr|or\\.kr|org\\.au|web\\.pk|mil\\.jo|biz\\.pl|org\\.np|city\\.hu|org\\.uy|auto\\.pl|aid\\.pl|bib\\.ve|mo\\.cn|br\\.com|dns\\.be|sh\\.cn|org\\.mo|com\\.sg|me\\.uk|gov\\.kw|eun\\.eg|kagoshima\\.jp|ln\\.cn|seoul\\.kr|school\\.fj|com\\.mk|e164\\.arpa|rnu\\.tn|pro\\.ae|org\\.om|gov\\.my|net\\.ye|gov\\.do|co\\.im|org\\.lb|plc\\.co\\.im|net\\.jp|go\\.id|net\\.tw|gov\\.ai|tlf\\.nr|ac\\.im|com\\.do|net\\.py|tozsde\\.hu|com\\.na|tottori\\.jp|net\\.ge|gov\\.cn|org\\.bb|net\\.bs|ac\\.za|rns\\.tn|biz\\.pk|gov\\.ge|org\\.uk|org\\.fk|nhs\\.uk|net\\.bh|tm\\.za|co\\.nz|gov\\.jp|jogasz\\.hu|shop\\.pl|media\\.pl|chiba\\.jp|city\\.za|org\\.ck|net\\.id|com\\.ar|gon\\.pk|gov\\.om|idf\\.il|net\\.cn|prd\\.fr|co\\.in|or\\.ug|red\\.sv|edu\\.lb|k12\\.ec|gx\\.cn|net\\.nz|info\\.hu|ac\\.zw|info\\.tt|com\\.ws|org\\.gg|com\\.et|ac\\.jp|ac\\.at|avocat\\.fr|org\\.ph|sark\\.gg|org\\.ve|tm\\.pl|net\\.pg|gov\\.co|com\\.lc|film\\.hu|ishikawa\\.jp|hotel\\.hu|hl\\.cn|edu\\.ge|com\\.bm|ac\\.om|tec\\.ve|edu\\.tr|cq\\.cn|com\\.pk|firm\\.in|inf\\.br|gunma\\.jp|gov\\.tn|oz\\.au|nf\\.ca|akita\\.jp|net\\.sd|tourism\\.pl|net\\.bb|or\\.at|idv\\.tw|dni\\.us|org\\.mx|conf\\.lv|net\\.jo|nic\\.in|info\\.vn|pe\\.kr|tw\\.cn|org\\.eg|ad\\.jp|hb\\.cn|kyonggi\\.kr|bourse\\.za|org\\.sb|gov\\.gg|net\\.br|mil\\.pe|kobe\\.jp|net\\.sa|edu\\.mt|org\\.vn|yokohama\\.jp|net\\.il|ac\\.cr|edu\\.sb|nagano\\.jp|travel\\.pl|gov\\.tr|com\\.sv|co\\.il|rec\\.br|biz\\.om|com\\.mm|com\\.az|org\\.vu|edu\\.ng|com\\.mx|info\\.co|realestate\\.pl|mil\\.sh|yamagata\\.jp|or\\.id|org\\.ae|greta\\.fr|k12\\.il|com\\.tw|gov\\.ve|arts\\.ve|cul\\.na|gov\\.kh|org\\.bm|etc\\.br|or\\.th|ch\\.vu|de\\.tt|ind\\.je|org\\.tw|nom\\.fr|co\\.tt|net\\.lc|intl\\.tn|shiga\\.jp|pvt\\.ge|gov\\.ua|org\\.pe|net\\.kh|co\\.vi|iwi\\.nz|biz\\.vn|gov\\.ck|edu\\.eg|zj\\.cn|press\\.ma|ac\\.in|eu\\.tt|art\\.do|med\\.ec|bbs\\.tr|gov\\.uk|edu\\.ua|eu\\.com|web\\.do|szex\\.hu|mil\\.kh|gen\\.nz|okinawa\\.jp|mob\\.nr|edu\\.ws|edu\\.sv|xj\\.cn|net\\.ru|dk\\.tt|erotika\\.hu|com\\.sh|cn\\.com|edu\\.pl|com\\.nc|org\\.il|arts\\.co|chirurgiens-dentistes\\.fr|net\\.pa|takamatsu\\.jp|net\\.ng|org\\.hu|net\\.in|net\\.vu|gen\\.tr|shop\\.hu|com\\.ae|tokushima\\.jp|za\\.com|gov\\.eg|co\\.jp|uba\\.ar|net\\.my|biz\\.et|art\\.br|ac\\.fk|gob\\.pe|com\\.bs|co\\.ae|de\\.net|net\\.eg|hyogo\\.jp|edunet\\.tn|museum\\.om|nom\\.ve|rnrt\\.tn|hn\\.cn|com\\.fk|edu\\.dz|ne\\.kr|co\\.je|sch\\.uk|priv\\.pl|sp\\.br|net\\.hk|name\\.vn|com\\.sa|edu\\.bm|qc\\.ca|bolt\\.hu|per\\.kh|sn\\.cn|mil\\.id|kagawa\\.jp|utsunomiya\\.jp|erotica\\.hu|gd\\.cn|net\\.tr|edu\\.np|asn\\.au|com\\.gu|ind\\.tn|mil\\.br|net\\.lb|nom\\.co|org\\.la|mil\\.pl|ac\\.il|gov\\.jo|com\\.kw|edu\\.sh|otc\\.au|gmina\\.pl|per\\.sg|gov\\.mo|int\\.ve|news\\.hu|sec\\.ps|ac\\.pg|health\\.vn|sex\\.pl|net\\.nc|qc\\.com|idv\\.hk|org\\.hk|gok\\.pk|com\\.ac|tochigi\\.jp|gsm\\.pl|law\\.za|pro\\.vn|edu\\.pe|info\\.et|sch\\.gg|com\\.vn|gov\\.bm|com\\.cn|mod\\.uk|gov\\.ps|toyama\\.jp|gv\\.at|yk\\.ca|org\\.et|suli\\.hu|edu\\.my|org\\.mm|co\\.yu|int\\.ar|pe\\.ca|tm\\.hu|net\\.sb|org\\.yu|com\\.ru|com\\.pe|edu\\.kh|edu\\.kw|org\\.qa|med\\.om|net\\.ws|org\\.in|turystyka\\.pl|store\\.ve|org\\.bs|mil\\.uy|net\\.ar|iwate\\.jp|org\\.nc|us\\.tt|gov\\.sh|nom\\.fk|go\\.th|gov\\.ec|com\\.br|edu\\.do|gov\\.ng|pro\\.tt|sapporo\\.jp|net\\.ua|tm\\.fr|com\\.lv|com\\.mo|edu\\.uk|fin\\.ec|edu\\.ps|ru\\.com|edu\\.ec|ac\\.fj|net\\.mm|veterinaire\\.fr|nom\\.re|ingatlan\\.hu|fr\\.vu|ne\\.jp|int\\.co|gov\\.cy|org\\.lv|de\\.com|nagasaki\\.jp|com\\.sb|gov\\.za|org\\.lc|com\\.fj|ind\\.in|or\\.cr|sc\\.cn|chambagri\\.fr|or\\.jp|forum\\.hu|tmp\\.br|reklam\\.hu|gob\\.sv|com\\.pl|saitama\\.jp|name\\.tt|niigata\\.jp|sklep\\.pl|nom\\.ni|co\\.ma|net\\.la|co\\.om|pharmacien\\.fr|port\\.fr|mil\\.gu|au\\.tt|edu\\.gu|ngo\\.ph|com\\.ve|ac\\.th|gov\\.fj|barreau\\.fr|net\\.ac|ac\\.je|org\\.kw|sport\\.hu|ac\\.cn|net\\.bm|ibaraki\\.jp|tel\\.no|org\\.cy|edu\\.mo|gb\\.net|kyoto\\.jp|sch\\.sa|com\\.au|edu\\.lc|fax\\.nr|gov\\.mm|it\\.tt|org\\.jo|nat\\.tn|mil\\.ve|be\\.tt|org\\.az|rec\\.co|co\\.ve|gifu\\.jp|net\\.th|hokkaido\\.jp|ac\\.gg|go\\.kr|edu\\.ye|qh\\.cn|ab\\.ca|org\\.cn|no\\.com|co\\.uk|gov\\.gu|de\\.vu|miasta\\.pl|kawasaki\\.jp|co\\.cr|miyagi\\.jp|org\\.jp|osaka\\.jp|web\\.za|net\\.za|gov\\.pk|gov\\.vn|agrar\\.hu|asn\\.lv|org\\.sv|net\\.sh|org\\.sa|org\\.dz|assedic\\.fr|com\\.sy|net\\.ph|mil\\.ge|es\\.tt|mobile\\.nr|co\\.kr|ltd\\.uk|ac\\.be|fgov\\.be|geek\\.nz|ind\\.gg|net\\.mt|maori\\.nz|ens\\.tn|edu\\.py|gov\\.sd|gov\\.qa|nt\\.ca|com\\.pg|org\\.kh|pc\\.pl|com\\.eg|net\\.ly|se\\.com|gb\\.com|edu\\.ar|sch\\.je|mil\\.ac|mil\\.ar|okayama\\.jp|gov\\.sg|ac\\.id|co\\.id|com\\.ly|huissier-justice\\.fr|nic\\.im|gov\\.lv|nu\\.ca|org\\.sg|com\\.kh|org\\.vi|sa\\.cr|lg\\.jp|ns\\.ca|edu\\.co|gov\\.im|edu\\.om|net\\.dz|org\\.pl|pp\\.ru|tm\\.mt|org\\.ar|co\\.gg|org\\.im|edu\\.qa|org\\.py|edu\\.uy|targi\\.pl|com\\.ge|gub\\.uy|gov\\.ar|ltd\\.gg|fr\\.tt|net\\.qa|com\\.np|ass\\.dz|se\\.tt|com\\.ai|org\\.ma|plo\\.ps|co\\.at|med\\.sa|net\\.sg|kanazawa\\.jp|com\\.fr|school\\.za|net\\.pl|ngo\\.za|net\\.sy|ed\\.jp|org\\.na|net\\.ma|asso\\.fr|police\\.uk|powiat\\.pl|govt\\.nz|sk\\.ca|tj\\.cn|mil\\.ec|com\\.jo|net\\.mo|notaires\\.fr|avoues\\.fr|aeroport\\.fr|yn\\.cn|gov\\.et|gov\\.sa|gov\\.ae|com\\.tt|art\\.dz|firm\\.ve|com\\.sd|school\\.nz|edu\\.et|gob\\.pa|telecom\\.na|ac\\.cy|gz\\.cn|net\\.kw|mobil\\.nr|nic\\.uk|co\\.th|com\\.vu|com\\.re|belgie\\.be|nl\\.ca|uk\\.com|com\\.om|utazas\\.hu|presse\\.fr|co\\.ck|xz\\.cn|org\\.tr|mil\\.co|edu\\.cn|net\\.ec|on\\.ca|konyvelo\\.hu|gop\\.pk|net\\.om|info\\.ve|com\\.ni|sa\\.com|com\\.tr|sch\\.sd|fukushima\\.jp|tel\\.nr|atm\\.pl|kitakyushu\\.jp|com\\.qa|firm\\.co|edu\\.tt|games\\.hu|mil\\.nz|cri\\.nz|net\\.az|org\\.ge|mie\\.jp|net\\.mx|sch\\.ae|nieruchomosci\\.pl|int\\.vn|edu\\.za|com\\.cy|wakayama\\.jp|gov\\.hk|org\\.pa|edu\\.au|gov\\.in|pro\\.om|2000\\.hu|szkola\\.pl|shimane\\.jp|co\\.zw|gove\\.tw|com\\.co|net\\.ck|net\\.pk|net\\.ve|org\\.ru|uk\\.net|org\\.co|uu\\.mt|com\\.cu|mil\\.za|plc\\.uk|lkd\\.co\\.im|gs\\.cn|sex\\.hu|net\\.je|kumamoto\\.jp|mil\\.lb|edu\\.yu|gov\\.ws|sendai\\.jp|eu\\.org|ah\\.cn|net\\.vn|gov\\.sb|net\\.pe|nagoya\\.jp|geometre-expert\\.fr|net\\.fk|biz\\.tt|org\\.sh|edu\\.sa|saga\\.jp|sx\\.cn|org\\.je|org\\.ye|muni\\.il|kochi\\.jp|com\\.bh|org\\.ec|priv\\.at|gov\\.sy|org\\.ni|casino\\.hu|res\\.in|uy\\.com)"
//var tldStr = "\.(?:(?:[a-z0-9]{2}\.)?[a-z0-9]{2,3}|(?:[a-z]+\.)?jp)";
res = tldRes[1] + tldStr + tldRes[3];
}
return res + "$";
}).join('|');
return new RegExp(regstr);
},
_isURLMatching: function(url) {
return !this._disabled &&
this._includeRegExp.test(url) &&
(!this._excludeRegExp ||
!this._excludeRegExp.test(url));
},
_getResource: function() {
var self = this;
if (this._requires.length) {
for (let i = 0, l = this._requires.length; i < l; i++) {
let requireURL = this._requires[i];
let json = this._resourceStorage.getValue(requireURL);
if (json) {
json = JSON.parse(json);
let val = json.bytes;
try {
val = decodeURIComponent(escape(val));
} catch (e) { }
this._requireSrc += val + '\n';
continue;
}
getContents(requireURL, function(bytes, contentType){
var js = {
bytes: bytes,
contentType: contentType
};
js = JSON.stringify(js);
self._resourceStorage.setValue(requireURL, js);
let val = bytes;
try {
val = decodeURIComponent(escape(val));
} catch (e) { }
self._requireSrc += val + '\n';
});
}
}

for (let n in this._resources) {
let resourceURL = this._resources[n];
let json = this._resourceStorage.getValue(resourceURL);
if (json) {
json = JSON.parse(json);
this._resourceValues[n] = json;
continue;
}
getContents(resourceURL, function(bytes, contentType){
let obj = {
bytes: bytes,
contentType: contentType
};
let json = JSON.stringify(obj);
self._resourceStorage.setValue(resourceURL, json);
self._resourceValues[n] = obj;
});
}
}
};

function Console() {}
Console.prototype = {
log: function(str){ Application.console.log(str); },
time: function(name) { this['_' + name] = new Date().getTime(); },
timeEnd: function(name) {
if (typeof this['_' + name] == 'undefined')
return this.log('timeEnd: Error' + name);
this.log(name + ':' + (new Date().getTime() - this['_' + name]));
delete this['_' + name];
},
};

["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]
.forEach(function(name){
if (name in this) return;
this[name] = function(){};
}, Console.prototype);

function getContents(aURL, callback){
try{
urlSecurityCheck(aURL, gBrowser.contentPrincipal,Ci.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
}catch(ex){
return;
}

var ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);

var channel = ioService.newChannel(aURL,null,null);
if (channel.URI.scheme != 'http' && channel.URI.scheme != 'https')
return error('getContents is "http" or "https" only');

var listener = {
data: "",
onStartRequest: function (request, context) {
this.data = "";
},
onDataAvailable: function (request, context, inputStream, offset, count) {
var bs = Cc["@mozilla.org/binaryinputstream;1"].createInstance(Ci.nsIBinaryInputStream);
bs.setInputStream(inputStream);
var n = bs.available();
var bytes = bs.readBytes(n);
this.data += bytes;
bs.close();
},
onStopRequest: function (request, context, statusCode) {
if (Components.isSuccessCode(statusCode)) {
this.callback.apply(this, [this.data, channel.contentType]);
} else {

}
},
callback: callback
};
channel.asyncOpen(listener, null);
debug("getContents: " + aURL);
}

function GM_addStyle(code, doc) {
var head = doc.getElementsByTagName('head')[0];
if (head) {
var style = doc.createElement('style');
style.type = 'text/css';
style.appendChild(doc.createTextNode(code));
head.appendChild(style);
return style;
}
}

function GM_xmlhttpRequest(obj) {
if(typeof(obj) != 'object' || (typeof(obj.url) != 'string' && !(obj.url instanceof String))) return;

var req = new XMLHttpRequest();
req.open(obj.method || 'GET',obj.url,true);
if(typeof(obj.headers) == 'object') for(var i in obj.headers) req.setRequestHeader(i,obj.headers[i]);
['onload','onerror','onreadystatechange'].forEach(function(k) {
if(obj[k] && (typeof(obj[k]) == 'function' || obj[k] instanceof Function)) req[k] = function() {
obj[k]({
status : (req.readyState == 4) ? req.status : 0,
statusText : (req.readyState == 4) ? req.statusText : '',
responseHeaders : (req.readyState == 4) ? req.getAllResponseHeaders() : '',
responseText : req.responseText,
readyState : req.readyState,
finalUrl : (req.readyState == 4) ? req.channel.URI.spec : '' });
};
});

if(obj.overrideMimeType) req.overrideMimeType(obj.overrideMimeType);
var c = 0;
var timer = setInterval(function() { if(req.readyState == 1 || ++c > 100) { clearInterval(timer); req.send(obj.data || null); } },10);
debug('GM_xmlhttpRequest ' + obj.url);
}

function log(str) { Application.console.log(str); }

function debug() { if (ns.DEBUG) Application.console.log('DEBUG: ' + Array.slice(arguments));}

function error(str) {
var consoleSvc = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService);
var err = Cc["@mozilla.org/scripterror;1"].createInstance(Ci.nsIScriptError);
err.init(str, null, null, null, null, err.errorFlag, null);
consoleSvc.logMessage(err);
}

// http://gist.github.com/321205
function $(id) document.getElementById(id);
function $E(xml, doc) {
doc = doc || document;
xml = <root xmlns={doc.documentElement.namespaceURI}/>.appendChild(xml);
var settings = XML.settings();
XML.prettyPrinting = false;
var root = new DOMParser().parseFromString(xml.toXMLString(), 'application/xml').documentElement;
XML.setSettings(settings);
doc.adoptNode(root);
var range = doc.createRange();
range.selectNodeContents(root);
var frag = range.extractContents();
range.detach();
return frag.childNodes.length < 2 ? frag.firstChild : frag;
}

(function(){
const currentRevision = 1.1;
const namespace = 'GrieverWindowStore';

if (namespace in window && window[namespace].version >= currentRevision) return;

var fxver = parseFloat(Cc['@mozilla.org/xre/app-info;1'].getService(Ci.nsIXULAppInfo).version);
var table = [];
var data = [];

window[namespace] = fxver >= 4? {
version: currentRevision,
get table() table,
get data() data,
getId: function(obj) {
if (!obj || obj instanceof Window === false) return -1;
try {
return obj
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils)
.currentInnerWindowID;
} catch(e) {
Cu.reportError(e);
}
return -1;
},
indexOf: function(id) {
return table.indexOf(id);
},
get: function(obj){
if (obj instanceof Window === false) return null;
var id = this.getId(obj);
var index = this.indexOf(id);
if (index >= 0) return data[index];

var url = obj.location.href;
var dataObj = { toString: function() url, id: id };
table.push(id);
data.push(dataObj);
obj.addEventListener('pagehide', this, false);
return dataObj;
},
delete: function(obj){
if (obj instanceof Window === false) return false;
var id = this.getId(obj);
var index = this.indexOf(id);
if (index == -1) return false;

table.splice(index, 1);
data.splice(index, 1);
return true;
},
handleEvent: function(event) {
switch (event.type) {
case 'pagehide':
event.currentTarget.removeEventListener('pagehide', this, false);
this.delete(event.currentTarget);
break;
}
},
} : {
version: currentRevision,
get table() table,
get data() data,
indexOf: function(obj) {
if (!(obj instanceof Window)) return -1;
var id = -1;
table.some(function(e, i, a) e == obj? (id = i, true) : false);
return id;
},
get: function(obj){
if (!(obj instanceof Window)) return null;
var id = this.indexOf(obj);
if (id >= 0) return data[id];
var url = obj.location.href;
var dataObj = { toString: function() url };
table.push(obj);
data.push(dataObj);
obj.addEventListener('pagehide', this, false);
return dataObj;
},
delete: function(obj){
if (!(obj instanceof Window)) return false;
var id = this.indexOf(obj);
if (id == -1) return false;
table.splice(id, 1);
data.splice(id, 1);
return true;
},
handleEvent: function(event) {
switch (event.type) {
case 'pagehide':
event.currentTarget.removeEventListener('pagehide', this, false);
this.delete(event.currentTarget);
break;
}
},
}
})();

return ns;

})();

window.UserScriptLoader.init();


Использование: положите код в любую Custom Buttons кнопку, в инициализацию. Не обязательно создавать новую CB кнопку, можно использовать уже существующую.
                    Отредактировано bunda1 (12-12-2011 19:26:48)

Некорректно отрабатывает Virtual Keyboard Interface for Greasemonkeyhttp://userscripts.org/scripts/show/10974

Отредактировано SendInfo (04-02-2012 18:37:47)

Отсутствует

 

№359204-02-2012 20:48:08

questman
Участник
 
Группа: Members
Зарегистрирован: 05-11-2011
Сообщений: 241
UA: Firefox 10.0

Re: Custom Buttons

Доброго времени суток всем!!!
Статью о стиле писании изучил.Дом инспектором и кнопкой Атрибут Инспектор вроде научился пользоваться.
Но вот что пока не могу понять  как создать кнопки которые бы запускали ту или иную функцию в браузере.
Например было бы удобно иметь кнопку перед глазами которая запускает "Инспектор".
И вообще откуда брать название таких элементов.
Мне легко далось понять как создать кнопки которые открывают about:plugins,  about:config, Error Console и так далее.
А вот где найти "Инспектор" не знаю.
Может кто намекнёт,буду благодарен.

Отсутствует

 

№359304-02-2012 21:09:36

Ste_pan
Участник
 
Группа: Members
Откуда: приморский край п.сибирцево
Зарегистрирован: 13-02-2011
Сообщений: 63
UA: Firefox 7.0

Re: Custom Buttons

SendInfo пишет

В кнопке имеется баг

уже нет

скрытый текст

Выделить код

Код:

var s=Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
var pref=Application.prefs.get("lightweightThemes.isThemeSelected")
if(!(pref)){
    s.setCharPref('lightweightThemes.isThemeSelected',false)
    s.setCharPref('lightweightThemes.isThemeSelected',true)}
else{
    pref.events.addListener("change", function() {s.setBoolPref('lightweightThemes.isThemeSelected', true)})};
var val = this. getAttribute ("id"); 
var s=Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
Components.utils.import("resource://gre/modules/LightweightThemeManager.jsm"); 
this. x= function ()
    {
        var groupbox=
        <tabbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
        <tabs>
            <tab label="add-ons" image="11"/>
            <tab label="themes" image="11"/>
            <tab label="styles" image="11"/>
            <tab label="personas" image="11"/>
        </tabs>
        <tabpanels>
            <tabpanel class="add_on">
                <vbox class="add_on" hidden="false">
                    <hbox hidden="false">
                        <label value="Enable" onclick="var  style_=&quot;color:#000000;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#000000;&quot;&#xA;var style_sel ='color:#FF6600;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#6633FF'&#xA;var Node=this.parentNode.childNodes;&#xA;for (var i = 0; i &lt;3; i++)&#xA;&#x9;&#x9;{&#xA;&#x9;&#x9;&#x9;&#xA;Node[i]. setAttribute (&quot;style&quot;, style_)&#xA;&#x9;&#x9;};&#xA;this.setAttribute (&quot;style&quot;,style_sel)&#xA;var Node=this.parentNode.nextSibling .childNodes;&#xA;for (var i = 0; i &lt;3; i++)&#xA;&#x9;&#x9;{&#xA;&#x9;&#x9;&#xA;if(Node[i].className ==this.className){&#xA;&#x9;&#x9;&#x9;&#x9;Node[i].hidden=false}&#xA;&#x9;&#x9;&#x9;else{&#xA;&#x9;&#x9;&#x9;&#x9;Node[i].hidden=true}&#xA;&#x9;&#x9;};&#xA;&#x9;&#x9;&#xA;" class="Enable_"/>
                        <label value="Disable" onclick="var  style_=&quot;color:#000000;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#000000;&quot;&#xA;var style_sel ='color:#FF6600;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#6633FF'&#xA;var Node=this.parentNode.childNodes;&#xA;for (var i = 0; i &lt;3; i++)&#xA;&#x9;&#x9;{&#xA;&#x9;&#x9;&#x9;&#xA;Node[i]. setAttribute (&quot;style&quot;, style_)&#xA;&#x9;&#x9;};&#xA;this.setAttribute (&quot;style&quot;,style_sel)&#xA;var Node=this.parentNode.nextSibling .childNodes;&#xA;for (var i = 0; i &lt;3; i++)&#xA;&#x9;&#x9;{&#xA;&#x9;&#x9;&#xA;if(Node[i].className ==this.className){&#xA;&#x9;&#x9;&#x9;&#x9;Node[i].hidden=false}&#xA;&#x9;&#x9;&#x9;else{&#xA;&#x9;&#x9;&#x9;&#x9;Node[i].hidden=true}&#xA;&#x9;&#x9;};&#xA;&#x9;&#x9;&#xA;" class="Disable_"/>
                        <label value="False" onclick="var  style_=&quot;color:#000000;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#000000;&quot;&#xA;var style_sel ='color:#FF6600;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#6633FF'&#xA;var Node=this.parentNode.childNodes;&#xA;for (var i = 0; i &lt;3; i++)&#xA;&#x9;&#x9;{&#xA;&#x9;&#x9;&#x9;&#xA;Node[i]. setAttribute (&quot;style&quot;, style_)&#xA;&#x9;&#x9;};&#xA;this.setAttribute (&quot;style&quot;,style_sel)&#xA;var Node=this.parentNode.nextSibling .childNodes;&#xA;for (var i = 0; i &lt;3; i++)&#xA;&#x9;&#x9;{&#xA;&#x9;&#x9;&#xA;if(Node[i].className ==this.className){&#xA;&#x9;&#x9;&#x9;&#x9;Node[i].hidden=false}&#xA;&#x9;&#x9;&#x9;else{&#xA;&#x9;&#x9;&#x9;&#x9;Node[i].hidden=true}&#xA;&#x9;&#x9;};&#xA;&#x9;&#x9;&#xA;" class="False_"/>
                    </hbox>
                    <box>
                        <vbox class="Enable_" hidden="false"/>
                        <vbox class="Disable_" hidden="true"/>
                        <vbox hidden="true" class="False_"/>
                    </box>
                </vbox>
            </tabpanel>
            <tabpanel class="theme_"/>
            <tabpanel class="styles_">
                <vbox>
                    <vbox class="st_e"/>
                    <menuseparator/>
                    <vbox class="st_d"/>
                </vbox>
            </tabpanel>
            <tabpanel class="pesonas_"/>
        </tabpanels>
    </tabbox>
    groupbox =  cbu. makeXML(groupbox);
    
    return groupbox
    }
this. xulFav = function ()
    {
        var groupbox=
        
        <vbox onmouseout="this.firstChild.nextSibling.hidden=true" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
            <vbox onmouseover="this.nextSibling.hidden=false">
                <menuitem label="hjgjghjghj" class="menuitem-iconic bookmark-item"/>
            </vbox>
            <hbox hidden="true" onblur="this.hidden=true" onmouseup="this.hidden=true" onmouseover="this.hidden=false">
                <button label="Preview" orient="horizontal" onmouseover="this.parentNode.hidden=false" image="11"/>
                <button label="del" onmouseover="this.parentNode.hidden=false" image="11"/>
                <button label="-" onmouseover="this.parentNode.hidden=false" image="11"/>
            </hbox>
        </vbox>
    
    
    groupbox =  cbu. makeXML(groupbox);
    
    return groupbox
    }
this. xulFavSel = function ()
    {
        var groupbox=
        
        <vbox onmouseout="this.firstChild.nextSibling.hidden=true" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
            <vbox onmouseover="this.nextSibling.hidden=false">
                <menuitem label="hjgjghjghj" class="menuitem-iconic bookmark-item"/>
            </vbox>
            <hbox hidden="true" onblur="this.hidden=true" onmouseup="this.hidden=true" onmouseover="this.hidden=false">
                <button label="del" onmouseover="this.parentNode.hidden=false" image="11"/>
            </hbox>
        </vbox>
        

    groupbox =  cbu. makeXML(groupbox);
    
    return groupbox
    }

this. xul_ = function ()
    {
        var groupbox=
        
        <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onmouseout="this.firstChild.nextSibling.hidden=true" class="parent_">
        
        <vbox onmouseover="this.nextSibling.hidden=false">
            <menuitem label="hjgjghjghj" class="menuitem-iconic bookmark-item"/>
        </vbox>
        <hbox hidden="true" onblur="this.hidden=true" onmouseup="this.hidden=true" onmouseover="this.hidden=false">
            <button label="Preview" orient="horizontal" onmouseover="this.parentNode.hidden=false" image="11"/>
            <button label="del" onmouseover="this.parentNode.hidden=false" image="11"/>
            <button label="+" onmouseover="this.parentNode.hidden=false" image="11"/>
        </hbox>
    </vbox>
    
    groupbox = cbu. makeXML (groupbox);
    
    return groupbox
    }


this. xul_ex= function ()
    {
        var groupbox=
        
        <vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" onmouseout="this.firstChild.nextSibling.hidden=true" class="parent_">
        
        <vbox onmouseover="this.nextSibling.hidden=false">
            <menuitem label="hjgjghjghj" class="menuitem-iconic bookmark-item"/>
        </vbox>
        <hbox hidden="true"   onmouseover="this.hidden=false">
            <button label="on/of" orient="horizontal" onmouseover="this.parentNode.hidden=false" image="11"/>
            <button label="del" onmouseover="this.parentNode.hidden=false" image="11"/>
            <button label="open" onmouseover="this.parentNode.hidden=false" image="11"/>
            <button label="update" image="11"/>
        </hbox>
    </vbox>
    
    groupbox = cbu. makeXML (groupbox);
    
    return groupbox
    }
    
var menupopup= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menupopup");

if(s.getChildList('').indexOf('LightweightThemeManager.Favorites_')==-1)
    {
        
        s.setCharPref('LightweightThemeManager.Favorites_','')
    }
var fav=s.getCharPref('LightweightThemeManager.Favorites_');
var arr = LightweightThemeManager.usedThemes;
    if(!(LightweightThemeManager.currentTheme))
        {
            var currentTheme=0
        }
    else
        {
            var currentTheme=LightweightThemeManager.currentTheme.id
            
        }
    var groupbox= 
    <groupbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
        <caption label="Favorites" image="11"/>
    </groupbox>
    groupbox =  cbu. makeXML(groupbox);
    var box_= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "vbox");    
    var box_sel= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "vbox");
    for (var i = 0; i < arr.length; i++)
    {
        arr. sort
                    (
                    function (a, b, c, d)
                        {
                            return a.name. toLowerCase ()  > b.name. toLowerCase ();
                        }
                    );
        if(!(fav==''))
            {
                var fl=0
                var data=fav.split(',')
                for (var j = 0; j < data.length; j++)
                {
                        if(data[j]==arr[i].id)
                        {    
                            if(currentTheme==arr[i].id)
                                {
                                    var xul=this. xulFavSel()
                                    var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                    menuItem. setAttribute ("src",arr[i]. iconURL);
                                    menuItem. setAttribute ("label",arr[i]. name);
                                    menuItem. setAttribute ("id",arr[i]. id);
                                    var b_= xul. getElementsByTagName ("button") [0];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)');
                                    box_sel.appendChild (xul);
                                    fl=1
                                }
                            else
                                {
                                    var xul=this. xulFav()
                                    var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                    menuItem. setAttribute ("src",arr[i]. iconURL);
                                    menuItem. setAttribute ("label",arr[i]. name);
                                    menuItem. setAttribute ("id",arr[i]. id);
                                    menuItem.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa._Changed(event)');
                                    var b_= xul. getElementsByTagName ("button") [0];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.Preview(event)');
                                    var b_= xul. getElementsByTagName ("button") [1];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)');
                                    var b_= xul. getElementsByTagName ("button") [2];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.favDel(event)');
                                    groupbox.appendChild (xul);
                                    fl=1
                                }
                        }
                }
                if(fl==0)
                    {
                        switch (arr[i].id)
                        {    
                            case currentTheme:
                                var xul=this. xulFavSel()
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("src",arr[i]. iconURL);
                                menuItem. setAttribute ("label",arr[i]. name);
                                menuItem. setAttribute ("id",arr[i]. id);
                                var b_= xul. getElementsByTagName ("button") [0];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)');
                                box_sel.appendChild (xul);
                            break;
                            default:
                                var xul=this. xul_()
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("src",arr[i]. iconURL);
                                menuItem. setAttribute ("label",arr[i]. name);
                                menuItem. setAttribute ("id",arr[i]. id);
                                menuItem.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa._Changed(event)');
                                var b_= xul. getElementsByTagName ("button") [2];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.favADD(event)');
                                var b_= xul. getElementsByTagName ("button") [1];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)')
                                var b_= xul. getElementsByTagName ("button") [0];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.Preview(event)');
                                box_.appendChild (xul);
                            break;
                        }
                    }
            }
        else
            {
                switch (arr[i].id)
                        {    
                            case currentTheme:
                                var xul=this. xulFavSel()
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("src",arr[i]. iconURL);
                                menuItem. setAttribute ("label",arr[i]. name);
                                menuItem. setAttribute ("id",arr[i]. id);
                                var b_= xul. getElementsByTagName ("button") [0];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)');
                                box_sel.appendChild (xul);
                            break;
                            default:
                                var xul=this. xul_()
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("src",arr[i]. iconURL);
                                menuItem. setAttribute ("label",arr[i]. name);
                                menuItem. setAttribute ("id",arr[i]. id);
                                var b_= xul. getElementsByTagName ("button") [2];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.favADD(event)');
                                var b_= xul. getElementsByTagName ("button") [1];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)');
                                var b_= xul. getElementsByTagName ("button") [0];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.Preview(event)');
                                box_.appendChild (xul);
                            break;
                        }
            }    
    }
var box_0=    this. x()
var boxx=    box_0.getElementsByClassName ("pesonas_")[0]
boxx.orient = "vertical";
    if(groupbox.childNodes.length==0||box_sel.childNodes.length==0)
        {
            boxx.appendChild (box_);
        }
    else
        {
            groupbox.insertBefore(box_sel, groupbox.firstChild)
            box_sel.appendChild(document.createElement("menuseparator"));
            boxx.appendChild (groupbox);
            boxx.appendChild(document.createElement("menuseparator"));
            boxx.appendChild (box_);
        }
        
        
this. favDel= function (event)
    {
        
        
        var id= event. originalTarget.parentNode.previousSibling.firstChild.id;
        
        var node_vbox= event. originalTarget.parentNode.parentNode.parentNode.parentNode 
        var fav=s.getCharPref('LightweightThemeManager.Favorites_');
        var f=fav.indexOf(id)
        var n=fav.slice(0,f)
        var k=fav.slice(id.length+f)
        var n=n.slice(0,-1)
        if(n==0)
            {
                var k=k.slice(1)
            }
            
        var res=n+k
        s.setCharPref('LightweightThemeManager.Favorites_',res)
        el=event. originalTarget.parentNode.parentNode
        var Theme=LightweightThemeManager.getUsedTheme(id)
        var xul=this. xul_()
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("src",Theme. iconURL);
                                menuItem. setAttribute ("label",Theme. name);
                                menuItem. setAttribute ("id",Theme. id);
                                var b_= xul. getElementsByTagName ("button") [2];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.favADD(event)');
                                var b_= xul. getElementsByTagName ("button") [1];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)')
                                var b_= xul. getElementsByTagName ("button") [0];
                                b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.Preview(event)');
                                el. parentNode. removeChild (el);
        node_vbox.appendChild (xul);
    }
    
this. favADD= function (event)
    {
        
        var node_grup= event. originalTarget.parentNode.parentNode.parentNode.parentNode.firstChild
        var id= event. originalTarget.parentNode.previousSibling.firstChild.id;
        var fav=s.getCharPref('LightweightThemeManager.Favorites_');
        var res=fav+','+id
        s.setCharPref('LightweightThemeManager.Favorites_',res)
        el=event. originalTarget.parentNode.parentNode
        var Theme=LightweightThemeManager.getUsedTheme(id)
        var xul=this. xulFav()
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("src",Theme. iconURL);
                                menuItem. setAttribute ("label",Theme. name);
                                menuItem. setAttribute ("id",Theme. id);
                                var b_= xul. getElementsByTagName ("button") [0];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.Preview(event)');
                                    var b_= xul. getElementsByTagName ("button") [1];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.unst(event)');
                                    var b_= xul. getElementsByTagName ("button") [2];
                                    b_.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.favDel(event)');
        el. parentNode. removeChild (el);
        node_grup.appendChild (xul);
    }
this. unst= function (event)
    {
        var id= event. originalTarget.parentNode.previousSibling.firstChild.id;
        el=event. originalTarget.parentNode.parentNode
        if(!(el. hasAttribute ("class")))
            el=event. originalTarget.parentNode.parentNode.parentNode
        var Theme=LightweightThemeManager.getUsedTheme(id)
        
        Components.utils.import("resource://gre/modules/AddonManager.jsm");
        AddonManager.getAddonsByTypes(["theme"], function(addons) {
        for(var i = 0, l = addons.length; i < l; i++)
        {
            if(addons[i].id == id+'@personas.mozilla.org') 
                {
                    el. parentNode. removeChild (el);
                    addons[i].uninstall();
                }
        }
        });
    }            
this. Preview= function (event)
    {
        var id= event. originalTarget.parentNode.previousSibling.firstChild.id;
        var Theme=LightweightThemeManager.getUsedTheme(id)
        LightweightThemeManager.previewTheme(Theme)
    }
this. _Changed= function (event)
    {
        var int_=Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
        var id= event. originalTarget.id;
        var Theme=LightweightThemeManager.getUsedTheme(id)
        int_.setCharPref('lightweightThemes.isThemeSelected','')
        LightweightThemeManager.themeChanged(Theme)
        
        Components.utils.import("resource://gre/modules/AddonManager.jsm");
        AddonManager.getAddonsByTypes(["theme"], function(addons) {
        for(var i = 0, l = addons.length; i < l; i++)
        {
            if(addons[i].isActive  == true) 
                {
                    if(!(addons[i].id.slice(addons[i].id.length-21)=='@personas.mozilla.org'))
                        {
                            var res=addons[i]
                            var res0=addons[i].id
                            var THIS=this
                            AddonManager.addAddonListener({ onDisabled: function(res) 
                                {
                                    AddonManager.getAddonByID(res0,function(a) 
                                        {
                                            a.userDisabled=false
                                            Services.obs.notifyObservers(null, "lightweight-theme-styling-update",JSON.stringify(Theme));
                                            AddonManager.removeAddonListener({ onDisabled: function(a){}})
                                        })
                                }})
                            
                            res.userDisabled=false
                        }
                
                }
                
                
        }
        
        });
    
    }    
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var iconURL='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACV0lEQVR4Xi3OT2ibZQDH8c/7msT1pZqOtlQ32ulaGJVuB0UvMiyRCbZCT14MHUIzcaCCFcZAGOiKIB3UkyCeBBU86EGYiPZanTIZwnTWScdqbdM/U/vHN1mS5jGHHD637w9+TOM1vKrTtPe8419z7njflrmWt2yb9ocpE0p4CaW2KTjVdtKgkqsnloZCMYyHQjgeHguD4YndoeBDwagZpzCKsfbmNIzjZZxF0aiS+Qd/TUJvRRjYzQcf2DPhotP6TOBJTOE5FIlVPG/NZEvRpq6Wpcp/dR1RXlcmz5pUasWOUalJDQ+3AOC83aGb/SF7TfCdMHCzJ5zYHwjKghXhwC1NXwvmBbOCgheVMI4iGSOas0MXXfWTdWU/WnBjc5kKUqpZkUGibkIFC1IdetSdwZXInB3HJS7bUNR3aCQbr67VaeAuKthGNxbxhVcccNiw8275LbZgw+dm/OUFn/h5falODjVUUUeEHfQKjrhg0OueEunUH3nGfY7akwjWvWnSjEdxG3U0UEOKCAnu4l58605Gzq4EOWRsqLWDFI22/bY6AlJ0ATHOCR6XlcgogCruRx6dgDo6BGvYQQY1cazfu3p9atUlxxT0YxnXcQ2/o4I8yvjSx+ZdsYI9ucjbNj2rx3UMY9O+ryy67bKGX3R42hEnjXnIIr4xJvE3LuH7WCqSw1HUsOAfq96QdU63j+SdUTbrBhLUHJTzg7Ki4ELsHhlNVJHBiIMOOatTnwSRYYeVHEMT2n3WMqoZizZ8pmm/BWKxLQXbHlCxjkfUDGs98yeqUluoAf8DkrzrAnZsWyMAAAAASUVORK5CYII='        
Components.utils.import("resource://gre/modules/AddonManager.jsm");
var box_enable= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "groupbox");
var box_disable= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "groupbox");
var box_false= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "groupbox");
var THIS=this
AddonManager. getAddonsByTypes
(
        ["extension"],
        function (extensions)
        {
            var arr_enable = new Array();
            var arr_disable = new Array();
            var arr_false = new Array();
            var e=extensions
            for (var i = 0; i < extensions. length; i++)
                {
                    
                    if(e[i].userDisabled==true)
                        {
                            arr_disable.push(e[i])
                        }
                    else
                        {
                            arr_enable.push(e[i])
                        }
                    if(e[i].appDisabled==true)
                        {
                            arr_false.push(e[i])
                        }    
                }
            if(!(arr_disable.length==0))
                {
                    arr_disable. sort
                    (
                    function (a, b, c, d)
                        {
                            return a.name. toLowerCase ()  > b.name. toLowerCase ();
                        }
                    );
                }    
            if(!(arr_enable.length==0))
                {
                    arr_enable. sort
                    (
                    function (a, b, c, d)
                        {
                            return a.name. toLowerCase ()  > b.name. toLowerCase ();
                        }
                    );
                }    
            if(!(box_false.length==0))
                {
                    arr_enable. sort
                    (
                    function (a, b, c, d)
                        {
                            return a.name. toLowerCase ()  > b.name. toLowerCase ();
                        }
                    );
                }        
            var sub_box=    box_0.getElementsByClassName ("add_on")[0]
            
            var Node=sub_box.firstChild.firstChild .firstChild ;
            var boxx=    box_0.getElementsByClassName ("Enable_")[1]    
            var boxx2=    box_0.getElementsByClassName ("Disable_")[1]    
            var boxx3=    box_0.getElementsByClassName ("False_")[1]    
            Node.setAttribute("value",Node.getAttribute("value")+'/'+arr_enable. length)
            Node.setAttribute("style",'color:#FF6600;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#6633FF;')
            Node.nextSibling .setAttribute("value",Node.nextSibling .getAttribute("value")+'/'+arr_disable. length)
            Node.nextSibling .setAttribute("style",'font-family:monospace;border-bottom-color:#000000;border-bottom-style:solid;border-bottom-width:1px;')
            Node.nextSibling .nextSibling.setAttribute("value",Node.nextSibling .nextSibling.getAttribute("value")+'/'+arr_false. length)
            Node.nextSibling .nextSibling.setAttribute("style",'font-family:monospace;border-bottom-color:#000000;border-bottom-style:solid;border-bottom-width:1px;')
            for (var i = 0; i < arr_enable. length; i++)
            {
                var xul=THIS. xul_ex()
                var b_=xul.lastChild
                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                menuItem. setAttribute ("src",arr_enable[i]. iconURL);
                menuItem. setAttribute ("label",arr_enable[i]. name);
                menuItem. setAttribute ("id_",arr_enable[i]. id);
                b_.firstChild.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="Disabled_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.open_(event)');
                b_.firstChild.nextSibling.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.but_u(event)');
                if (arr_enable[i]. iconURL)
                    {                        
                       menuItem. setAttribute ("src",arr_enable[i]. iconURL);
                    }
                else
                    {
                        menuItem. setAttribute ("src",iconURL);
                    }
                if (arr_enable[i]. optionsURL)
                    menuItem.setAttribute('oncommand', "window. openDialog ('" + arr_enable[i]. optionsURL + "', '', 'chrome,dialog=0,resizable,titlebar,toolbar,centerscreen');");
                 boxx. appendChild (xul)
            }
            for (var i = 0; i < arr_disable. length; i++)
            {
                var xul=THIS.xul_ex()
                var b_=xul.lastChild
                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                menuItem. setAttribute ("label",arr_disable[i]. name);
                menuItem. setAttribute ("id_",arr_disable[i]. id);
                b_.firstChild.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="Disabled_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.open_(event)');
                b_.firstChild.nextSibling.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.but_u(event)');
                if (arr_disable[i]. iconURL)
                    {                        
                       menuItem. setAttribute ("src",arr_disable[i]. iconURL);
                    }
                else
                    {
                        menuItem. setAttribute ("src",iconURL);
                    }
                if (arr_disable[i]. optionsURL)
                    menuItem.setAttribute('oncommand', "window. openDialog ('" + arr_disable[i]. optionsURL + "', '', 'chrome,dialog=0,resizable,titlebar,toolbar,centerscreen');");
                 boxx2. appendChild (xul)
            }
            for (var i = 0; i < arr_false. length; i++)
            {
                var xul=THIS. xul_ex()
                var b_=xul.lastChild
                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                menuItem. setAttribute ("label",arr_false[0]. name);
                menuItem. setAttribute ("id_",arr_false[0]. id);
                b_.firstChild.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="Disabled_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.open_(event)');
                b_.firstChild.nextSibling.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.but_u(event)');
                if (arr_false[i]. iconURL)
                    {                        
                       menuItem. setAttribute ("src",arr_false[i]. iconURL);
                    }
                else
                    {
                        menuItem. setAttribute ("src",iconURL);
                    }
                boxx3. appendChild (xul)
            }
        }
    )    
 
this. but_=function (event,class_) 
{
    var id= event. originalTarget.parentNode.previousSibling.firstChild. getAttribute ("id_")
    Components.utils.import("resource://gre/modules/AddonManager.jsm");
    AddonManager.getAllAddons
    (
        function(addons) 
            {                    
                for (var i = 0; i < addons. length; i++)
                {
                    if(addons[i].id==id)
                        {
                            if(class_=='Disabled_')
                                {
                                    
                                    addons[i].userDisabled = !addons[i].userDisabled;
                                }
                            if(class_=='_')
                                {
                                    addons[i].uninstall();
                                }
                            if(class_=='st_')
                                {
                                    window. openDialog ('chrome://stylish/content/edit.xul', addons[i].name, 'chrome,dialog=0,resizable,titlebar,toolbar,centerscreen;',addons[i])
                                }    
                        }
                    }            
                }
            );    
}

this.open_=function(event){
var id= event. originalTarget.parentNode.previousSibling.firstChild. getAttribute ("id_")
var file = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).
    get("ProfD", Components.interfaces.nsIFile);
file.append("extensions");
file.append(id);
var tr=file.exists()
if(tr==true)
    {
        let nsLocalFile = Components.Constructor("@mozilla.org/file/local;1",
                                           "nsILocalFile", "initWithPath");                                           
        new nsLocalFile(file.path).reveal();
    }
else
    {
        var id=id+'.xpi'
        var file = Components.classes["@mozilla.org/file/directory_service;1"].
            getService(Components.interfaces.nsIProperties).
            get("ProfD", Components.interfaces.nsIFile);
        file.append("extensions");
        file.append(id);
        var local = Components.classes["@mozilla.org/file/local;1"].
            createInstance(Components.interfaces.nsILocalFile);
        var process = Components.classes["@mozilla.org/process/util;1"].
            createInstance(Components.interfaces.nsIProcess);
        var args = [file.path]
        local.initWithPath("e:\\pro\\WinRAR\\WinRAR.exe");
        process.init(local);
        process.run(false, args, args.length);
    }}

 

var boxx=    box_0.getElementsByClassName ("theme_")[0]
AddonManager. getAddonsByTypes
(
        ["theme"],
        function (addons)
        {
            addons. sort
                    (
                    function (a, b, c, d)
                        {
                            return a.name. toLowerCase ()  > b.name. toLowerCase ();
                        }
                    );
            
            var box_on= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "vbox");
            var box_of= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "vbox");
            var box_sel= document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "vbox");
            for (var i = 0; i < addons. length; i++)
                {
                    if(!(addons[i].id.slice(addons[i].id.length-21)=='@personas.mozilla.org'))
                        {
                            
                            if(addons[i].id=='{972ce4c6-7e08-4474-a285-3208198ce6fd}')
                                {
                                    var xul=THIS. xulFavSel()
                                    var b_=xul.lastChild
                                    var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                    menuItem. setAttribute ("label",addons[i]. name);
                                    menuItem. setAttribute ("id_",addons[i]. id);
                                    b_.firstChild.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="Disabled_";tqa.but_(event,class_)');
                                    b_.firstChild.setAttribute('label','on/of')
                                    if (addons[i]. iconURL)
                                        {                        
                                            menuItem. setAttribute ("src",addons[i]. iconURL);
                                        }
                                    else
                                        {
                                            menuItem. setAttribute ("src",iconURL);
                                        }
                                    if(addons[i].isActive)
                                    {
                                        box_sel. appendChild (xul)
                                        box_sel. appendChild (document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuseparator"))
                                    }    
                                    else
                                    {
                                        if (addons[i].appDisabled==true)
                                        {                        
                                            menuItem.setAttribute("disabled","true")
                                            box_of. appendChild (xul)    
                                        }
                                        if (addons[i].appDisabled==false)
                                        {
                                            box_on. appendChild (xul)    
                                        }    
                                    }
                                }
                            else
                            {
                                var xul=THIS. xul_ex()
                                var b_=xul.lastChild
                                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                                menuItem. setAttribute ("label",addons[i]. name);
                                menuItem. setAttribute ("id_",addons[i]. id);
                                b_.firstChild.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="Disabled_";tqa.but_(event,class_)');
                                b_.firstChild.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="_";tqa.but_(event,class_)');
                                b_.firstChild.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.open_(event)');                
                                b_.firstChild.nextSibling.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.but_u(event)');
                                if (addons[i]. iconURL)
                                {                        
                                    menuItem. setAttribute ("src",addons[i]. iconURL);
                                }
                                else
                                {
                                    menuItem. setAttribute ("src",iconURL);
                                }
                                
                                if(addons[i].isActive)
                                    {
                                        box_sel. appendChild (xul)
                                        box_sel. appendChild (document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuseparator"))
                                    }    
                                    else
                                    {
                                        if (addons[i].appDisabled==true)
                                        {                        
                                            menuItem.setAttribute("disabled","true")
                                            box_of. appendChild (xul)    
                                        }
                                        if (addons[i].appDisabled==false)
                                        {
                                            box_on. appendChild (xul)    
                                        }    
                                    }
                            }
                                    
                        }
                
                }
            boxx.orient = "vertical";
            boxx. appendChild (box_sel)
            boxx. appendChild (box_on)
            if(box_of.childNodes.length>0)
            {
                boxx. appendChild (document.createElementNS ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "menuseparator"));
                boxx. appendChild (box_of)    
            }
            
        }
)    



            

var st_e=    box_0.getElementsByClassName ("st_e")[0]
var st_d=    box_0.getElementsByClassName ("st_d")[0]
var st_d_arr=new Array();
var st_e_arr=new Array();    
AddonManager. getAddonsByTypes
(
        ["userstyle"],
        function (addons)
        {
            
            
            for (var i = 0; i < addons. length; i++)
            {
                var xul=THIS.  xul_ex()
                var b_=xul.lastChild
                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                menuItem. setAttribute ("src",addons[i]. iconURL);
                menuItem. setAttribute ("label",addons[i]. name);
                menuItem. setAttribute ("id_",addons[i]. id);
                b_.firstChild.nextSibling.nextSibling.setAttribute("label","edit")
                b_.firstChild.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="Disabled_";tqa.but_(event,class_);tqa.st_(event);');
                b_.firstChild.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="_";tqa.but_(event,class_);event. originalTarget.parentNode.parentNode.parentNode.removeChild(event. originalTarget.parentNode.parentNode);');
                b_.firstChild.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');var class_="st_";tqa.but_(event,class_)');
                b_.firstChild.nextSibling.nextSibling.nextSibling.setAttribute('oncommand','var tqa = document.getElementById('+'"'+val+'"'+');tqa.but_u(event)');
                var menuItem =xul. getElementsByTagName ("menuitem") [0];
                if (addons[i]. iconURL)
                {                        
                    menuItem. setAttribute ("src",addons[i]. iconURL);
                }
                else
                {
                    menuItem. setAttribute ("src",iconURL);
                }
                if (addons[i] .userDisabled)
                {                        
                    menuItem.setAttribute("disabled","true")
                    st_d_arr.push(xul)
                }
                else
                {
                    menuItem.setAttribute("disabled","false")
                    st_e_arr.push(xul)
                }
                                     
            }
            
        st_e_arr. sort
                    (
                    function (a, b, c, d)
                        {
                            return a.getElementsByTagName ("menuitem") [0]. getAttribute ("label"). toLowerCase ()  > b.getElementsByTagName ("menuitem") [0]. getAttribute ("label"). toLowerCase () ;
                        }
                    );    
        st_d_arr. sort
                    (
                    function (a, b, c, d)
                        {
                            return a.getElementsByTagName ("menuitem") [0]. getAttribute ("label"). toLowerCase ()  > b.getElementsByTagName ("menuitem") [0]. getAttribute ("label"). toLowerCase () ;
                        }
                    );                
        for (var i = 0; i < st_d_arr. length; i++)
            {    
                st_d. appendChild (st_d_arr[i])
            }    
        for (var i = 0; i < st_d_arr. length; i++)
            {    
                st_e. appendChild (st_e_arr[i])
            }        
        }
)
this. st_=function (event) 
{
    
    var m= event. originalTarget.parentNode.previousSibling.firstChild
    var obj= event. originalTarget.parentNode.parentNode
    var b= event. originalTarget.parentNode.parentNode.parentNode
    
    if(m.getAttribute("disabled")=='true')
    {
        
        b.previousSibling .previousSibling .  appendChild (obj)
        m.setAttribute("disabled","false")
        
    }
    else
    {
        m.setAttribute("disabled","true")
        b.nextSibling .nextSibling. appendChild (obj)
    }
}    

this. but_u=function (event) 
    {
        var id= event. originalTarget.parentNode.previousSibling.firstChild. getAttribute ("id_")
        var info = Components.classes["@mozilla.org/xre/app-info;1"] 
            .getService(Components.interfaces.nsIXULAppInfo);   
        Components.utils.import("resource://gre/modules/AddonManager.jsm");
        AddonManager.getAddonByID(id, function(aAddon) {
            aAddon.findUpdates(UpdateListener, 1, window.navigator.appVersion, info.platformVersion);
        });  
 
 
        var UpdateListener = 
        {
            onUpdateAvailable: function(addon,install) 
            {
                install.addListener
                (
                    { 
                        onInstallEnded: function () 
                        {                    
                            install.removeListener({onInstallEnded: function (){}})
                            event. originalTarget.parentNode.previousSibling.firstChild.setAttribute("style","color:#006600;")
                            event. originalTarget.setAttribute("oncommand",'this.install.cancel();this.install=null;this.parentNode.previousSibling.firstChild.setAttribute("style","color:#000000;")')
                            event. originalTarget.setAttribute("label","cancel")
                        }
                    }
                    
                );
                install.addListener
                (
                    { 
                        onDownloadFailed: function ()
                        {
                            install.removeListener({onDownloadFailed: function (){}})
                            event. originalTarget.parentNode.previousSibling.firstChild.setAttribute("style","color:#FF0000;")
                            event. originalTarget.setAttribute("label","error")
                        }
                    }
                )
                install.addListener
                (
                    { 
                        onInstallFailed: function ()
                        {
                            install.removeListener({onInstallFailed: function (){}})
                            event. originalTarget.parentNode.previousSibling.firstChild.setAttribute("style","color:#FF0000;")
                            event. originalTarget.setAttribute("label","error")
                        }    
                    }
                )    
                event. originalTarget.parentNode.previousSibling.firstChild.setAttribute("style","text-decoration:underline;")
                event. originalTarget.setAttribute("label","install/true")
                event. originalTarget.install=install
                event. originalTarget.setAttribute('onclick','this.install.install()');
            },
            onNoUpdateAvailable: function(addon) 
            {
                 if(event. originalTarget.getAttribute("label")=='install/true'||event. originalTarget.getAttribute("label")=='cancel')
                    return
                 event. originalTarget.setAttribute("label","install/false")
                 event. originalTarget.parentNode.previousSibling.firstChild.setAttribute("style","color:#6666CC;")
                 return;
            },
            onCompatibilityUpdateAvailable: function(addon) 
            {                  
                return;
            },
            onNoCompatibilityUpdateAvailable: function(addon) 
            {
                return;
            },
            onUpdateFinished: function(addon,err) 
            {
   
                return;
            }
        }
    }
                        
this. type = "menu";
this.orient = "horizontal";
this. appendChild (menupopup);
menupopup.appendChild (box_0);

Добавлено 04-02-2012 21:16:41

SendInfo пишет

local.initWithPath("/usr/bin/file-roller");

не понял как применить

Отредактировано Ste_pan (04-02-2012 21:16:41)

Отсутствует

 

№359404-02-2012 21:34:00

Abricosio
Участник
 
Группа: Members
Зарегистрирован: 13-01-2011
Сообщений: 30
UA: Firefox 9.0
Веб-сайт

Re: Custom Buttons

Anton пишет

Abricosio
При посещении любого сайта, и нажатии на определенную кнопку, все внутренние ссылки на открытой странице сделать красными (изменить для них цвет)?Если я правильно понял:

Выделить код

Код:

function makeURL (url)
{
    var uri = makeURI (url);
    try
    {
        uri = uri. QueryInterface (Components. interfaces. nsIURL);
    }
    catch (e)
    {
        uri = null;
    }
    return uri;
}
var doc = gBrowser. contentDocument;
var cdurl = makeURL (doc. location. href);
cdurl. ref = "";
var links = doc. links;
var curl;
for (var i = 0; i < links. length; i++)
{
    curl = makeURL (links [i]. href);
    if (curl && (curl. host == cdurl. host))
        links [i]. style. backgroundColor = "red";
}

Подскажите пожалуйста как сделать данную кнопку включенной всегда, для новых открываемых URL также... Через UserContent.css не получается, говорят, до версии css4 пока что нельзя такой функционал иметь

Отредактировано Abricosio (04-02-2012 21:36:47)

Отсутствует

 

№359504-02-2012 21:48:22

bugmenot
Участник
 
Группа: Members
Зарегистрирован: 29-01-2012
Сообщений: 35
UA: Firefox 10.0
Веб-сайт

Re: Custom Buttons

Тут, похоже, не кнопка, а Greasemonkey или Scriptish нужны. Твой скрипт будет выполняться на любой нужной странице.

Отсутствует

 

№359604-02-2012 22:06:55

Abricosio
Участник
 
Группа: Members
Зарегистрирован: 13-01-2011
Сообщений: 30
UA: Firefox 9.0
Веб-сайт

Re: Custom Buttons

А если нужно на всех всех? :)

Отсутствует

 

№359704-02-2012 22:18:00

bunda1
Moderator
 
Группа: Moderators
Откуда: Латвия
Зарегистрирован: 09-02-2010
Сообщений: 4811
UA: Firefox 3.6

Re: Custom Buttons

Abricosio пишет

Подскажите пожалуйста как сделать данную кнопку включенной всегда, для новых открываемых URL также

положи код в любую Custom Buttons кнопку, в инициализацию. Не обязательно создавать новую CB кнопку, можно использовать уже существующую.

Выделить код

Код:

RedLink = function(event){
function makeURL (url)
{
    var uri = makeURI (url);
    try
    {
        uri = uri. QueryInterface (Components. interfaces. nsIURL);
    }
    catch (e)
    {
        uri = null;
    }
    return uri;
}
var doc = gBrowser. contentDocument;
var cdurl = makeURL (doc. location. href);
cdurl. ref = "";
var links = doc. links;
var curl;

for (var i = 0; i < links. length; i++)
{
    curl = makeURL (links [i]. href);
    if (curl && (curl. host == cdurl. host))
    //внутренние ссылки на открытой странице сделать красными (= "red")
        links [i]. style.color = "red";
}
 }
 
//добавляем обработчики для табов......
gBrowser.tabContainer.addEventListener("TabSelect", RedLink, false);
gBrowser.addEventListener("DOMContentLoaded", function(event){
//фылтр....
//стоп, если открыть новые таби 
if (event.target.location.href !== getBrowser().currentURI.spec) return;
//стоп, если срабатывает на фрейме
var document = event.originalTarget;
if (document instanceof HTMLDocument && this.contentWindow.document !== document) return;
RedLink(event)}, false);

Добавлено 04-02-2012 22:26:14

questman пишет

А вот где найти "Инспектор" не знаю.
Может кто намекнёт,буду благодарен.

DOM Inspector | custombuttons

Отредактировано bunda1 (04-02-2012 22:26:42)

Отсутствует

 

№359804-02-2012 22:26:20

Andrey_Krropotkin
Участник
 
Группа: Members
Зарегистрирован: 11-11-2011
Сообщений: 484
UA: Firefox 10.0

Re: Custom Buttons

Переношу кнопку feed-button в адресную строку - вот код:
//-----------feed-button----------------------------------
var bar = document.getElementById("nav-bar");
bar.currentSet = "feed-button," + bar.getAttribute("currentset");
bar.setAttribute("currentset",bar.currentSet);
document.persist(bar.id,"currentset");
document.getElementById("urlbar-icons").insertBefore(document.getElementById("feed-button"),document.getElementById("star-button"));

Хочу изменить стиль: во первых, чтобы когда не не активна не была видна, во вторых, чтобы не искажала адресную строку:

var feed = document.getElementById("feed-button");
if (feed.setAttribute("disabled", "true"))
{
feed.setAttribute("style", "display: none;");
}
else
{
feed.setAttribute("style", "height: 16px; min-width: 0; margin: 0; padding: 0; -moz-appearance: none; background: none; border: none; box-shadow: none;");
}

Не могу понять, почему if (feed.setAttribute("disabled",true)) у меня не срабатывает (то есть кнопка когда неактивна все равно видима) , подскажите  пожалуйста.

Отредактировано Andrey_Krropotkin (04-02-2012 23:21:58)

Отсутствует

 

№359904-02-2012 22:28:44

bunda1
Moderator
 
Группа: Moderators
Откуда: Латвия
Зарегистрирован: 09-02-2010
Сообщений: 4811
UA: Firefox 3.6

Re: Custom Buttons

Andrey_Krropotkin

Выделить код

Код:

var feed = document.getElementById("feed-button");
if (feed.getAttribute("disabled"))
{
feed.setAttribute("style", "visibility: collapse;");
}
else
{
feed.setAttribute("style", "visibility:visible");
feed.setAttribute("style", "height: 16px; min-width: 0; margin: 0; padding: 0; -moz-appearance: none; background: none; border: none; box-shadow: none;");
}

Отредактировано bunda1 (04-02-2012 22:56:29)

Отсутствует

 

№360004-02-2012 23:07:28

Andrey_Krropotkin
Участник
 
Группа: Members
Зарегистрирован: 11-11-2011
Сообщений: 484
UA: Firefox 10.0

Re: Custom Buttons

bunda1 Кнопка вообще пропала из адресной строки

Отсутствует

 

Board footer

Powered by PunBB
Modified by Mozilla Russia
Copyright © 2004–2020 Mozilla Russia GitHub mark
Язык отображения форума: [Русский] [English]