Abricosio пишет: Подскажите пожалуйста как сделать данную кнопку включенной всегда, для новых открываемых URL такжеположи код в любую Custom Buttons кнопку, в инициализацию. Не обязательно создавать новую CB кнопку, можно использовать уже существующую.
Спасибо! Отлично работает!!!
Добавлено 04-02-2012 23:42:42
Тормозит правда все это дело нещадно )) А возможно сделал тумблер, вкл/выкл?
Отредактировано Abricosio (04-02-2012 23:42:42)
Отсутствует
Кнопка вообще пропала из адресной строки
Да точно, если feed-button не видно то if (feed.getAttribute("disabled")) не работает, надо как то по другому проверять.
Вот убедись сам.
var feed = document.getElementById("feed-button");
alert(feed.getAttribute("disabled"))
Добавлено 04-02-2012 23:51:55
Тормозит правда все это дело нещадно )) А возможно сделал тумблер, вкл/выкл?
Как тормозит?
Отредактировано bunda1 (05-02-2012 00:10:36)
Отсутствует
bunda1 и это не подходит
Отсутствует
SendInfo пишетне понял как применить
Не надо применять - пользователи Ubuntu сами применят(если им нужно открытие расширений кнопкой "open")
Отсутствует
Как тормозит?
При переключении между вкладками секунд на 5-7 подвисает
Добавлено 05-02-2012 01:31:08
А нет, вероятно дело было не в нем, сейчас все нормально! Подскажите ещё пожалуйста, что дописать, чтобы внешний ссылки были blue
т.е. if (curl && (curl. host != cdurl. host))
Всмысле, одновременно внутренние - красные, внешние - синие
Отредактировано Abricosio (05-02-2012 01:32:31)
Отсутствует
Подскажите ещё пожалуйста, что дописать, чтобы внешний ссылки были blue
Всмысле, одновременно внутренние - красные, внешние - синие
поменять на
(curl && (curl. host == cdurl. host)) ? links [i]. style.color = 'red' : links [i]. style.color ='blue' ;
Отредактировано bunda1 (05-02-2012 06:49:39)
Отсутствует
добавил рестарт по пкм в любом месте меню
вообще фишка кнопки по моему применение персон к не стандартной теме
эта функция работала через раз поправил и т.д
var s=Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch); var pref=Application.prefs.get("lightweightThemes.isThemeSelected") if(!(pref)) s.setBoolPref('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_="color:#000000;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#000000;"
var style_sel ='color:#FF6600;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#6633FF'
var Node=this.parentNode.childNodes;
for (var i = 0; i <3; i++)
		{
			
Node[i]. setAttribute ("style", style_)
		};
this.setAttribute ("style",style_sel)
var Node=this.parentNode.nextSibling .childNodes;
for (var i = 0; i <3; i++)
		{
		
if(Node[i].className ==this.className){
				Node[i].hidden=false}
			else{
				Node[i].hidden=true}
		};
		
" class="Enable_"/> <label value="Disable" onclick="var style_="color:#000000;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#000000;"
var style_sel ='color:#FF6600;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#6633FF'
var Node=this.parentNode.childNodes;
for (var i = 0; i <3; i++)
		{
			
Node[i]. setAttribute ("style", style_)
		};
this.setAttribute ("style",style_sel)
var Node=this.parentNode.nextSibling .childNodes;
for (var i = 0; i <3; i++)
		{
		
if(Node[i].className ==this.className){
				Node[i].hidden=false}
			else{
				Node[i].hidden=true}
		};
		
" class="Disable_"/> <label value="False" onclick="var style_="color:#000000;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#000000;"
var style_sel ='color:#FF6600;font-family:monospace;font-weight:lighter;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:#6633FF'
var Node=this.parentNode.childNodes;
for (var i = 0; i <3; i++)
		{
			
Node[i]. setAttribute ("style", style_)
		};
this.setAttribute ("style",style_sel)
var Node=this.parentNode.nextSibling .childNodes;
for (var i = 0; i <3; i++)
		{
		
if(Node[i].className ==this.className){
				Node[i].hidden=false}
			else{
				Node[i].hidden=true}
		};
		
" 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) { if(box_sel.childNodes.length==0) { boxx.appendChild (box_); } else { boxx.appendChild (box_sel); box_sel.appendChild(document.createElement("menuseparator")); boxx.appendChild (box_); } } else { if(box_sel.childNodes.length==0) { boxx.appendChild (groupbox); boxx.appendChild(document.createElement("menuseparator")); 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_.setBoolPref('lightweightThemes.isThemeSelected',true) 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); this. onclick = function (event){ if ( event. shiftKey) return; if (event. button == 2) { event. preventDefault (); event. stopPropagation (); var appStartup = Components.classes["@mozilla.org/toolkit/app-startup;1"] .getService(Components.interfaces.nsIAppStartup); appStartup.quit(appStartup.eForceQuit | appStartup.eRestart); }}
Отсутствует
Наше решение, подсмотрел в одной из кнопок, но оно какое-то корявое
//-----------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"); feed.setAttribute("style", "height: 16px; min-width: 0; margin: 0; padding: 0; -moz-appearance: none; background: none; border: none; box-shadow: none;"); /* my style....................................... */ var sId = "__customButtonsStyle__" + this.id; // Unique style "id" var cssStr = <><![CDATA[ #feed-button[disabled] { display: none !important; } ]]></> .toString() .replace(/%button%/g, "#" + this.id); function sheet(cssStr, removeFlag) { var cc = Components.classes; var sss = cc["@mozilla.org/content/style-sheet-service;1"] .getService(Components.interfaces.nsIStyleSheetService); var ios = cc["@mozilla.org/network/io-service;1"] .getService(Components.interfaces.nsIIOService); var data = "data:text/css," + encodeURIComponent(cssStr); var uri = ios.newURI(data, null, null); if(sss.sheetRegistered(uri, sss.AGENT_SHEET)) sss.unregisterSheet(uri, sss.AGENT_SHEET); if(removeFlag) return; sss.loadAndRegisterSheet(uri, sss.AGENT_SHEET); window[sId] = cssStr; } if(!(sId in window)) sheet(cssStr); else if(window[sId] != cssStr) { sheet(window[sId], true); sheet(cssStr); }
Может кто предложит лучшее решение для #feed-button[disabled]?
Отредактировано Andrey_Krropotkin (05-02-2012 13:51:35)
Отсутствует
Наше решение, подсмотрел в одной из кнопок, но оно какое-то корявое
Может кто предложит лучшее решение для #feed-button[disabled]?
//-----------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"); feed.setAttribute("style", "height: 16px; min-width: 0; margin: 0; padding: 0; -moz-appearance: none; background: none; border: none; box-shadow: none;"); (function(css) { var pi = document.createProcessingInstruction( 'xml-stylesheet', 'type="text/css" href="data:text/css;utf-8,' + encodeURIComponent(css) + '"' ); return document.insertBefore(pi, document.documentElement); } )(<![CDATA[ @namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul); #feed-button[disabled] { display: none !important; } ]]>.toString());
Но кнопку также можно перенести в адресную строку CSS стилем.
Отредактировано bunda1 (05-02-2012 14:29:20)
Отсутствует
bunda1 спасибо, все работает.
Отсутствует
Вот эта кнопка https://forum.mozilla-russia.org/viewto … 46#p534846
Кнопока переключающая true/false параметр в about:config - dom.ipc.plugins.enabled
Вопрос: при переключении требуется перезапуск?
Отсутствует
Вот эта кнопка https://forum.mozilla-russia.org/viewto … 46#p534846
Кнопока переключающая true/false параметр в about:config - dom.ipc.plugins.enabled
Вопрос: при переключении требуется перезапуск?
Ответ: при переключении требуется перезапуск, иначе никак: 13-12-2011 18:39:03
Добавлено 05-02-2012 22:43:01
bunda1 пишетSendInfoВот CB код каторый заменяет greasemonkey.Скрипты сохраняй в папку \Profile\chrome\UserScriptLoader, скрипт в папке должен быть вот таким 47007.user. Код саздает на панеле дополнений кнопку которая открывает меню для управление скриптами:
Некорректно отрабатывает Virtual Keyboard Interface for Greasemonkeyhttp://userscripts.org/scripts/show/10974
Не знаю в чем тут дело, автор кода не я.
P.S. У меня вроде работает.
Отредактировано bunda1 (05-02-2012 22:51:45)
Отсутствует
okkamas_knife
по поводу последней кнопочки Weather from gismeteo(enter city code in Initialization)(Firefox 4+):
при наведении курсором во всплывающем тултипе вот имею такое
и еще
ПКМ принудительно обновить информацию (автоматически обновляется каждые полчаса)
Но так же выскакивает и меню кнопки! Не очень удобно. Может или на СКМ повесить или меню запретить...
Отсутствует
скорее всего код кнопки чемто побит при установке
Создал кнопку вручную и вставил скопированный код в инициализацию - та же фигня, даже не меняя город (мой, Харьков)!
Редирект ремувером не пользуюсь. Что еще может влиять, не знаю...
Отсутствует
bunda1 может запостите кнопку feed-button в готовые кнопки. Вроде кнопка не моя , от общего сообщества, но с вашими исправлениями.
Отсутствует
okkamas_knife
Создал чистый профиль, установил только CB 0.0.5.5 и одну эту кнопочку. Вот имею:
У коллеги по работе на его компе пробовал ту же связку и та же фигня...
Пришло в голову только одно - у тебя gismeteo.ru, а у меня автоматом переводится на gismeteo.uа ! Может поэтому?
и меню не выскакиевает раз в полчаса.
Нет, меню через полчаса не выскакивает. Просто, когда жмешь ПКМ, чтобы обновить погоду, открывается меню кнопки. Вот я и говорю:
Может или на СКМ повесить или меню запретить?
Отредактировано Inko7 (06-02-2012 18:57:25)
Отсутствует
bunda1 может запостите кнопку feed-button в готовые кнопки. Вроде кнопка не моя , от общего сообщества, но с вашими исправлениями.
Хорошо.
Feed-button в адресной стоке
Отредактировано bunda1 (06-02-2012 22:19:42)
Отсутствует
На базе известной кнопки от bunda1 переводчика Google попытался сделать такую же для Promta
function cbTranslatorButton (browser)
{
this. doc = browser. contentDocument;
this. win = browser. contentDocument. defaultView;
}
cbTranslatorButton. prototype =
{
doc: null,
win: null,
toolbar: null,
clse: null,
frame: null,
grabX: 0,
origX: 0,
grabY: 0,
origY: 0,
handleEvent: function (event)
{
switch (event. type)
{
case "mousedown":
this. tbOnMouseDown (event);
break;
case "mousemove":
this. tbOnMouseMove (event);
break;
case "mouseup":
this. tbOnMouseUp (event);
break;
case "click":
this. clseOnClick (event);
break;
case "load":
this. frameOnLoad (event);
break;
default:;
}
},
tbOnMouseMove: function (event)
{
this. toolbar. style. left = this. origX + event. clientX - this. grabX + 'px';
this. toolbar. style. top = this. origY + event. clientY - this. grabY + 'px';
},
tbOnMouseUp: function (event)
{
this. doc. removeEventListener ('mousemove', this, false);
this. toolbar. style. zIndex = 9997;
},
tbOnMouseDown: function (event)
{
if (event. target == this. toolbar)
{
event. preventDefault ();
this. toolbar. style. zIndex = 9998;
this. grabX = event. clientX;
this. grabY = event. clientY;
this. origX = parseInt (this. toolbar. style. left);
this. origY = parseInt (this. toolbar. style. top);
this. doc. addEventListener ('mousemove', this, false);
this. doc. addEventListener ('mouseup', this, false);
}
},
removeEventListener: function (element, eventType, captureFlag)
{
try
{
element. removeEventListener (eventType, this, captureFlag);
}
catch (err) {}
},
removeElement: function (element)
{
try
{
element. parentNode. removeChild (element);
}
catch (err) {}
},
clseOnClick: function (event)
{
this. clse. removeEventListener ('click', this, false);
this. removeEventListener (this. toolbar, 'mousedown', false);
this. removeEventListener (this. doc, 'mousemove', false);
this. removeEventListener (this. doc, 'mouseup', false);
this. removeEventListener (this. frame, 'load', false);
this. removeElement (this. toolbar);
this. removeElement (this. frame);
this. frame = null;
this. clse = null;
this. toolbar = null;
this. win = null;
this. doc = null;
},
ujs_createWindow: function (txt)
{
var doc = this. doc;
var win = this. win;
var h, w;
var txtLen = txt. length;
var tbId = UJS_TOOLBAR_ID;
if (arguments. length > 2)
tbId += arguments [2];
var toolbar = doc. getElementById (tbId);
if (toolbar)
toolbar. parentNode. removeChild (toolbar);
toolbar = doc. createElement ('div');
this. toolbar = toolbar;
toolbar. id = tbId;
if (arguments. length == 5)
{
w = arguments [3];
h = arguments [4]
}
else
{
h = 15;
w = 20;
if (txtLen > 2000)
{
h = 50;
w = 66
}
else if (txtLen > 250)
{
h = 25;
w = 33
};
h = parseInt (h * win. innerHeight / 30);
w = parseInt (w * win. innerWidth / 50)
};
var title = (arguments. length > 1) ?arguments [1]: '<a href="http://www.translate.ru/" target="_blank" style="text-decoration:none;color:#000099;font:16px Times New Roman;">Google Translate</a>';
toolbar. innerHTML = '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAABh0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjIyt5EXfQAAAStJREFUOE+1k9tqhDAQhtOHqO37P4E3IlQFQQSvBBVEl1TBVVi1B+1C8XAx3QmNqIVqhBV+DEPmy8z8ycPX9Ruq6kLqqiRHvkfpiUjSMyGUJtB1HfR9D8MwCAlz6voNkEGCIGDJeZ5DURTCatoWNE0D4nk+jOMoDMBD8fDPpoGXu4OyLAPUutV1/N+KcPPNPaY4jidYktwG+hunlLL4ZmsI4EloxhxiGAY4jgNpmm6D8DQEcBj/I8SyrKnSzYr4bDzPm2CKoiwgu1rDTfN2eEWu6y4M2KxoPRNVVRcz4xXvdm0+k/nMwjDc5xraa9v2n5kgwDRNMdfQXtT6Us7jy9Z8n738Iw82O5/hUpag6zqQ0+kVmqZld0NUURSxl48M8v5xZQtZlg8Jc5HxA5fIE73hTda3AAAAAElFTkSuQmCC" title="Close" width="18" height="18"> ' + title + '<div></div>';
toolbar. setAttribute('style', 'position:fixed;background:white;display:block;visibility:hidden;left:0;top:0;height:auto;width:' + w + 'px;font:16px Times New Roman;border:1px solid gray;padding:3px;z-index:9997;overflow:visible;cursor:move;');
toolbar. addEventListener ('mousedown', this, false);
var clse = toolbar. firstChild;
this. clse = clse;
clse. setAttribute ('style', 'float:right;background:white;padding:0;margin:0;border:none;cursor:pointer;');
clse. addEventListener ('click', this, false);
var textbar = toolbar. lastChild;
textbar. innerHTML = txt;
textbar. setAttribute ('style', 'display:block;border:1px solid #aaaaaa;margin:2px 0 0 0;padding:4px;background-color:#fafcfe;font:14px Times New Roman;height:' + h + 'px;width:auto;overflow:auto;cursor:text;');
doc. documentElement. appendChild (toolbar);
var halfWidth = parseInt (toolbar. offsetWidth / 2);
var strict = doc. compatMode == 'CSS1Compat';
var mX = (strict?
doc. documentElement. clientWidth:
doc. body. clientWidth) - toolbar. offsetWidth;
var mY = (strict?
doc. documentElement. clientHeight:
doc. body. clientHeight) - toolbar. offsetHeight;
var lastClickX = win. cbTranslateButton2X;
var lastClickY = win. cbTranslateButton2Y;
toolbar. style. left = ((lastClickX < mX + halfWidth)?
(lastClickX > halfWidth?
(lastClickX - halfWidth):
0):
mX) + "px";
toolbar. style. top = ((lastClickY < mY)?
lastClickY:
mY) + "px";
toolbar. style. visibility = 'visible';
return textbar;
},
frameOnLoad: function (event)
{
var fr = event. currentTarget;
fr. removeEventListener ('load', this, false);
var tbId = fr. id. substring (UJS_GOOGLE_TRANSLATE_FRAME_ID. length);
var toolbar = this. doc. getElementById (UJS_TOOLBAR_ID + tbId);
var frdoc = fr. contentDocument;
var a = frdoc. getElementById ('autotrans');
var title = (a && !/#808080/. test (a. innerHTML))?
' - ' + a. textContent. replace (/^.+: | [(\xBB].+$/g, ''):
'';
var result = frdoc. getElementById ('translationResult'). innerHTML;
var ancor = toolbar. getElementsByTagName ("a") [0];
ancor. innerHTML += title;
ancor. nextSibling. innerHTML = result;
setTimeout
(
function ()
{
fr. parentNode. removeChild (fr);
},
0
);
},
google_translate: function (language)
{
var doc = this. doc;
var win = this. win;
var t = document. commandDispatcher. focusedWindow. getSelection (). toString ();
var lng = (win. navigator. language == 'ru')? 'ru': 'en';
if (t && location. hostname != 'www.translate.ru')
{
this. ujs_createWindow
(
(lng == 'ru'?
'\u041F\u0435\u0440\u0435\u0432\u043E\u0434\u0438\u043C':
'Подождите идет перевод'
) +
'\u2026',
'<a href="http://www.translate.ru/" target="_blank" style="text-decoration:none;color:#000099;font:16px Times New Roman;">Promt перевод</a>',
btoa (escape (t))
);
var gtfId = UJS_GOOGLE_TRANSLATE_FRAME_ID;
var fr = doc. getElementById (gtfId);
if (!fr)
fr = doc. createElement ('iframe');
this. frame = fr;
fr. setAttribute ('id', gtfId + btoa (escape (t)));
fr. setAttribute ('frameborder', '0');
fr. setAttribute ('style', 'width:0px;height:0px;visibility:hidden;position:absolute;left:-999em;');
fr. setAttribute
(
'src',
'http://www.translate.ru/?External=IE8Accelerator&formEncoding=utf-8&prmtlang=ru&direction=ar&status=translate&template=General&source=' +
encodeURIComponent (t)+
'&tbb=1&ujs=gtt'
);
fr. addEventListener ('load', this, false);
doc. documentElement. appendChild (fr);
}
else
{
getBrowser (). addTab
(
'http://www.translate.ru/url/tran_url.asp?direction=ar&template=General&autotranslate=true&url=' +
escape (doc. location. href) +
(doc. charset? '&ie=' + doc. charset: ''),
null,
null
);
}
}
};
var ct = getBrowser (). selectedTab;
if (!ct. cbTranslateButton5)
ct. cbTranslateButton5 = [];
var translator = new cbTranslatorButton (getBrowser ());
ct. cbTranslateButton5. push (translator);
translator. google_translate ("");
Помогите пожалуйста решить эти проблемы.
Отсутствует
Выдернул из расширения Mar Mod перевод с заменой текста. Воткнул в контекстное меню для выделенного текста и добавил еще несколько пунктов:
Перевести текст в окне - кнопка от bunda1
Перевести текст в Google - в новой вкладке
Перевести текст в PROMT- в новой вкладке
Перевести текст в Bing Translator- в новой вкладке
Перевести слово в Яндексе- в новой вкладке
Перевести слово в Lingvo- в новой вкладке
Перевести слово в Mail.ru- в новой вкладке
Если что лишнее, то легко убрать.
/*Initialization Code*/ var gtlnkicon="data:image/gif;base64,R0lGODlhEAAQALMOAMz//8zM/5nM/2ZmzGZmmZmZzMyZzMzMmZmZ/5mZmQAAAP///2Zm/wD/AP///wAAACH5BAHoAw4ALAAAAAAQABAAAARw0EkJgghgajlIMQUxjMZmeNIhiYSGEEmwOUQrIUMiKXy/EYpJkOcIajob4izBTBR2xk1hQU20lJvEQrHQAo2BsERLrfJGCIYtwdsq2ER1yZFo2O26iXzMaygaeQ4BQHMEd3Y1BGo1hYmJAQsHKgRzEQA7"; var gticon="data:image/gif;base64,R0lGODlhEAAQALMMAMz//8zM/5nM/2ZmzGZmmZmZzMyZzJmZ/8zMmZmZmQAAAGZm/////wAAAAAAAAAAACH5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KcpQmPLmCiESVID42RPCSQIFX3pIYhABwZ8TE2oUGbLkwAMLEMageEGnBJ8wRH7M0dBADRQDaIwkksSFDSAYBQroWMAjUJAcTQblkTTgiRhGSphE4XDIwRo5JgamadNngI0beCzqFuiCRYzdkgICADs="; var gti1con="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAADPElEQVR4nGWTTWhjZRSG3/uTNr39mTqTn1KacagTqyKIlYJ2ExQCUhiprgpduRVFpLvZjOCsXEgWFqRk0RZcWLopmOnCQcPUsVBiTEZbalrGTJOZJm2aNGm++92b737fcdGZTfvAuznwnMV7OBouEI/HdSHEyNzcXCwajb7r8/n6T09P99bW1u4PDw8/SiQSbHd396IGBINBJJPJQDqdvssYK0kpO0SkiIiUUlII0SqVSr8lk8n3JycnjUsLZmdnb5bL5T+klPK5RNzp0BlzyHEFKXU+cxynubKy8tXExIQJABoAzM/PB6amptYikch70DRtv3iMh5kClPQglcKzozMMXhnAh7E3EL0RhCcEX19f/6xSqSxhdHRUT6VS39i2LYUQtJ7epm9/uEdHtSZJKUkpRa0zm75fvE+f3/mRmM3JcRyqVqulmZmZl7G6uhopl8sHtm3TduEpffH1T1Srn9FFavUmnTRaJKUkx3Go0WiojY2N22aj0Yj5fL6wJyVS6R289koYVwd7L3V07aUBAICUEkopSCk1v99/Sw+Hw5NSyi7OXZQrTQwFBy6f6DlKKSil4HkeOp0ODMO4btq23S+EgFQaAAKzO1BKQdd1AICmaSAiEBGUlBBCwHVduK4LzrlpHh4e7nHOVW+vofdbPmxkHuPWB6/D6vFD13UoRfj38TPsP6mBOxJjN64gdNUC5xz1er2l5/P5XxqNBvNEByPBLmS2n+LXzQK4zcH5ebp9GkAeEksPwJgNxhhs20axWMzo7Xb7US6Xyx7Xanh7LIhXRywklh7i9z/30Wy1YNsMfT0mrG4DGoCO64Ixhlqt5uTz+UVjZ2dHDA0NFYPB4Cd9fVb3W2MhnDZb+DldwD+FCk5OWvivVEX27ycY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gatekeeper/there.is.only.xul"; var contextMenu = document.getElementById("contentAreaContextMenu"); var separator = document.getElementById("LinkMasterMenu"); var eventTarget = null; var menu = document.createElementNS(kXULNS, "menu"); menu.id = "PerevodMenu1"; menu.setAttribute("label", "Перевести текст"); menu.setAttribute("class", "menu-iconic"); menu.setAttribute("image", lmricon); menu.hidden = true; contextMenu.insertBefore(menu, separator ); var menuPopup = document.createElementNS(kXULNS, "menupopup"); menu.appendChild(menuPopup); var lst = [ { label:"Заменить текст переводом", command:command98, image:gti1con }, { label:"Перевести текст в окне", command:command908, image:gti1con }, { label:"separator" }, { label:"Перевести текст в Google", command:command90, image:gtlnkicon }, { label:"Перевести текст в PROMT", command:command91, image:promticon }, { label:"Перевести текст в Bing Translator", command:command92, image:Bingicon }, { label:"separator" }, { label:"Перевести слово в Яндексе", command:command93, image:Yndicon }, { label:"Перевести слово в Lingvo", command:command94, image:Lingvoicon }, { label:"Перевести слово в Mail.ru", command:command95, image:Malicon }, ]; for(var i = 0, m; m = lst[i]; i++){ if (m.label=="separator"){ var menuItem = document.createElementNS(kXULNS, "menuseparator"); menuItem.id = "context-Demo-Menu-" + m.label.toString(); menuPopup.appendChild(menuItem); } else{ var menuItem = document.createElementNS(kXULNS, "menuitem"); menuItem.setAttribute("label", m.label); menuItem.setAttribute("class", "menuitem-iconic"); menuItem.setAttribute("image", m.image); menuItem.setAttribute("type", "m.radio"); menuItem.addEventListener("command", m.command, false); menuItem.id = "context-Demo-Menu-" + m.label.toString(); menuPopup.appendChild(menuItem); } } contextMenu.addEventListener("popupshowing", setMenuDisplay, false); function setMenuDisplay(aEvent) { if (gContextMenu.isTextSelected) { document.getElementById("PerevodMenu1").hidden = false; } else document.getElementById("PerevodMenu1").hidden = true; } //--------Перевести текст в Google-------------- //----------------------------------------------------- function command90(){ var clipboard = Components.classes["@mozilla.org/widget/clipboardhelper;1"]. getService(Components.interfaces.nsIClipboardHelper); var t = document.commandDispatcher.focusedWindow.getSelection(); if (t != '') { var x = gBrowser.mCurrentTab._tPos +1; gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://translate.google.com/translate_t?hl=ru#auto|ru|"+t), x); } else { var x = gBrowser.mCurrentTab._tPos +1; gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://translate.google.com/"), x); } } //---------Перевести текст в PROMT--------------- //----------------------------------------------------- function command91(){ var clipboard = Components.classes["@mozilla.org/widget/clipboardhelper;1"]. getService(Components.interfaces.nsIClipboardHelper); var t = document.commandDispatcher.focusedWindow.getSelection(); if (t != '') { var x = gBrowser.mCurrentTab._tPos +1; gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://www.translate.ru/?External=IE8Accelerator&formEncoding=utf-8&direction=ar&prmtlang=ru&status=translate&template=General&source="+t), x); } else { var x = gBrowser.mCurrentTab._tPos +1; gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://www.translate.ru/"), x); } } //---------Перевести текст в Bing Translator--------------- //----------------------------------------------------- function command92(){ var clipboard = Components.classes["@mozilla.org/widget/clipboardhelper;1"]. getService(Components.interfaces.nsIClipboardHelper); var t = document.commandDispatcher.focusedWindow.getSelection(); if (t != '') { var x = gBrowser.mCurrentTab._tPos +1; gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://www.microsofttranslator.com/?ref=IE8Activity&to=ru&SourceText="+t), x); } else { var x = gBrowser.mCurrentTab._tPos +1; gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://www.microsofttranslator.com/"), x); } } //----------Перевести слово в Яндексе------------ //----------------------------------------------------- function command93(){ var clipboard = Components.classes["@mozilla.org/widget/clipboardhelper;1"]. getService(Components.interfaces.nsIClipboardHelper); var t = document.commandDispatcher.focusedWindow.getSelection(); if (t != '') { var x = gBrowser.mCurrentTab._tPos +1; gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://lingvo.yandex.ru/"+t), x); } else { var x = gBrowser.mCurrentTab._tPos +1; gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://lingvo.yandex.ru/"), x); } } //-----------Перевести слово в Lingvo-------------- //----------------------------------------------------- function command94(){ var clipboard = Components.classes["@mozilla.org/widget/clipboardhelper;1"]. getService(Components.interfaces.nsIClipboardHelper); var t = document.commandDispatcher.focusedWindow.getSelection(); if (t != '') { var x = gBrowser.mCurrentTab._tPos +1; gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://lingvopro.abbyyonline.com/ru/Search/en-ru/"+t), x); } else { var x = gBrowser.mCurrentTab._tPos +1; gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://lingvopro.abbyyonline.com/ru/Search/en-ru/"), x); } } //----------Перевести слово в Mail.ru------------ //----------------------------------------------------- function command95(){ var clipboard = Components.classes["@mozilla.org/widget/clipboardhelper;1"]. getService(Components.interfaces.nsIClipboardHelper); var t = document.commandDispatcher.focusedWindow.getSelection(); if (t != '') { var x = gBrowser.mCurrentTab._tPos +1; gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://lingvo.mail.ru/?lang_id=1033&translate=&text="+t), x); } else { var x = gBrowser.mCurrentTab._tPos +1; gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://lingvo.mail.ru/"), x); } } //----------Заменить текст переводом------------ //----------------------------------------------------- function command98(){ var clipboard = Components.classes["@mozilla.org/widget/clipboardhelper;1"]. getService(Components.interfaces.nsIClipboardHelper); var t = document.commandDispatcher.focusedWindow.getSelection(); var fullUrl = "http://translate.google.hu/translate_t?text="+t+"&hl=ru"+"&langpair=auto|ru&tbb=1" ; function removeHTMLTags(mitkell) { //clean up a string from html tags var strInputCode = mitkell; var strTagStrippedText = strInputCode.replace(/<\/?[^>]+(>|$)/g, ""); return strTagStrippedText; } function infoReceived() { // if there is response from Google then write out translation var output = httpRequest.responseText; if (output.length) { // Build the output string from Google Page output = output.replace(/"/gi,'"'); output = output.replace(/</gi,'<'); output = output.replace(/>/gi,'>'); output = output.replace(/&/gi,'&'); output = output.replace(/'/gi,"'"); var fieldArray = output.split('</head>'); if (fieldArray[1].search('class="short_text"')!=-1) { var tempResz = fieldArray[1].split('<span id=result_box class="short_text">'); } else if (fieldArray[1].search('class="medium_text"')!=-1) { var tempResz = fieldArray[1].split('<span id=result_box class="medium_text">'); } else { var tempResz = fieldArray[1].split('<span id=result_box class="long_text">'); } var kimenet = tempResz[1].split('</span></div>'); var range = content.getSelection().getRangeAt(0); range.deleteContents(); range.insertNode(document.createTextNode(removeHTMLTags(kimenet[0]))); } } httpRequest = new XMLHttpRequest(); httpRequest.open("GET", fullUrl, true); httpRequest.onload = infoReceived; httpRequest.send(null); } //----------Перевести текст в окне------------ //----------------------------------------------------- function command908(){ const UJS_TOOLBAR_ID = "ujs_toolbar"; const UJS_GOOGLE_TRANSLATE_FRAME_ID = "ujs_googletranslateframe"; function cbTranslatorButton (browser) { this. doc = browser. contentDocument; this. win = browser. contentDocument. defaultView; } cbTranslatorButton. prototype = { doc: null, win: null, toolbar: null, clse: null, frame: null, grabX: 0, origX: 0, grabY: 0, origY: 0, handleEvent: function (event) { switch (event. type) { case "mousedown": this. tbOnMouseDown (event); break; case "mousemove": this. tbOnMouseMove (event); break; case "mouseup": this. tbOnMouseUp (event); break; case "click": this. clseOnClick (event); break; case "load": this. frameOnLoad (event); break; default:; } }, tbOnMouseMove: function (event) { this. toolbar. style. left = this. origX + event. clientX - this. grabX + 'px'; this. toolbar. style. top = this. origY + event. clientY - this. grabY + 'px'; }, tbOnMouseUp: function (event) { this. doc. removeEventListener ('mousemove', this, false); this. toolbar. style. zIndex = 9997; }, tbOnMouseDown: function (event) { if (event. target == this. toolbar) { event. preventDefault (); this. toolbar. style. zIndex = 9998; this. grabX = event. clientX; this. grabY = event. clientY; this. origX = parseInt (this. toolbar. style. left); this. origY = parseInt (this. toolbar. style. top); this. doc. addEventListener ('mousemove', this, false); this. doc. addEventListener ('mouseup', this, false); } }, removeEventListener: function (element, eventType, captureFlag) { try { element. removeEventListener (eventType, this, captureFlag); } catch (err) {} }, removeElement: function (element) { try { element. parentNode. removeChild (element); } catch (err) {} }, clseOnClick: function (event) { this. clse. removeEventListener ('click', this, false); this. removeEventListener (this. toolbar, 'mousedown', false); this. removeEventListener (this. doc, 'mousemove', false); this. removeEventListener (this. doc, 'mouseup', false); this. removeEventListener (this. frame, 'load', false); this. removeElement (this. toolbar); this. removeElement (this. frame); this. frame = null; this. clse = null; this. toolbar = null; this. win = null; this. doc = null; }, ujs_createWindow: function (txt) { var doc = this. doc; var win = this. win; var h, w; var txtLen = txt. length; var tbId = UJS_TOOLBAR_ID; if (arguments. length > 2) tbId += arguments [2]; var toolbar = doc. getElementById (tbId); if (toolbar) toolbar. parentNode. removeChild (toolbar); toolbar = doc. createElement ('div'); this. toolbar = toolbar; toolbar. id = tbId; if (arguments. length == 5) { w = arguments [3]; h = arguments [4] } else { h = 15; w = 20; if (txtLen > 2000) { h = 50; w = 66 } else if (txtLen > 250) { h = 25; w = 33 }; h = parseInt (h * win. innerHeight / 30); w = parseInt (w * win. innerWidth / 50) }; var title = (arguments. length > 1) ?arguments [1]: '<a href="http://translate.google.com/" target="_blank" style="text-decoration:none;color:#000099;font:16px Times New Roman;">Google Translate</a>'; toolbar. innerHTML = '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAABh0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjIyt5EXfQAAAStJREFUOE+1k9tqhDAQhtOHqO37P4E3IlQFQQSvBBVEl1TBVVi1B+1C8XAx3QmNqIVqhBV+DEPmy8z8ycPX9Ruq6kLqqiRHvkfpiUjSMyGUJtB1HfR9D8MwCAlz6voNkEGCIGDJeZ5DURTCatoWNE0D4nk+jOMoDMBD8fDPpoGXu4OyLAPUutV1/N+KcPPNPaY4jidYktwG+hunlLL4ZmsI4EloxhxiGAY4jgNpmm6D8DQEcBj/I8SyrKnSzYr4bDzPm2CKoiwgu1rDTfN2eEWu6y4M2KxoPRNVVRcz4xXvdm0+k/nMwjDc5xraa9v2n5kgwDRNMdfQXtT6Us7jy9Z8n738Iw82O5/hUpag6zqQ0+kVmqZld0NUURSxl48M8v5xZQtZlg8Jc5HxA5fIE73hTda3AAAAAElFTkSuQmCC" title="Close" width="18" height="18"> ' + title + '<div></div>'; toolbar. setAttribute('style', 'position:fixed;background:white;display:block;visibility:hidden;left:0;top:0;height:auto;width:' + w + 'px;font:16px Times New Roman;border:1px solid gray;padding:3px;z-index:9997;overflow:visible;cursor:move;'); toolbar. addEventListener ('mousedown', this, false); var clse = toolbar. firstChild; this. clse = clse; clse. setAttribute ('style', 'float:right;background:white;padding:0;margin:0;border:none;cursor:pointer;'); clse. addEventListener ('click', this, false); var textbar = toolbar. lastChild; textbar. innerHTML = txt; textbar. setAttribute ('style', 'display:block;border:1px solid #aaaaaa;margin:2px 0 0 0;padding:4px;background-color:#fafcfe;font:14px Times New Roman;height:' + h + 'px;width:auto;overflow:auto;cursor:text;'); doc. documentElement. appendChild (toolbar); var halfWidth = parseInt (toolbar. offsetWidth / 2); var strict = doc. compatMode == 'CSS1Compat'; var mX = (strict? doc. documentElement. clientWidth: doc. body. clientWidth) - toolbar. offsetWidth; var mY = (strict? doc. documentElement. clientHeight: doc. body. clientHeight) - toolbar. offsetHeight; var lastClickX = win. cbTranslateButton2X; var lastClickY = win. cbTranslateButton2Y; toolbar. style. left = ((lastClickX < mX + halfWidth)? (lastClickX > halfWidth? (lastClickX - halfWidth): 0): mX) + "px"; toolbar. style. top = ((lastClickY < mY)? lastClickY: mY) + "px"; toolbar. style. visibility = 'visible'; return textbar; }, frameOnLoad: function (event) { var fr = event. currentTarget; fr. removeEventListener ('load', this, false); var tbId = fr. id. substring (UJS_GOOGLE_TRANSLATE_FRAME_ID. length); var toolbar = this. doc. getElementById (UJS_TOOLBAR_ID + tbId); var frdoc = fr. contentDocument; var a = frdoc. getElementById ('autotrans'); var title = (a && !/#808080/. test (a. innerHTML))? ' - ' + a. textContent. replace (/^.+: | [(\xBB].+$/g, ''): ''; var result = frdoc. getElementById ('result_box'). innerHTML; var ancor = toolbar. getElementsByTagName ("a") [0]; ancor. innerHTML += title; ancor. nextSibling. innerHTML = result; setTimeout ( function () { fr. parentNode. removeChild (fr); }, 0 ); }, google_translate: function (language) { var doc = this. doc; var win = this. win; var t = document. commandDispatcher. focusedWindow. getSelection (). toString (); var lng = (win. navigator. language == 'ru')? 'ru': 'en'; if (t && location. hostname != 'translate.google.com') { this. ujs_createWindow ( (lng == 'ru'? '\u041F\u0435\u0440\u0435\u0432\u043E\u0434\u0438\u043C': 'Подождите идет перевод' ) + '\u2026', '<a href="http://translate.google.com/" target="_blank" style="text-decoration:none;color:#000099;font:16px Times New Roman;">Google перевод</a>', btoa (escape (t)) ); var gtfId = UJS_GOOGLE_TRANSLATE_FRAME_ID; var fr = doc. getElementById (gtfId); if (!fr) fr = doc. createElement ('iframe'); this. frame = fr; fr. setAttribute ('id', gtfId + btoa (escape (t))); fr. setAttribute ('frameborder', '0'); fr. setAttribute ('style', 'width:0px;height:0px;visibility:hidden;position:absolute;left:-999em;'); fr. setAttribute ( 'src', 'http://translate.google.com/translate_t?text=' + encodeURIComponent (t) + '&hl=' + lng + '&langpair=' + language + '&tbb=1&ujs=gtt' ); fr. addEventListener ('load', this, false); doc. documentElement. appendChild (fr); } } }; var ct = getBrowser (). selectedTab; if (!ct. cbTranslateButton5) ct. cbTranslateButton5 = []; var translator = new cbTranslatorButton (getBrowser ()); ct. cbTranslateButton5. push (translator); translator. google_translate ("auto|ru"); } //------------------------------------------------------ //------------------------------------------------------------------------- })();
Отредактировано Andrey_Krropotkin (08-02-2012 22:57:34)
Отсутствует
Andrey_Krropotkin
спс
не забудьте иконку сделать
зачем? она же в инициализацию к любой другой кн. а иконка для кон.меню в ней есть.
Отсутствует
Andrey_Krropotkin
Хорошая кнопка но видно что в ней много лишнего кода:
это не нужно
var clipboard = Components.classes["@mozilla.org/widget/clipboardhelper;1"]. getService(Components.interfaces.nsIClipboardHelper);
это тоже не нужно
это можно объявить только один раз
результат:
var gtlnkicon="data:image/gif;base64,R0lGODlhEAAQALMOAMz//8zM/5nM/2ZmzGZmmZmZzMyZzMzMmZmZ/5mZmQAAAP///2Zm/wD/AP///wAAACH5BAHoAw4ALAAAAAAQABAAAARw0EkJgghgajlIMQUxjMZmeNIhiYSGEEmwOUQrIUMiKXy/EYpJkOcIajob4izBTBR2xk1hQU20lJvEQrHQAo2BsERLrfJGCIYtwdsq2ER1yZFo2O26iXzMaygaeQ4BQHMEd3Y1BGo1hYmJAQsHKgRzEQA7"; var gticon="data:image/gif;base64,R0lGODlhEAAQALMMAMz//8zM/5nM/2ZmzGZmmZmZzMyZzJmZ/8zMmZmZmQAAAGZm/////wAAAAAAAAAAACH5BAHoAwwALAAAAAAQABAAAARbkEkJgghgajlIMQUxjMZmeBIiiYR2EEmwMUQrHUMiKXy/EYpJkMcIajob4qyWNP6cO+gEqVEGrhxCSagYHRa2ka3oA28DrK3GrKmJ1GiFmoFm1cC1+UQmQ6g0EQA7"; var promticon="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAADQ0lEQVQ4jX2TX2xTdRTHT7O4GWL0gSwKmphoi3SsdFXHZiRjDExGSIxGHoTgwzDAUoM4skgEE6ckmiiEB2D8GYqbo2LLrmxZ51rWlob+W1e2ua2z2tp1ZVzrunZr161r7/3drw9TCLr4Sc7b+Zycc3IO0QNkY4M333LrD19zGbSc64aWc/VoOZepnnOZD3KuHi3nNB9rCQQcW2kl7CPjH3tPF7OUjpAxEbKDhNwEQUgSxBRBiD8GYWY/UlONzHO76YJery+4LwcmJmrHZtL5tlOVmGsjzPcQFgcIuRBBmCaIaYKYJIip18HyHiylv2Ae5wUtERGFef5ZZzQWS4sSmjgO060yzB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dGcbexAQ+3LyB/UQCuqLgy+EharUanrlcfCAny5ihwC6FVMaQjB2ZMYjcICMMdWwM1WoVT0UnH9gKh43ASWE7zAhhK0RIErJSELquY8l5ng9s0mCmrc0QtpkQkkgKIhtkDGBzgNGPSqWCJ93dfCBDo2kKZKXTwpt+RgCZAOH3o0w/97HDwQfWacACp4SAHwpJis+HdYbXi1KphEd2Ox9I02DabDa+ovh9TYkExlpfn0G6txfFYhGLXV18YJUGcQoYgrcprJGQNvBg1cNwQ9M0LNhsfCBFg7jZ1CIQbjdSDHo8jHw+j4XOTj6w7HIdxE2m34K7Kaww6OEco6oqHlqtfGDObr+WsFg+p1qEJEMUf7GRyfy4ZbGsCH+7O4Jw5p7NdvuBw7Hx2ulsnJQZ9+fnszQ7K/zPXRKEc1MdHdfnrNblJVGsLQYCB62bI3TCqVl5ZBgZAAAAAElFTkSuQmCC"; //Объявляем 'x' ...... var x = gBrowser.mCurrentTab._tPos +1; (function PerevodMenu1(){ const kXULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; var contextMenu = document.getElementById("contentAreaContextMenu"); var separator = document.getElementById("context-searchselect"); var eventTarget = null; var menu = document.createElementNS(kXULNS, "menu"); menu.id = "PerevodMenu1"; menu.setAttribute("label", "Перевести текст"); menu.setAttribute("class", "menu-iconic"); menu.setAttribute("image", lmricon); menu.hidden = true; contextMenu.insertBefore(menu, separator ); var menuPopup = document.createElementNS(kXULNS, "menupopup"); menu.appendChild(menuPopup); var lst = [ { label:"Заменить текст переводом", command:command98, image:gti1con }, { label:"Перевести текст в окне", command:command908, image:gti1con }, { label:"separator" }, { label:"Перевести текст в Google", command:command90, image:gtlnkicon }, { label:"Перевести текст в PROMT", command:command91, image:promticon }, { label:"Перевести текст в Bing Translator", command:command92, image:Bingicon }, { label:"separator" }, { label:"Перевести слово в Яндексе", command:command93, image:Yndicon }, { label:"Перевести слово в Lingvo", command:command94, image:Lingvoicon }, { label:"Перевести слово в Mail.ru", command:command95, image:Malicon }, ]; for(var i = 0, m; m = lst[i]; i++){ if (m.label=="separator"){ var menuItem = document.createElementNS(kXULNS, "menuseparator"); menuItem.id = "context-Demo-Menu-" + m.label.toString(); menuPopup.appendChild(menuItem); } else{ var menuItem = document.createElementNS(kXULNS, "menuitem"); menuItem.setAttribute("label", m.label); menuItem.setAttribute("class", "menuitem-iconic"); menuItem.setAttribute("image", m.image); menuItem.setAttribute("type", "m.radio"); menuItem.addEventListener("command", m.command, false); menuItem.id = "context-Demo-Menu-" + m.label.toString(); menuPopup.appendChild(menuItem); } } contextMenu.addEventListener("popupshowing", setMenuDisplay, false); function setMenuDisplay(aEvent) { if (gContextMenu.isTextSelected) { document.getElementById("PerevodMenu1").hidden = false; } else document.getElementById("PerevodMenu1").hidden = true; } //--------Перевести текст в Google-------------- function command90(){ var t = document.commandDispatcher.focusedWindow.getSelection(); gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://translate.google.com/translate_t?hl=ru#auto|ru|"+t), x); } //---------Перевести текст в PROMT--------------- function command91(){ var t = document.commandDispatcher.focusedWindow.getSelection(); gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://www.translate.ru/?External=IE8Accelerator&formEncoding=utf-8&direction=ar&prmtlang=ru&status=translate&template=General&source="+t), x); } //---------Перевести текст в Bing Translator--------------- function command92(){ var t = document.commandDispatcher.focusedWindow.getSelection(); gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://www.microsofttranslator.com/?ref=IE8Activity&to=ru&SourceText="+t), x); } //----------Перевести слово в Яндексе------------ function command93(){ var t = document.commandDispatcher.focusedWindow.getSelection(); gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://lingvo.yandex.ru/"+t), x); } //-----------Перевести слово в Lingvo-------------- function command94(){ var t = document.commandDispatcher.focusedWindow.getSelection(); gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://lingvopro.abbyyonline.com/ru/Search/en-ru/"+t), x); } //----------Перевести слово в Mail.ru------------ function command95(){ var t = document.commandDispatcher.focusedWindow.getSelection(); gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://lingvo.mail.ru/?lang_id=1033&translate=&text="+t), x); } //----------Заменить текст переводом------------ function command98(){ var t = document.commandDispatcher.focusedWindow.getSelection(); var fullUrl = "http://translate.google.hu/translate_t?text="+t+"&hl=ru"+"&langpair=auto|ru&tbb=1" ; function removeHTMLTags(mitkell) { //clean up a string from html tags var strInputCode = mitkell; var strTagStrippedText = strInputCode.replace(/<\/?[^>]+(>|$)/g, ""); return strTagStrippedText; } function infoReceived() { // if there is response from Google then write out translation var output = httpRequest.responseText; if (output.length) { // Build the output string from Google Page output = output.replace(/"/gi,'"'); output = output.replace(/</gi,'<'); output = output.replace(/>/gi,'>'); output = output.replace(/&/gi,'&'); output = output.replace(/'/gi,"'"); var fieldArray = output.split('</head>'); if (fieldArray[1].search('class="short_text"')!=-1) { var tempResz = fieldArray[1].split('<span id=result_box class="short_text">'); } else if (fieldArray[1].search('class="medium_text"')!=-1) { var tempResz = fieldArray[1].split('<span id=result_box class="medium_text">'); } else { var tempResz = fieldArray[1].split('<span id=result_box class="long_text">'); } var kimenet = tempResz[1].split('</span></div>'); var range = content.getSelection().getRangeAt(0); range.deleteContents(); range.insertNode(document.createTextNode(removeHTMLTags(kimenet[0]))); } } httpRequest = new XMLHttpRequest(); httpRequest.open("GET", fullUrl, true); httpRequest.onload = infoReceived; httpRequest.send(null); } //----------Перевести текст в окне------------ function command908(){ const UJS_TOOLBAR_ID = "ujs_toolbar"; const UJS_GOOGLE_TRANSLATE_FRAME_ID = "ujs_googletranslateframe"; function cbTranslatorButton (browser) { this. doc = browser. contentDocument; this. win = browser. contentDocument. defaultView; } cbTranslatorButton. prototype = { doc: null, win: null, toolbar: null, clse: null, frame: null, grabX: 0, origX: 0, grabY: 0, origY: 0, handleEvent: function (event) { switch (event. type) { case "mousedown": this. tbOnMouseDown (event); break; case "mousemove": this. tbOnMouseMove (event); break; case "mouseup": this. tbOnMouseUp (event); break; case "click": this. clseOnClick (event); break; case "load": this. frameOnLoad (event); break; default:; } }, tbOnMouseMove: function (event) { this. toolbar. style. left = this. origX + event. clientX - this. grabX + 'px'; this. toolbar. style. top = this. origY + event. clientY - this. grabY + 'px'; }, tbOnMouseUp: function (event) { this. doc. removeEventListener ('mousemove', this, false); this. toolbar. style. zIndex = 9997; }, tbOnMouseDown: function (event) { if (event. target == this. toolbar) { event. preventDefault (); this. toolbar. style. zIndex = 9998; this. grabX = event. clientX; this. grabY = event. clientY; this. origX = parseInt (this. toolbar. style. left); this. origY = parseInt (this. toolbar. style. top); this. doc. addEventListener ('mousemove', this, false); this. doc. addEventListener ('mouseup', this, false); } }, removeEventListener: function (element, eventType, captureFlag) { try { element. removeEventListener (eventType, this, captureFlag); } catch (err) {} }, removeElement: function (element) { try { element. parentNode. removeChild (element); } catch (err) {} }, clseOnClick: function (event) { this. clse. removeEventListener ('click', this, false); this. removeEventListener (this. toolbar, 'mousedown', false); this. removeEventListener (this. doc, 'mousemove', false); this. removeEventListener (this. doc, 'mouseup', false); this. removeEventListener (this. frame, 'load', false); this. removeElement (this. toolbar); this. removeElement (this. frame); this. frame = null; this. clse = null; this. toolbar = null; this. win = null; this. doc = null; }, ujs_createWindow: function (txt) { var doc = this. doc; var win = this. win; var h, w; var txtLen = txt. length; var tbId = UJS_TOOLBAR_ID; if (arguments. length > 2) tbId += arguments [2]; var toolbar = doc. getElementById (tbId); if (toolbar) toolbar. parentNode. removeChild (toolbar); toolbar = doc. createElement ('div'); this. toolbar = toolbar; toolbar. id = tbId; if (arguments. length == 5) { w = arguments [3]; h = arguments [4] } else { h = 15; w = 20; if (txtLen > 2000) { h = 50; w = 66 } else if (txtLen > 250) { h = 25; w = 33 }; h = parseInt (h * win. innerHeight / 30); w = parseInt (w * win. innerWidth / 50) }; var title = (arguments. length > 1) ?arguments [1]: '<a href="http://translate.google.com/" target="_blank" style="text-decoration:none;color:#000099;font:16px Times New Roman;">Google Translate</a>'; toolbar. innerHTML = '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAABh0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjIyt5EXfQAAAStJREFUOE+1k9tqhDAQhtOHqO37P4E3IlQFQQSvBBVEl1TBVVi1B+1C8XAx3QmNqIVqhBV+DEPmy8z8ycPX9Ruq6kLqqiRHvkfpiUjSMyGUJtB1HfR9D8MwCAlz6voNkEGCIGDJeZ5DURTCatoWNE0D4nk+jOMoDMBD8fDPpoGXu4OyLAPUutV1/N+KcPPNPaY4jidYktwG+hunlLL4ZmsI4EloxhxiGAY4jgNpmm6D8DQEcBj/I8SyrKnSzYr4bDzPm2CKoiwgu1rDTfN2eEWu6y4M2KxoPRNVVRcz4xXvdm0+k/nMwjDc5xraa9v2n5kgwDRNMdfQXtT6Us7jy9Z8n738Iw82O5/hUpag6zqQ0+kVmqZld0NUURSxl48M8v5xZQtZlg8Jc5HxA5fIE73hTda3AAAAAElFTkSuQmCC" title="Close" width="18" height="18"> ' + title + '<div></div>'; toolbar. setAttribute('style', 'position:fixed;background:white;display:block;visibility:hidden;left:0;top:0;height:auto;width:' + w + 'px;font:16px Times New Roman;border:1px solid gray;padding:3px;z-index:9997;overflow:visible;cursor:move;'); toolbar. addEventListener ('mousedown', this, false); var clse = toolbar. firstChild; this. clse = clse; clse. setAttribute ('style', 'float:right;background:white;padding:0;margin:0;border:none;cursor:pointer;'); clse. addEventListener ('click', this, false); var textbar = toolbar. lastChild; textbar. innerHTML = txt; textbar. setAttribute ('style', 'display:block;border:1px solid #aaaaaa;margin:2px 0 0 0;padding:4px;background-color:#fafcfe;font:14px Times New Roman;height:' + h + 'px;width:auto;overflow:auto;cursor:text;'); doc. documentElement. appendChild (toolbar); var halfWidth = parseInt (toolbar. offsetWidth / 2); var strict = doc. compatMode == 'CSS1Compat'; var mX = (strict? doc. documentElement. clientWidth: doc. body. clientWidth) - toolbar. offsetWidth; var mY = (strict? doc. documentElement. clientHeight: doc. body. clientHeight) - toolbar. offsetHeight; var lastClickX = win. cbTranslateButton2X; var lastClickY = win. cbTranslateButton2Y; toolbar. style. left = ((lastClickX < mX + halfWidth)? (lastClickX > halfWidth? (lastClickX - halfWidth): 0): mX) + "px"; toolbar. style. top = ((lastClickY < mY)? lastClickY: mY) + "px"; toolbar. style. visibility = 'visible'; return textbar; }, frameOnLoad: function (event) { var fr = event. currentTarget; fr. removeEventListener ('load', this, false); var tbId = fr. id. substring (UJS_GOOGLE_TRANSLATE_FRAME_ID. length); var toolbar = this. doc. getElementById (UJS_TOOLBAR_ID + tbId); var frdoc = fr. contentDocument; var a = frdoc. getElementById ('autotrans'); var title = (a && !/#808080/. test (a. innerHTML))? ' - ' + a. textContent. replace (/^.+: | [(\xBB].+$/g, ''): ''; var result = frdoc. getElementById ('result_box'). innerHTML; var ancor = toolbar. getElementsByTagName ("a") [0]; ancor. innerHTML += title; ancor. nextSibling. innerHTML = result; setTimeout ( function () { fr. parentNode. removeChild (fr); }, 0 ); }, google_translate: function (language) { var doc = this. doc; var win = this. win; var t = document. commandDispatcher. focusedWindow. getSelection (). toString (); var lng = (win. navigator. language == 'ru')? 'ru': 'en'; if (t && location. hostname != 'translate.google.com') { this. ujs_createWindow ( (lng == 'ru'? '\u041F\u0435\u0440\u0435\u0432\u043E\u0434\u0438\u043C': 'Подождите идет перевод' ) + '\u2026', '<a href="http://translate.google.com/" target="_blank" style="text-decoration:none;color:#000099;font:16px Times New Roman;">Google перевод</a>', btoa (escape (t)) ); var gtfId = UJS_GOOGLE_TRANSLATE_FRAME_ID; var fr = doc. getElementById (gtfId); if (!fr) fr = doc. createElement ('iframe'); this. frame = fr; fr. setAttribute ('id', gtfId + btoa (escape (t))); fr. setAttribute ('frameborder', '0'); fr. setAttribute ('style', 'width:0px;height:0px;visibility:hidden;position:absolute;left:-999em;'); fr. setAttribute ( 'src', 'http://translate.google.com/translate_t?text=' + encodeURIComponent (t) + '&hl=' + lng + '&langpair=' + language + '&tbb=1&ujs=gtt' ); fr. addEventListener ('load', this, false); doc. documentElement. appendChild (fr); } } }; var ct = getBrowser (). selectedTab; if (!ct. cbTranslateButton5) ct. cbTranslateButton5 = []; var translator = new cbTranslatorButton (getBrowser ()); ct. cbTranslateButton5. push (translator); translator. google_translate ("auto|ru"); } })();
Отредактировано bunda1 (08-02-2012 21:46:05)
Отсутствует
okkamas_knife, bunda1 спасибо за советы, пытаюсь еще упростить, правда добавил перевод из контекстного меню: страницы и URL. bunda1 посмотри, можно еще что упростить?
/*Initialization Code*/ var gtlnkicon="data:image/gif;base64,R0lGODlhEAAQALMOAMz//8zM/5nM/2ZmzGZmmZmZzMyZzMzMmZmZ/5mZmQAAAP///2Zm/wD/AP///wAAACH5BAHoAw4ALAAAAAAQABAAAARw0EkJgghgajlIMQUxjMZmeNIhiYSGEEmwOUQrIUMiKXy/EYpJkOcIajob4izBTBR2xk1hQU20lJvEQrHQAo2BsERLrfJGCIYtwdsq2ER1yZFo2O26iXzMaygaeQ4BQHMEd3Y1BGo1hYmJAQsHKgRzEQA7"; var gticon="data:image/gif;base64,R0lGODlhEAAQALMMAMz//8zM/5nM/2ZmzGZmmZmZzMyZzJmZ/8zMmZmZmQAAAGZm/////wAAAAAAAAAAACH5BAHoAwwALAAAAAAQABAAAARbkEkJgghgajlIMQUxjMZmeBIiiYR2EEmwMUQrHUMiKXy/EYpJkMcIajob4qyWNP6cO+gEqVEGrhxCSagYHRa2ka3oA28DrK3GrKmJ1GiFmoFm1cC1+UQmQ6g0EQA7"; var promticon="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAADQ0lEQVQ4jX2TX2xTdRTHT7O4GWL0gSwKmphoi3SsdFXHZiRjDExGSIxGHoTgwzDAUoM4skgEE6ck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AAAQCAYAAAAf8/9hAAACBElEQVR42o2Sy04TYRiGJ+oFtNANKaXFTmmhB+i0DGBpNbIQ2ZpwCV6ArlwYbwA35ZDYHXFjIqh4DCalFKZIoQwWp6YxdlGSSjKLYuyiST28fP9UFPpr9Eue3fs8k0x+Qfh52uWo/P7q+MfCxRi0Y2JRvGNERw32RhkR5CORgtB6hfErn6rJ5NdGo4F/8cLj+c4F8rHot9zkJPbvTkF/9RK1chn1ev2PPO/pARfYGR7CbHs73l4YMdgdGcbexAQ+3LyB/UQCuqLgy+EharUanrlcfCAny5ihwC6FVMaQjB2ZMYjcICMMdWwM1WoVT0UnH9gKh43ASWE7zAhhK0RIErJSELquY8l5ng9s0mCmrc0QtpkQkkgKIhtkDGBzgNGPSqWCJ93dfCBDo2kKZKXTwpt+RgCZAOH3o0w/97HDwQfWacACp4SAHwpJis+HdYbXi1KphEd2Ox9I02DabDa+ovh9TYkExlpfn0G6txfFYhGLXV18YJUGcQoYgrcprJGQNvBg1cNwQ9M0LNhsfCBFg7jZ1CIQbjdSDHo8jHw+j4XOTj6w7HIdxE2m34K7Kaww6OEco6oqHlqtfGDObr+WsFg+p1qEJEMUf7GRyfy4ZbGsCH+7O4Jw5p7NdvuBw7Hx2ulsnJQZ9+fnszQ7K/zPXRKEc1MdHdfnrNblJVGsLQYCB62bI3TCqVl5ZBgZAAAAAElFTkSuQmCC"; //Объявляем 'x' ...... var x = gBrowser.mCurrentTab._tPos +1; const kXULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; var contextMenu = document.getElementById("contentAreaContextMenu"); var separator = document.getElementById("context-searchselect"); var eventTarget = null; (function PerevodMenu(){ var menu = document.createElementNS(kXULNS, "menu"); menu.id = "PerevodMenu"; menu.setAttribute("label", "Перевести ссылку"); menu.setAttribute("class", "menu-iconic"); menu.setAttribute("image", lmricon); menu.hidden = true; contextMenu.insertBefore(menu, separator ); var menuPopup = document.createElementNS(kXULNS, "menupopup"); menu.appendChild(menuPopup); var lst = [ { label:"Перевести ссылку в Google", command:command901, image:gticon }, { label:"Перевести ссылку в Яндексе", command:command902, image:Yndicon }, { label:"Перевести ссылку в PROMT", command:command903, image:promticon }, { label:"Перевести ссылку в Bing Translator", command:command904, image:Bingicon }, { label:"separator" }, { label:"Перевести текст ссылки в Google", command:command905, image:gtlnkicon }, ]; for(var i = 0, m; m = lst[i]; i++){ if (m.label=="separator"){ var menuItem = document.createElementNS(kXULNS, "menuseparator"); menuItem.id = "context-Demo-Menu-" + m.label.toString(); menuPopup.appendChild(menuItem); } else{ var menuItem = document.createElementNS(kXULNS, "menuitem"); menuItem.setAttribute("label", m.label); menuItem.setAttribute("class", "menuitem-iconic"); menuItem.setAttribute("image", m.image); menuItem.setAttribute("type", "m.radio"); menuItem.addEventListener("command", m.command, false); menuItem.id = "context-Demo-Menu-" + m.label.toString(); menuPopup.appendChild(menuItem); } } contextMenu.addEventListener("popupshowing", setMenuDisplay, false); function setMenuDisplay(aEvent) { if (gContextMenu.onLink) { document.getElementById("PerevodMenu").hidden = false; } else document.getElementById("PerevodMenu").hidden = true; if (gContextMenu.onImage) { document.getElementById("PerevodMenu").hidden = true; } } //---------Перевести ссылку в Google----------------- function command901(){ var urllink= encodeURIComponent(gContextMenu.linkURL); var urltr="http://translate.google.com/?sl=auto&tl=ru&js=n&prev=_t&hl=en&ie=UTF-8&layout=2&eotf=1&text="+urllink; getBrowser (). selectedTab = getBrowser (). addTab (urltr); } //---------Перевести ссылку в Яндексе------------- function command902(){ var urllink= encodeURIComponent(gContextMenu.linkURL); var urltr="http://translate.yandex.ru/translate?srv=yasearch&url="+urllink; getBrowser (). selectedTab = getBrowser (). addTab (urltr); } //-----------Перевести ссылку в PROMT--------------- function command903(){ var urllink= encodeURIComponent(gContextMenu.linkURL); var urltr="http://www.translate.ru/siteTranslation/autolink/?direction=ar&template=General&sourceURL="+urllink; getBrowser (). selectedTab = getBrowser (). addTab (urltr); } //---------Перевести ссылку в Bing Translator-------------- function command904(){ var urllink= encodeURIComponent(gContextMenu.linkURL); var urltr="http://www.microsofttranslator.com/bv.aspx?from=&to=ru&a="+urllink; getBrowser (). selectedTab = getBrowser (). addTab (urltr); } //-------Перевести текст ссылки в Google-------------- function command905(){ var t = gContextMenu.linkText(); var x = gBrowser.mCurrentTab._tPos +1; gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://translate.google.com/translate_t?hl=ru#auto|ru|"+t), x); } })(); (function PerevodMenu1(){ var menu = document.createElementNS(kXULNS, "menu"); menu.id = "PerevodMenu1"; menu.setAttribute("label", "Перевести текст"); menu.setAttribute("class", "menu-iconic"); menu.setAttribute("image", lmricon); menu.hidden = true; contextMenu.insertBefore(menu, separator ); var menuPopup = document.createElementNS(kXULNS, "menupopup"); menu.appendChild(menuPopup); var lst = [ { label:"Заменить текст переводом", command:command907, image:gti1con }, { label:"Перевести текст в окне", command:command908, image:gti1con }, { label:"separator" }, { label:"Перевести текст в Google", command:command909, image:gtlnkicon }, { label:"Перевести текст в PROMT", command:command910, image:promticon }, { label:"Перевести текст в Bing Translator", command:command911, image:Bingicon }, { label:"separator" }, { label:"Перевести слово в Яндексе", command:command912, image:Yndicon }, { label:"Перевести слово в Lingvo", command:command913, image:Lingvoicon }, { label:"Перевести слово в Mail.ru", command:command914, image:Malicon }, ]; for(var i = 0, m; m = lst[i]; i++){ if (m.label=="separator"){ var menuItem = document.createElementNS(kXULNS, "menuseparator"); menuItem.id = "context-Demo-Menu-" + m.label.toString(); menuPopup.appendChild(menuItem); } else{ var menuItem = document.createElementNS(kXULNS, "menuitem"); menuItem.setAttribute("label", m.label); menuItem.setAttribute("class", "menuitem-iconic"); menuItem.setAttribute("image", m.image); menuItem.setAttribute("type", "m.radio"); menuItem.addEventListener("command", m.command, false); menuItem.id = "context-Demo-Menu-" + m.label.toString(); menuPopup.appendChild(menuItem); } } contextMenu.addEventListener("popupshowing", setMenuDisplay, false); function setMenuDisplay(aEvent) { if (gContextMenu.isTextSelected) { document.getElementById("PerevodMenu1").hidden = false; } else document.getElementById("PerevodMenu1").hidden = true; if (gContextMenu.onLink) { document.getElementById("PerevodMenu1").hidden = true; } } //----------Заменить текст переводом------------ function command907(){ var clipboard = Components.classes["@mozilla.org/widget/clipboardhelper;1"]. getService(Components.interfaces.nsIClipboardHelper); var t = document.commandDispatcher.focusedWindow.getSelection(); var fullUrl = "http://translate.google.hu/translate_t?text="+t+"&hl=ru"+"&langpair=auto|ru&tbb=1" ; function removeHTMLTags(mitkell) { //clean up a string from html tags var strInputCode = mitkell; var strTagStrippedText = strInputCode.replace(/<\/?[^>]+(>|$)/g, ""); return strTagStrippedText; } function infoReceived() { // if there is response from Google then write out translation var output = httpRequest.responseText; if (output.length) { // Build the output string from Google Page output = output.replace(/"/gi,'"'); output = output.replace(/</gi,'<'); output = output.replace(/>/gi,'>'); output = output.replace(/&/gi,'&'); output = output.replace(/'/gi,"'"); var fieldArray = output.split('</head>'); if (fieldArray[1].search('class="short_text"')!=-1) { var tempResz = fieldArray[1].split('<span id=result_box class="short_text">'); } else if (fieldArray[1].search('class="medium_text"')!=-1) { var tempResz = fieldArray[1].split('<span id=result_box class="medium_text">'); } else { var tempResz = fieldArray[1].split('<span id=result_box class="long_text">'); } var kimenet = tempResz[1].split('</span></div>'); var range = content.getSelection().getRangeAt(0); range.deleteContents(); range.insertNode(document.createTextNode(removeHTMLTags(kimenet[0]))); } } httpRequest = new XMLHttpRequest(); httpRequest.open("GET", fullUrl, true); httpRequest.onload = infoReceived; httpRequest.send(null); } //----------Перевести текст в окне------------ function command908(){ const UJS_TOOLBAR_ID = "ujs_toolbar"; const UJS_GOOGLE_TRANSLATE_FRAME_ID = "ujs_googletranslateframe"; function cbTranslatorButton (browser) { this. doc = browser. contentDocument; this. win = browser. contentDocument. defaultView; } cbTranslatorButton. prototype = { doc: null, win: null, toolbar: null, clse: null, frame: null, grabX: 0, origX: 0, grabY: 0, origY: 0, handleEvent: function (event) { switch (event. type) { case "mousedown": this. tbOnMouseDown (event); break; case "mousemove": this. tbOnMouseMove (event); break; case "mouseup": this. tbOnMouseUp (event); break; case "click": this. clseOnClick (event); break; case "load": this. frameOnLoad (event); break; default:; } }, tbOnMouseMove: function (event) { this. toolbar. style. left = this. origX + event. clientX - this. grabX + 'px'; this. toolbar. style. top = this. origY + event. clientY - this. grabY + 'px'; }, tbOnMouseUp: function (event) { this. doc. removeEventListener ('mousemove', this, false); this. toolbar. style. zIndex = 9997; }, tbOnMouseDown: function (event) { if (event. target == this. toolbar) { event. preventDefault (); this. toolbar. style. zIndex = 9998; this. grabX = event. clientX; this. grabY = event. clientY; this. origX = parseInt (this. toolbar. style. left); this. origY = parseInt (this. toolbar. style. top); this. doc. addEventListener ('mousemove', this, false); this. doc. addEventListener ('mouseup', this, false); } }, removeEventListener: function (element, eventType, captureFlag) { try { element. removeEventListener (eventType, this, captureFlag); } catch (err) {} }, removeElement: function (element) { try { element. parentNode. removeChild (element); } catch (err) {} }, clseOnClick: function (event) { this. clse. removeEventListener ('click', this, false); this. removeEventListener (this. toolbar, 'mousedown', false); this. removeEventListener (this. doc, 'mousemove', false); this. removeEventListener (this. doc, 'mouseup', false); this. removeEventListener (this. frame, 'load', false); this. removeElement (this. toolbar); this. removeElement (this. frame); this. frame = null; this. clse = null; this. toolbar = null; this. win = null; this. doc = null; }, ujs_createWindow: function (txt) { var doc = this. doc; var win = this. win; var h, w; var txtLen = txt. length; var tbId = UJS_TOOLBAR_ID; if (arguments. length > 2) tbId += arguments [2]; var toolbar = doc. getElementById (tbId); if (toolbar) toolbar. parentNode. removeChild (toolbar); toolbar = doc. createElement ('div'); this. toolbar = toolbar; toolbar. id = tbId; if (arguments. length == 5) { w = arguments [3]; h = arguments [4] } else { h = 15; w = 20; if (txtLen > 2000) { h = 50; w = 66 } else if (txtLen > 250) { h = 25; w = 33 }; h = parseInt (h * win. innerHeight / 30); w = parseInt (w * win. innerWidth / 50) }; var title = (arguments. length > 1) ?arguments [1]: '<a href="http://translate.google.com/" target="_blank" style="text-decoration:none;color:#000099;font:16px Times New Roman;">Google Translate</a>'; toolbar. innerHTML = '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAABh0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjIyt5EXfQAAAStJREFUOE+1k9tqhDAQhtOHqO37P4E3IlQFQQSvBBVEl1TBVVi1B+1C8XAx3QmNqIVqhBV+DEPmy8z8ycPX9Ruq6kLqqiRHvkfpiUjSMyGUJtB1HfR9D8MwCAlz6voNkEGCIGDJeZ5DURTCatoWNE0D4nk+jOMoDMBD8fDPpoGXu4OyLAPUutV1/N+KcPPNPaY4jidYktwG+hunlLL4ZmsI4EloxhxiGAY4jgNpmm6D8DQEcBj/I8SyrKnSzYr4bDzPm2CKoiwgu1rDTfN2eEWu6y4M2KxoPRNVVRcz4xXvdm0+k/nMwjDc5xraa9v2n5kgwDRNMdfQXtT6Us7jy9Z8n738Iw82O5/hUpag6zqQ0+kVmqZld0NUURSxl48M8v5xZQtZlg8Jc5HxA5fIE73hTda3AAAAAElFTkSuQmCC" title="Close" width="18" height="18"> ' + title + '<div></div>'; toolbar. setAttribute('style', 'position:fixed;background:white;display:block;visibility:hidden;left:0;top:0;height:auto;width:' + w + 'px;font:16px Times New Roman;border:1px solid gray;padding:3px;z-index:9997;overflow:visible;cursor:move;'); toolbar. addEventListener ('mousedown', this, false); var clse = toolbar. firstChild; this. clse = clse; clse. setAttribute ('style', 'float:right;background:white;padding:0;margin:0;border:none;cursor:pointer;'); clse. addEventListener ('click', this, false); var textbar = toolbar. lastChild; textbar. innerHTML = txt; textbar. setAttribute ('style', 'display:block;border:1px solid #aaaaaa;margin:2px 0 0 0;padding:4px;background-color:#fafcfe;font:14px Times New Roman;height:' + h + 'px;width:auto;overflow:auto;cursor:text;'); doc. documentElement. appendChild (toolbar); var halfWidth = parseInt (toolbar. offsetWidth / 2); var strict = doc. compatMode == 'CSS1Compat'; var mX = (strict? doc. documentElement. clientWidth: doc. body. clientWidth) - toolbar. offsetWidth; var mY = (strict? doc. documentElement. clientHeight: doc. body. clientHeight) - toolbar. offsetHeight; var lastClickX = win. cbTranslateButton2X; var lastClickY = win. cbTranslateButton2Y; toolbar. style. left = ((lastClickX < mX + halfWidth)? (lastClickX > halfWidth? (lastClickX - halfWidth): 0): mX) + "px"; toolbar. style. top = ((lastClickY < mY)? lastClickY: mY) + "px"; toolbar. style. visibility = 'visible'; return textbar; }, frameOnLoad: function (event) { var fr = event. currentTarget; fr. removeEventListener ('load', this, false); var tbId = fr. id. substring (UJS_GOOGLE_TRANSLATE_FRAME_ID. length); var toolbar = this. doc. getElementById (UJS_TOOLBAR_ID + tbId); var frdoc = fr. contentDocument; var a = frdoc. getElementById ('autotrans'); var title = (a && !/#808080/. test (a. innerHTML))? ' - ' + a. textContent. replace (/^.+: | [(\xBB].+$/g, ''): ''; var result = frdoc. getElementById ('result_box'). innerHTML; var ancor = toolbar. getElementsByTagName ("a") [0]; ancor. innerHTML += title; ancor. nextSibling. innerHTML = result; setTimeout ( function () { fr. parentNode. removeChild (fr); }, 0 ); }, google_translate: function (language) { var doc = this. doc; var win = this. win; var t = document. commandDispatcher. focusedWindow. getSelection (). toString (); var lng = (win. navigator. language == 'ru')? 'ru': 'en'; if (t && location. hostname != 'translate.google.com') { this. ujs_createWindow ( (lng == 'ru'? '\u041F\u0435\u0440\u0435\u0432\u043E\u0434\u0438\u043C': 'Подождите идет перевод' ) + '\u2026', '<a href="http://translate.google.com/" target="_blank" style="text-decoration:none;color:#000099;font:16px Times New Roman;">Google перевод</a>', btoa (escape (t)) ); var gtfId = UJS_GOOGLE_TRANSLATE_FRAME_ID; var fr = doc. getElementById (gtfId); if (!fr) fr = doc. createElement ('iframe'); this. frame = fr; fr. setAttribute ('id', gtfId + btoa (escape (t))); fr. setAttribute ('frameborder', '0'); fr. setAttribute ('style', 'width:0px;height:0px;visibility:hidden;position:absolute;left:-999em;'); fr. setAttribute ( 'src', 'http://translate.google.com/translate_t?text=' + encodeURIComponent (t) + '&hl=' + lng + '&langpair=' + language + '&tbb=1&ujs=gtt' ); fr. addEventListener ('load', this, false); doc. documentElement. appendChild (fr); } } }; var ct = getBrowser (). selectedTab; if (!ct. cbTranslateButton5) ct. cbTranslateButton5 = []; var translator = new cbTranslatorButton (getBrowser ()); ct. cbTranslateButton5. push (translator); translator. google_translate ("auto|ru"); } //--------Перевести текст в Google-------------- function command909(){ var t = document.commandDispatcher.focusedWindow.getSelection(); gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://translate.google.com/translate_t?hl=ru#auto|ru|"+t), x); } //---------Перевести текст в PROMT--------------- function command910(){ var t = document.commandDispatcher.focusedWindow.getSelection(); gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://www.translate.ru/?External=IE8Accelerator&formEncoding=utf-8&direction=ar&prmtlang=ru&status=translate&template=General&source="+t), x); } //---------Перевести текст в Bing Translator--------------- function command911(){ var t = document.commandDispatcher.focusedWindow.getSelection(); gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://www.microsofttranslator.com/?ref=IE8Activity&to=ru&SourceText="+t), x); } //----------Перевести слово в Яндексе------------ function command912(){ var t = document.commandDispatcher.focusedWindow.getSelection(); gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://lingvo.yandex.ru/"+t), x); } //-----------Перевести слово в Lingvo-------------- function command913(){ var t = document.commandDispatcher.focusedWindow.getSelection(); gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://lingvopro.abbyyonline.com/ru/Search/en-ru/"+t), x); } //----------Перевести слово в Mail.ru------------ function command914(){ var t = document.commandDispatcher.focusedWindow.getSelection(); gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://lingvo.mail.ru/?lang_id=1033&translate=&text="+t), x); } })(); (function PerevodMenu2(){ var menu = document.createElementNS(kXULNS, "menu"); menu.id = "PerevodMenu2"; menu.setAttribute("label", "Перевести страницу"); menu.setAttribute("class", "menu-iconic"); menu.setAttribute("image", lmricon); menu.hidden = true; contextMenu.insertBefore(menu, separator ); var menuPopup = document.createElementNS(kXULNS, "menupopup"); menu.appendChild(menuPopup); var lst = [ { label:"Перевести страницу в Google", command:command921, image:gticon }, { label:"Перевести страницу в Яндексе", command:command922, image:Yndicon }, { label:"Перевести страницу в PROMT", command:command923, image:promticon }, { label:"Перевести страницу в Bing Translator", command:command924, image:Bingicon }, ]; for(var i = 0, m; m = lst[i]; i++){ if (m.label=="separator"){ var menuItem = document.createElementNS(kXULNS, "menuseparator"); menuItem.id = "context-Demo-Menu-" + m.label.toString(); menuPopup.appendChild(menuItem); } else{ var menuItem = document.createElementNS(kXULNS, "menuitem"); menuItem.setAttribute("label", m.label); menuItem.setAttribute("class", "menuitem-iconic"); menuItem.setAttribute("image", m.image); menuItem.setAttribute("type", "m.radio"); menuItem.addEventListener("command", m.command, false); menuItem.id = "context-Demo-Menu-" + m.label.toString(); menuPopup.appendChild(menuItem); } } contextMenu.addEventListener("popupshowing", setMenuDisplay, false); function setMenuDisplay(aEvent) { if (gContextMenu.onLink) { document.getElementById("PerevodMenu2").hidden = true; } else document.getElementById("PerevodMenu2").hidden = false; if (gContextMenu.onImage) { document.getElementById("PerevodMenu2").hidden = true; } if (gContextMenu.isTextSelected) { document.getElementById("PerevodMenu2").hidden = true; } } //---------Перевести страницу в Google----------------- function command921(){ var urllink= encodeURIComponent(content.document.location.href); var urltr="http://translate.google.com/?sl=auto&tl=ru&js=n&prev=_t&hl=en&ie=UTF-8&layout=2&eotf=1&text="+urllink; getBrowser (). selectedTab = getBrowser (). addTab (urltr); } //---------Перевести страницу в Яндексе------------- function command922(){ var urllink= encodeURIComponent(content.document.location.href); var urltr="http://translate.yandex.ru/translate?srv=yasearch&url="+urllink; getBrowser (). selectedTab = getBrowser (). addTab (urltr); } //-----------Перевести страницу в PROMT--------------- function command923(){ var urllink= encodeURIComponent(content.document.location.href); var urltr="http://www.translate.ru/siteTranslation/autolink/?direction=ar&template=General&sourceURL="+urllink; getBrowser (). selectedTab = getBrowser (). addTab (urltr); } //---------Перевести страницу в Bing Translator-------------- function command924(){ var urllink= encodeURIComponent(content.document.location.href); var urltr="http://www.microsofttranslator.com/bv.aspx?from=&to=ru&a="+urllink; getBrowser (). selectedTab = getBrowser (). addTab (urltr); } })();
Отредактировано Andrey_Krropotkin (08-02-2012 22:56:24)
Отсутствует
bunda1 посмотри, можно еще что упростить?
наверно можно еще упростить
/*Initialization Code*/ var gtlnkicon="data:image/gif;base64,R0lGODlhEAAQALMOAMz//8zM/5nM/2ZmzGZmmZmZzMyZzMzMmZmZ/5mZmQAAAP///2Zm/wD/AP///wAAACH5BAHoAw4ALAAAAAAQABAAAARw0EkJgghgajlIMQUxjMZmeNIhiYSGEEmwOUQrIUMiKXy/EYpJkOcIajob4izBTBR2xk1hQU20lJvEQrHQAo2BsERLrfJGCIYtwdsq2ER1yZFo2O26iXzMaygaeQ4BQHMEd3Y1BGo1hYmJAQsHKgRzEQA7"; var gticon="data:image/gif;base64,R0lGODlhEAAQALMMAMz//8zM/5nM/2ZmzGZmmZmZzMyZzJmZ/8zMmZmZmQAAAGZm/////wAAAAAAAAAAACH5BAHoAwwALAAAAAAQABAAAARbkEkJgghgajlIMQUxjMZmeBIiiYR2EEmwMUQrHUMiKXy/EYpJkMcIajob4qyWNP6cO+gEqVEGrhxCSagYHRa2ka3oA28DrK3GrKmJ1GiFmoFm1cC1+UQmQ6g0EQA7"; var promticon="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAADQ0lEQVQ4jX2TX2xTdRTHT7O4GWL0gSwKmphoi3SsdFXHZiRjDExGSIxGHoTgwzDAUoM4skgEE6ckmiiEB2D8GYqbo2LLrmxZ51rWlob+W1e2ua2z2tp1ZVzrunZr161r7/3drw9TCLr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BpNbIQ2ZpwCV6ArlwYbwA35ZDYHXFjIqh4DCalFKZIoQwWp6YxdlGSSjKLYuyiST28fP9UFPpr9Eue3fs8k0x+Qfh52uWo/P7q+MfCxRi0Y2JRvGNERw32RhkR5CORgtB6hfErn6rJ5NdGo4F/8cLj+c4F8rHot9zkJPbvTkF/9RK1chn1ev2PPO/pARfYGR7CbHs73l4YMdgdGcbexAQ+3LyB/UQCuqLgy+EharUanrlcfCAny5ihwC6FVMaQjB2ZMYjcICMMdWwM1WoVT0UnH9gKh43ASWE7zAhhK0RIErJSELquY8l5ng9s0mCmrc0QtpkQkkgKIhtkDGBzgNGPSqWCJ93dfCBDo2kKZKXTwpt+RgCZAOH3o0w/97HDwQfWacACp4SAHwpJis+HdYbXi1KphEd2Ox9I02DabDa+ovh9TYkExlpfn0G6txfFYhGLXV18YJUGcQoYgrcprJGQNvBg1cNwQ9M0LNhsfCBFg7jZ1CIQbjdSDHo8jHw+j4XOTj6w7HIdxE2m34K7Kaww6OEco6oqHlqtfGDObr+WsFg+p1qEJEMUf7GRyfy4ZbGsCH+7O4Jw5p7NdvuBw7Hx2ulsnJQZ9+fnszQ7K/zPXRKEc1MdHdfnrNblJVGsLQYCB62bI3TCqVl5ZBgZAAAAAElFTkSuQmCC"; //Объявляем 'x', ...... var x = gBrowser.mCurrentTab._tPos +1; const kXULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; var contextMenu = document.getElementById("contentAreaContextMenu"); var separator = document.getElementById("context-searchselect"); var eventTarget = null; (function PerevodMenu(){ var menu = document.createElementNS(kXULNS, "menu"); menu.id = "PerevodMenu"; menu.setAttribute("label", "Перевести ссылку"); menu.setAttribute("class", "menu-iconic"); menu.setAttribute("image", lmricon); menu.hidden = true; contextMenu.insertBefore(menu, separator ); var menuPopup = document.createElementNS(kXULNS, "menupopup"); menu.appendChild(menuPopup); var lst = [ { label:"Перевести ссылку в Google", command:command901, image:gticon }, { label:"Перевести ссылку в Яндексе", command:command902, image:Yndicon }, { label:"Перевести ссылку в PROMT", command:command903, image:promticon }, { label:"Перевести ссылку в Bing Translator", command:command904, image:Bingicon }, { label:"separator" }, { label:"Перевести текст ссылки в Google", command:command905, image:gtlnkicon }, ]; for(var i = 0, m; m = lst[i]; i++){ if (m.label=="separator"){ var menuItem = document.createElementNS(kXULNS, "menuseparator"); menuItem.id = "context-Demo-Menu-" + m.label.toString(); menuPopup.appendChild(menuItem); } else{ var menuItem = document.createElementNS(kXULNS, "menuitem"); menuItem.setAttribute("label", m.label); menuItem.setAttribute("class", "menuitem-iconic"); menuItem.setAttribute("image", m.image); menuItem.setAttribute("type", "m.radio"); menuItem.addEventListener("command", m.command, false); menuItem.id = "context-Demo-Menu-" + m.label.toString(); menuPopup.appendChild(menuItem); } } contextMenu.addEventListener("popupshowing", setMenuDisplay, false); function setMenuDisplay(aEvent) { window.link_xy = encodeURIComponent(gContextMenu.linkURL); if (gContextMenu.onLink && !gContextMenu.onImage) { document.getElementById("PerevodMenu").hidden = false; } else document.getElementById("PerevodMenu").hidden = true; } //---------Перевести ссылку в Google----------------- function command901(){ var urltr="http://translate.google.com/?sl=auto&tl=ru&js=n&prev=_t&hl=en&ie=UTF-8&layout=2&eotf=1&text="+link_xy; getBrowser (). selectedTab = getBrowser (). addTab (urltr); } //---------Перевести ссылку в Яндексе------------- function command902(){ var urltr="http://translate.yandex.ru/translate?srv=yasearch&url="+link_xy; getBrowser (). selectedTab = getBrowser (). addTab (urltr); } //-----------Перевести ссылку в PROMT--------------- function command903(){ var urltr="http://www.translate.ru/siteTranslation/autolink/?direction=ar&template=General&sourceURL="+link_xy; getBrowser (). selectedTab = getBrowser (). addTab (urltr); } //---------Перевести ссылку в Bing Translator-------------- function command904(){ var urltr="http://www.microsofttranslator.com/bv.aspx?from=&to=ru&a="+link_xy; getBrowser (). selectedTab = getBrowser (). addTab (urltr); } //-------Перевести текст ссылки в Google-------------- function command905(){ var t = gContextMenu.linkText(); gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://translate.google.com/translate_t?hl=ru#auto|ru|"+t), x); } })(); (function PerevodMenu1(){ var menu = document.createElementNS(kXULNS, "menu"); menu.id = "PerevodMenu1"; menu.setAttribute("label", "Перевести текст"); menu.setAttribute("class", "menu-iconic"); menu.setAttribute("image", lmricon); menu.hidden = true; contextMenu.insertBefore(menu, separator ); var menuPopup = document.createElementNS(kXULNS, "menupopup"); menu.appendChild(menuPopup); var lst = [ { label:"Заменить текст переводом", command:command907, image:gti1con }, { label:"Перевести текст в окне", command:command908, image:gti1con }, { label:"separator" }, { label:"Перевести текст в Google", command:command909, image:gtlnkicon }, { label:"Перевести текст в PROMT", command:command910, image:promticon }, { label:"Перевести текст в Bing Translator", command:command911, image:Bingicon }, { label:"separator" }, { label:"Перевести слово в Яндексе", command:command912, image:Yndicon }, { label:"Перевести слово в Lingvo", command:command913, image:Lingvoicon }, { label:"Перевести слово в Mail.ru", command:command914, image:Malicon }, ]; for(var i = 0, m; m = lst[i]; i++){ if (m.label=="separator"){ var menuItem = document.createElementNS(kXULNS, "menuseparator"); menuItem.id = "context-Demo-Menu-" + m.label.toString(); menuPopup.appendChild(menuItem); } else{ var menuItem = document.createElementNS(kXULNS, "menuitem"); menuItem.setAttribute("label", m.label); menuItem.setAttribute("class", "menuitem-iconic"); menuItem.setAttribute("image", m.image); menuItem.setAttribute("type", "m.radio"); menuItem.addEventListener("command", m.command, false); menuItem.id = "context-Demo-Menu-" + m.label.toString(); menuPopup.appendChild(menuItem); } } contextMenu.addEventListener("popupshowing", setMenuDisplay, false); function setMenuDisplay(aEvent) { window.t_xy= document.commandDispatcher.focusedWindow.getSelection(); if (!gContextMenu.onImage && !gContextMenu.onLink && gContextMenu.isTextSelected) { document.getElementById("PerevodMenu1").hidden = false; } else document.getElementById("PerevodMenu1").hidden = true; } //----------Заменить текст переводом------------ function command907(){ var fullUrl = "http://translate.google.hu/translate_t?text="+t_xy+"&hl=ru"+"&langpair=auto|ru&tbb=1" ; function removeHTMLTags(mitkell) { //clean up a string from html tags var strInputCode = mitkell; var strTagStrippedText = strInputCode.replace(/<\/?[^>]+(>|$)/g, ""); return strTagStrippedText; } function infoReceived() { // if there is response from Google then write out translation var output = httpRequest.responseText; if (output.length) { // Build the output string from Google Page output = output.replace(/"/gi,'"'); output = output.replace(/</gi,'<'); output = output.replace(/>/gi,'>'); output = output.replace(/&/gi,'&'); output = output.replace(/'/gi,"'"); var fieldArray = output.split('</head>'); if (fieldArray[1].search('class="short_text"')!=-1) { var tempResz = fieldArray[1].split('<span id=result_box class="short_text">'); } else if (fieldArray[1].search('class="medium_text"')!=-1) { var tempResz = fieldArray[1].split('<span id=result_box class="medium_text">'); } else { var tempResz = fieldArray[1].split('<span id=result_box class="long_text">'); } var kimenet = tempResz[1].split('</span></div>'); var range = content.getSelection().getRangeAt(0); range.deleteContents(); range.insertNode(document.createTextNode(removeHTMLTags(kimenet[0]))); } } httpRequest = new XMLHttpRequest(); httpRequest.open("GET", fullUrl, true); httpRequest.onload = infoReceived; httpRequest.send(null); } //----------Перевести текст в окне------------ function command908(){ const UJS_TOOLBAR_ID = "ujs_toolbar"; const UJS_GOOGLE_TRANSLATE_FRAME_ID = "ujs_googletranslateframe"; function cbTranslatorButton (browser) { this. doc = browser. contentDocument; this. win = browser. contentDocument. defaultView; } cbTranslatorButton. prototype = { doc: null, win: null, toolbar: null, clse: null, frame: null, grabX: 0, origX: 0, grabY: 0, origY: 0, handleEvent: function (event) { switch (event. type) { case "mousedown": this. tbOnMouseDown (event); break; case "mousemove": this. tbOnMouseMove (event); break; case "mouseup": this. tbOnMouseUp (event); break; case "click": this. clseOnClick (event); break; case "load": this. frameOnLoad (event); break; default:; } }, tbOnMouseMove: function (event) { this. toolbar. style. left = this. origX + event. clientX - this. grabX + 'px'; this. toolbar. style. top = this. origY + event. clientY - this. grabY + 'px'; }, tbOnMouseUp: function (event) { this. doc. removeEventListener ('mousemove', this, false); this. toolbar. style. zIndex = 9997; }, tbOnMouseDown: function (event) { if (event. target == this. toolbar) { event. preventDefault (); this. toolbar. style. zIndex = 9998; this. grabX = event. clientX; this. grabY = event. clientY; this. origX = parseInt (this. toolbar. style. left); this. origY = parseInt (this. toolbar. style. top); this. doc. addEventListener ('mousemove', this, false); this. doc. addEventListener ('mouseup', this, false); } }, removeEventListener: function (element, eventType, captureFlag) { try { element. removeEventListener (eventType, this, captureFlag); } catch (err) {} }, removeElement: function (element) { try { element. parentNode. removeChild (element); } catch (err) {} }, clseOnClick: function (event) { this. clse. removeEventListener ('click', this, false); this. removeEventListener (this. toolbar, 'mousedown', false); this. removeEventListener (this. doc, 'mousemove', false); this. removeEventListener (this. doc, 'mouseup', false); this. removeEventListener (this. frame, 'load', false); this. removeElement (this. toolbar); this. removeElement (this. frame); this. frame = null; this. clse = null; this. toolbar = null; this. win = null; this. doc = null; }, ujs_createWindow: function (txt) { var doc = this. doc; var win = this. win; var h, w; var txtLen = txt. length; var tbId = UJS_TOOLBAR_ID; if (arguments. length > 2) tbId += arguments [2]; var toolbar = doc. getElementById (tbId); if (toolbar) toolbar. parentNode. removeChild (toolbar); toolbar = doc. createElement ('div'); this. toolbar = toolbar; toolbar. id = tbId; if (arguments. length == 5) { w = arguments [3]; h = arguments [4] } else { h = 15; w = 20; if (txtLen > 2000) { h = 50; w = 66 } else if (txtLen > 250) { h = 25; w = 33 }; h = parseInt (h * win. innerHeight / 30); w = parseInt (w * win. innerWidth / 50) }; var title = (arguments. length > 1) ?arguments [1]: '<a href="http://translate.google.com/" target="_blank" style="text-decoration:none;color:#000099;font:16px Times New Roman;">Google Translate</a>'; toolbar. innerHTML = '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAABh0RVh0U29mdHdhcmUAUGFpbnQuTkVUIHYzLjIyt5EXfQAAAStJREFUOE+1k9tqhDAQhtOHqO37P4E3IlQFQQSvBBVEl1TBVVi1B+1C8XAx3QmNqIVqhBV+DEPmy8z8ycPX9Ruq6kLqqiRHvkfpiUjSMyGUJtB1HfR9D8MwCAlz6voNkEGCIGDJeZ5DURTCatoWNE0D4nk+jOMoDMBD8fDPpoGXu4OyLAPUutV1/N+KcPPNPaY4jidYktwG+hunlLL4ZmsI4EloxhxiGAY4jgNpmm6D8DQEcBj/I8SyrKnSzYr4bDzPm2CKoiwgu1rDTfN2eEWu6y4M2KxoPRNVVRcz4xXvdm0+k/nMwjDc5xraa9v2n5kgwDRNMdfQXtT6Us7jy9Z8n738Iw82O5/hUpag6zqQ0+kVmqZld0NUURSxl48M8v5xZQtZlg8Jc5HxA5fIE73hTda3AAAAAElFTkSuQmCC" title="Close" width="18" height="18"> ' + title + '<div></div>'; toolbar. setAttribute('style', 'position:fixed;background:white;display:block;visibility:hidden;left:0;top:0;height:auto;width:' + w + 'px;font:16px Times New Roman;border:1px solid gray;padding:3px;z-index:9997;overflow:visible;cursor:move;'); toolbar. addEventListener ('mousedown', this, false); var clse = toolbar. firstChild; this. clse = clse; clse. setAttribute ('style', 'float:right;background:white;padding:0;margin:0;border:none;cursor:pointer;'); clse. addEventListener ('click', this, false); var textbar = toolbar. lastChild; textbar. innerHTML = txt; textbar. setAttribute ('style', 'display:block;border:1px solid #aaaaaa;margin:2px 0 0 0;padding:4px;background-color:#fafcfe;font:14px Times New Roman;height:' + h + 'px;width:auto;overflow:auto;cursor:text;'); doc. documentElement. appendChild (toolbar); var halfWidth = parseInt (toolbar. offsetWidth / 2); var strict = doc. compatMode == 'CSS1Compat'; var mX = (strict? doc. documentElement. clientWidth: doc. body. clientWidth) - toolbar. offsetWidth; var mY = (strict? doc. documentElement. clientHeight: doc. body. clientHeight) - toolbar. offsetHeight; var lastClickX = win. cbTranslateButton2X; var lastClickY = win. cbTranslateButton2Y; toolbar. style. left = ((lastClickX < mX + halfWidth)? (lastClickX > halfWidth? (lastClickX - halfWidth): 0): mX) + "px"; toolbar. style. top = ((lastClickY < mY)? lastClickY: mY) + "px"; toolbar. style. visibility = 'visible'; return textbar; }, frameOnLoad: function (event) { var fr = event. currentTarget; fr. removeEventListener ('load', this, false); var tbId = fr. id. substring (UJS_GOOGLE_TRANSLATE_FRAME_ID. length); var toolbar = this. doc. getElementById (UJS_TOOLBAR_ID + tbId); var frdoc = fr. contentDocument; var a = frdoc. getElementById ('autotrans'); var title = (a && !/#808080/. test (a. innerHTML))? ' - ' + a. textContent. replace (/^.+: | [(\xBB].+$/g, ''): ''; var result = frdoc. getElementById ('result_box'). innerHTML; var ancor = toolbar. getElementsByTagName ("a") [0]; ancor. innerHTML += title; ancor. nextSibling. innerHTML = result; setTimeout ( function () { fr. parentNode. removeChild (fr); }, 0 ); }, google_translate: function (language) { var doc = this. doc; var win = this. win; var t = document. commandDispatcher. focusedWindow. getSelection (). toString (); var lng = (win. navigator. language == 'ru')? 'ru': 'en'; if (t && location. hostname != 'translate.google.com') { this. ujs_createWindow ( (lng == 'ru'? '\u041F\u0435\u0440\u0435\u0432\u043E\u0434\u0438\u043C': 'Подождите идет перевод' ) + '\u2026', '<a href="http://translate.google.com/" target="_blank" style="text-decoration:none;color:#000099;font:16px Times New Roman;">Google перевод</a>', btoa (escape (t)) ); var gtfId = UJS_GOOGLE_TRANSLATE_FRAME_ID; var fr = doc. getElementById (gtfId); if (!fr) fr = doc. createElement ('iframe'); this. frame = fr; fr. setAttribute ('id', gtfId + btoa (escape (t))); fr. setAttribute ('frameborder', '0'); fr. setAttribute ('style', 'width:0px;height:0px;visibility:hidden;position:absolute;left:-999em;'); fr. setAttribute ( 'src', 'http://translate.google.com/translate_t?text=' + encodeURIComponent (t) + '&hl=' + lng + '&langpair=' + language + '&tbb=1&ujs=gtt' ); fr. addEventListener ('load', this, false); doc. documentElement. appendChild (fr); } } }; var ct = getBrowser (). selectedTab; if (!ct. cbTranslateButton5) ct. cbTranslateButton5 = []; var translator = new cbTranslatorButton (getBrowser ()); ct. cbTranslateButton5. push (translator); translator. google_translate ("auto|ru"); } //--------Перевести текст в Google-------------- function command909(){ gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://translate.google.com/translate_t?hl=ru#auto|ru|"+t_xy), x); } //---------Перевести текст в PROMT--------------- function command910(){ gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://www.translate.ru/?External=IE8Accelerator&formEncoding=utf-8&direction=ar&prmtlang=ru&status=translate&template=General&source="+t_xy), x); } //---------Перевести текст в Bing Translator--------------- function command911(){ gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://www.microsofttranslator.com/?ref=IE8Activity&to=ru&SourceText="+t_xy), x); } //----------Перевести слово в Яндексе------------ function command912(){ gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://lingvo.yandex.ru/"+t_xy), x); } //-----------Перевести слово в Lingvo-------------- function command913(){ gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://lingvopro.abbyyonline.com/ru/Search/en-ru/"+t_xy), x); } //----------Перевести слово в Mail.ru------------ function command914(){ gBrowser.moveTabTo(gBrowser.selectedTab = gBrowser.addTab("http://lingvo.mail.ru/?lang_id=1033&translate=&text="+t_xy), x); } })(); (function PerevodMenu2(){ var menu = document.createElementNS(kXULNS, "menu"); menu.id = "PerevodMenu2"; menu.setAttribute("label", "Перевести страницу"); menu.setAttribute("class", "menu-iconic"); menu.setAttribute("image", lmricon); menu.hidden = true; contextMenu.insertBefore(menu, separator ); var menuPopup = document.createElementNS(kXULNS, "menupopup"); menu.appendChild(menuPopup); var lst = [ { label:"Перевести страницу в Google", command:command921, image:gticon }, { label:"Перевести страницу в Яндексе", command:command922, image:Yndicon }, { label:"Перевести страницу в PROMT", command:command923, image:promticon }, { label:"Перевести страницу в Bing Translator", command:command924, image:Bingicon }, ]; for(var i = 0, m; m = lst[i]; i++){ if (m.label=="separator"){ var menuItem = document.createElementNS(kXULNS, "menuseparator"); menuItem.id = "context-Demo-Menu-" + m.label.toString(); menuPopup.appendChild(menuItem); } else{ var menuItem = document.createElementNS(kXULNS, "menuitem"); menuItem.setAttribute("label", m.label); menuItem.setAttribute("class", "menuitem-iconic"); menuItem.setAttribute("image", m.image); menuItem.setAttribute("type", "m.radio"); menuItem.addEventListener("command", m.command, false); menuItem.id = "context-Demo-Menu-" + m.label.toString(); menuPopup.appendChild(menuItem); } } contextMenu.addEventListener("popupshowing", setMenuDisplay, false); function setMenuDisplay(aEvent) { window.url_xy= encodeURIComponent(content.document.location.href); if (gContextMenu.onImage || gContextMenu.onLink || gContextMenu.isTextSelected) { document.getElementById("PerevodMenu2").hidden = true; } else document.getElementById("PerevodMenu2").hidden = false; } //---------Перевести страницу в Google----------------- function command921(){ var urltr="http://translate.google.com/?sl=auto&tl=ru&js=n&prev=_t&hl=en&ie=UTF-8&layout=2&eotf=1&text="+url_xy; getBrowser (). selectedTab = getBrowser (). addTab (urltr); } //---------Перевести страницу в Яндексе------------- function command922(){ var urltr="http://translate.yandex.ru/translate?srv=yasearch&url="+url_xy; getBrowser (). selectedTab = getBrowser (). addTab (urltr); } //-----------Перевести страницу в PROMT--------------- function command923(){ var urltr="http://www.translate.ru/siteTranslation/autolink/?direction=ar&template=General&sourceURL="+url_xy; getBrowser (). selectedTab = getBrowser (). addTab (urltr); } //---------Перевести страницу в Bing Translator-------------- function command924(){ var urltr="http://www.microsofttranslator.com/bv.aspx?from=&to=ru&a="+url_xy; getBrowser (). selectedTab = getBrowser (). addTab (urltr); } })();
Отредактировано bunda1 (09-02-2012 02:40:40)
Отсутствует