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

Общайтесь со знакомыми и друзьями в нашем сообществе в Facebook.

№108-02-2016 14:33:06

pag77
Участник
 
Группа: Extensions
Зарегистрирован: 20-03-2012
Сообщений: 1657
UA: Firefox 44.0

[MenuWizard] Подменю с историей вкладки в её контекстном меню

Это готовое решение для аддона "Menu Wizard"
https://addons.mozilla.org/addon/s3menu-wizard/
https://forum.mozilla-russia.org/viewtopic.php?id=63252

Это решение добавит в контекстном меню вкладки её историю с возможностью открытия ссылок в новой вкладке браузера.
c9f84084819a.png

Установка:

  1. Установите Menu Wizard, если его еще нет в вашем браузере
  2. Откройте настройки Menu Wizard: "Инструменты > Menu Wizard", "Дополнения > Menu Wizard > Настройки" или введите в строку адреса about:config-menu
  3. Раскройте меню "Контекстное меню вкладок"
  4. Вверху справа нажмите значок "Добавить новые элементы"
  5. Перетяните с помощью мыши "Новая меню-папка" в меню "Контекстное меню вкладок"
  6. Откройте свойства у "Новая меню-папка"
    290bff5a6c5d.png
  7. В поле "Команда > onPopupShowing" вставьте этот код:

    Выделить код

    Код:

    FillHistoryMenu_new(event.target);
    
    function FillHistoryMenu_new(aParent) {
      // Lazily add the hover listeners on first showing and never remove them
      if (!aParent.hasStatusListener) {
        // Show history item's uri in the status bar when hovering, and clear on exit
        aParent.addEventListener("DOMMenuItemActive", function(aEvent) {
          // Only the current page should have the checked attribute, so skip it
          if (!aEvent.target.hasAttribute("checked"))
            XULBrowserWindow.setOverLink(aEvent.target.getAttribute("uri"));
        }, false);
        aParent.addEventListener("DOMMenuItemInactive", function() {
          XULBrowserWindow.setOverLink("");
        }, false);
    
        aParent.hasStatusListener = true;
      }
    
      // Remove old entries if any
      var children = aParent.childNodes;
      for (var i = children.length - 1; i >= 0; --i) {
        if (children[i].hasAttribute("index"))
          aParent.removeChild(children[i]);
      }
    
      var webNav = gBrowser.getBrowserForTab(TabContextMenu.contextTab).webNavigation;
      var sessionHistory = webNav.sessionHistory;
    
      var count = sessionHistory.count;
      if (count <= 1) // don't display the popup for a single item
        return false;
    
      const MAX_HISTORY_MENU_ITEMS = 15;
      var index = sessionHistory.index;
      var half_length = Math.floor(MAX_HISTORY_MENU_ITEMS / 2);
      var start = Math.max(index - half_length, 0);
      var end = Math.min(start == 0 ? MAX_HISTORY_MENU_ITEMS : index + half_length + 1, count);
      if (end == count)
        start = Math.max(count - MAX_HISTORY_MENU_ITEMS, 0);
    
      var tooltipBack = gNavigatorBundle.getString("tabHistory.goBack");
      var tooltipCurrent = gNavigatorBundle.getString("tabHistory.current");
      var tooltipForward = gNavigatorBundle.getString("tabHistory.goForward");
    
      for (var j = end - 1; j >= start; j--) {
        var item = document.createElement("menuitem");
        var entry = sessionHistory.getEntryAtIndex(j, false);
        var uri = entry.URI.spec;
        var entryURI = BrowserUtils.makeURIFromCPOW(entry.URI);
    
        item.setAttribute("uri", uri);
        item.setAttribute("label", entry.title || uri);
        item.setAttribute("index", j);
        item.setAttribute("onclick", "gBrowser.selectedTab = gBrowser.addTab(this.getAttribute('uri'));");
    
        if (j != index) {
          PlacesUtils.favicons.getFaviconURLForPage(entryURI, function (aURI) {
            if (aURI) {
              var iconURL = PlacesUtils.favicons.getFaviconLinkForIcon(aURI).spec;
              iconURL = PlacesUtils.getImageURLForResolution(window, iconURL);
              item.style.listStyleImage = "url(" + iconURL + ")";
            }
          });
        }
    
        if (j < index) {
          item.className = "unified-nav-back menuitem-iconic menuitem-with-favicon";
          item.setAttribute("tooltiptext", tooltipBack);
        } else if (j == index) {
          item.setAttribute("type", "radio");
          item.setAttribute("checked", "true");
          item.className = "unified-nav-current";
          item.setAttribute("tooltiptext", tooltipCurrent);
        } else {
          item.className = "unified-nav-forward menuitem-iconic menuitem-with-favicon";
          item.setAttribute("tooltiptext", tooltipForward);
        }
    
        aParent.appendChild(item);
      }
      return true;
    }

  8. Нажмите "Применить"
  9. При желании можно изменить название меню: "Свойства > Название" и изменить иконку

Отредактировано pag77 (08-02-2016 14:55:57)

Отсутствует

 

№209-02-2016 00:56:03

Sergeys
Administrator
 
Группа: Administrators
Откуда: Moscow, Russia
Зарегистрирован: 23-01-2005
Сообщений: 14009
UA: Firefox 44.0
Веб-сайт

Re: [MenuWizard] Подменю с историей вкладки в её контекстном меню

достаточно одной темы
https://forum.mozilla-russia.org/viewtopic.php?id=63252


Через сомнения приходим к истине. Цицерон

Отсутствует

 

Board footer

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