// Дополнительно в контекстном меню var itemsArr = [ ["Проверить доступность сайта", function(){window.open('http://downforeveryoneorjustme.com/'+location.hostname,'DownForMe_'+location.hostname,'width=600,height=400,left=100,top=100,scrollbars=yes,location=no')}], ]; var contextMenu = document.getElementById("contentAreaContextMenu"); var nextEleMenu = document.getElementById("context-inspect"); var menuId = "context-ext-addon"; var menuItem, menuPopup, menu = document.getElementById(menuId); if (menu) { contextMenu.removeChild(menu.previousElementSibling); contextMenu.removeChild(menu); }; menuPopup = document.createElement("menupopup"); menu = document.createElement("menu"); menu.setAttribute("id", menuId); menu.setAttribute("label", "Дополнительно"); for (var i = 0; i < itemsArr.length; i++) { if (itemsArr[i]) { menuItem = document.createElement("menuitem"); menuItem.setAttribute("label", itemsArr[i][0]); menuItem.addEventListener("command", (function(f){return function(){content.location.href = "javascript:(" + encodeURI(f) + ")()"}})(itemsArr[i][1].toString()), false); } else { menuItem = document.createElement("menuseparator"); }; menuPopup.appendChild(menuItem); }; menu.appendChild(menuPopup); contextMenu.insertBefore(menu, nextEleMenu); contextMenu.insertBefore(document.createElement("menuseparator"), nextEleMenu); |