Extended Context Menu

Add-ons for Pale Moon and other applications
General discussion, compatibility, contributed extensions, themes, plugins, and more.

Moderators: FranklinDM, Lootyhoof

Tolyasho

Extended Context Menu

Unread post by Tolyasho » 2017-06-30, 05:20

Hi! Since I'm admin of the one forum , I have to work a lot with news and articles adding/publishing. This usually requires a link for origin or source article (site). Copy-Pasting links from adress-bar sometimes not rather convinient. So I thougt what if we had an ability of some similar functions by default via context menu? There is an FF addon that seemes to me very usuful in that way - Context Menu Plus - https://addons.mozilla.org/ru/firefox/a ... serprofile. It extends CM with some interesting and usuful, IMO, options: Copy page title, Copy page url, Copy page title and url, Copy page title &url of all tabs, Copy as html link and many other. Unfortunatly this addon can't be insatlled on PM. It seems to me, most of its options would be usuful for others makin things more convinient. Is there any chance to see some of this options implemented in Context Menu by default? Thanks for attention.

User avatar
jars_
Lunatic
Lunatic
Posts: 398
Joined: 2016-12-27, 00:12

Re: Extended Context Menu

Unread post by jars_ » 2017-06-30, 10:22

worked with PM-27.1.0b1+ (instruction here Pale Moon - Developer Wiki - Jetpack Style Extensions)
PM-ext-jetpack-fixed
+
CustomButton for tab menu with some usefull func (items in russian ;-) )
initialization Code:

Code: Select all

// ----------------- Для вкладок подменю "Копировать адрес и название как BBCode или" в контекстном меню вкладки.
// ----------- bunda1 от 17.07.2015. 
/*Initialization Code*/
(function( tabContextMenu ) {
   
   var separator = tabContextMenu.appendChild( document.createElement("menuseparator") );
   var menu = tabContextMenu.appendChild( document.createElement("menu") );      
   menu.id = "get-tab-like";
   menu.setAttribute("label", "Копировать BBCode");
//   document.getElementById("sep_closeTab").parentNode.insertBefore( menu, document.getElementById("sep_closeTab") );
   document.getElementById("context_openTabInWindow").parentNode.insertBefore( menu, document.getElementById("context_openTabInWindow") );

   
   addDestructor(function() {
      tabContextMenu.removeChild( menu );
      tabContextMenu.removeChild( separator );        
   });      
        
   var data = {
       url:                  "Адрес",
       label:                "Название",
       image:                "Иконки адресс",
       shortUrl:             "Коротко адресс",
       shortLabel:           "Коротко название",
       tabInfo:              "Адрес и название",
       tabInfoHtml:          "Адрес и название как HTML",
       tabChangedInfoBbcode: "Адрес и редактированное название как BBCode",
       separator1: 0,
       allTabsURL:           "Адреса всех вкладок",
       allTabsLabels:        "Название всех вкладок",
       allTabsInfo:          "Адреса и название всех вкладок",
       allTabsInfoHtml:      "Адреса и название всех вкладок как HTML",
       allTabsInfoBbcode:    "Адреса и название всех вкладок как BBCode"
   }
   var menuPopup = menu.appendChild( document.createElement("menupopup") );              
   for ( var key in data ) {
         if ( key.startsWith("separator") ) { menuPopup.appendChild(document.createElement("menuseparator")); continue };
         var menuitem = menuPopup.appendChild( document.createElement("menuitem") );
         menuitem.setAttribute("label", data[key] );
         menuitem.arg = key;
         };
   
   addEventListener("click", function(e) {
      var info, tab = document.popupNode, lab = tab.label;
      var tabs = e.button == 0 ? [...gBrowser.tabs] : gBrowser.visibleTabs;
      var arg = (e.target == menu) ? "tabInfoBbcode" : e.target.arg;

      switch( arg ) {
         case "url": info = tab.linkedBrowser.currentURI.spec; break;            
         case "label": info = lab; break;
         case "image": info = tab.image.replace("#-moz-resolution=16,16",""); break;
         case "shortUrl": copyShortUrl(); break;         
         case "shortLabel": info = lab.slice(0,50) + (lab.length > 50 ? ' ......' : ""); break;
         case "tabInfo": info = getBuildInfo(tab, arg); break;
         case "tabInfoHtml": info = getBuildInfo(tab, arg); break;
         case "tabInfoBbcode": info = getBuildInfo(tab, arg); break;
         case "tabChangedInfoBbcode": info = getBuildInfo({__proto__: tab, label: custombuttons.promptBox("Измените название вкладки:", null, lab)[1]}, arg); break;
         case "allTabsURL": info = tabs.map(function(node) node.linkedBrowser.currentURI.spec ).join("\n"); break;
         case "allTabsLabels": info = tabs.map(function(node) node.label ).join("\n"); break;
         case "allTabsInfo": info = tabs.map(function(node) getBuildInfo(node, arg) ).join("\n"); break;
         case "allTabsInfoHtml": info = tabs.map(function(node) getBuildInfo(node, arg) ).join("\n"); break;
         case "allTabsInfoBbcode": info = tabs.map(function(node) getBuildInfo(node, arg) ).join("\n"); break;
      }
      gClipboard.write( info );
      
      tabContextMenu.hidePopup();      
   }, false, menu );
   
   function copyShortUrl() { 
      var xhr = new XMLHttpRequest();
      xhr.open('POST', 'https://www.googleapis.com/urlshortener/v1/url?key=AIzaSyC7uWVak6m9AFIMORinK4gfNZZ5IrNPgKA', true);
      xhr.setRequestHeader("Content-type", "application/json");
      var request = { longUrl:content.location.href, key:'{YOUR_API_KEY}' }
      xhr.onload = xhr.onerror = function() {         
         try { gClipboard.write( JSON.parse(xhr.response).id ) } 
         catch (e) { custombuttons.alertSlide("Ошибка, не удалось получить короткий адрес","") };            
         }
      xhr.send( JSON.stringify(request) );
   };  

   function getBuildInfo( tab, arg ) {
//      var info, url = tab.linkedBrowser.currentURI.spec;
// Для копирования кириллицы в адресе
      var info, url = decodeURIComponent( tab.linkedBrowser.currentURI.spec );
      
      switch( arg.slice(-4) ) {
        case "code": info = '[url=' + url + ']' + tab.label + '[/url]'; break;
        case "Html": info = '<a href="' + url + '">' + tab.label + '</a>'; break;
        case "Info": info = tab.label + "\n" + url;
      }
      return info;
   };
   
})(document.getElementById("tabContextMenu"));


JustOff

Re: Extended Context Menu

Unread post by JustOff » 2017-06-30, 11:23

Take a look at CoLT, I'm very happy with it for more than 10 years.

Tolyasho

Re: Extended Context Menu

Unread post by Tolyasho » 2017-06-30, 14:06

Thanks guys, I'll try everything you've suggested. As far as I see, all that stuff is not much complicated. I mean not much complicated for being implemented. Thats why lot of us really miss an old Opera Presto ;) Opera had it all in one. Anyway, thanks for you answers.

User avatar
Giraffe
Lunatic
Lunatic
Posts: 402
Joined: 2016-11-09, 11:57

Re: Extended Context Menu

Unread post by Giraffe » 2017-07-01, 07:20

One I like is
https://addons.mozilla.org/en-US/firefo ... /versions/

1.4.5.2 will install but I use 1.5.1 which was installed with the Moon Tester Tool.
It gives many options for Context Menu on a page.
Then, with other options for tabs and some for the page:
http://tabmixplus.org/
Windows 7 Pro 32-bit. Comodo Internet security or Comodo Firewall + Avira Anivirus.

Tolyasho

Re: Extended Context Menu

Unread post by Tolyasho » 2017-07-01, 09:50

CMP is also my favorite one ;) I've already installed v1.5.2 via Moon Tester Tool. However the first idea was implementation some of its options into context menu by default. Just like Opera Presto had. Without any addons. Since we started talking about addons, the topic has been removed from Suggestions over here :)

Locked