kerlser

Untitled

Oct 28th, 2022
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // JavaScript Document
  2. //Button_PersonalToolbar.uc.js
  3.  
  4. (function ptbut() {
  5.    
  6.            
  7.     if (location != 'chrome://browser/content/browser.xul' && location != 'chrome://browser/content/browser.xhtml')
  8.        return;
  9.  
  10.     try {
  11.         CustomizableUI.createWidget({
  12.             id: 'PersonalToolbar-button',
  13.             type: 'custom',
  14.             defaultArea: CustomizableUI.AREA_NAVBAR,
  15.                 onBuild: function(aDocument) {
  16.                     var toolbaritem = aDocument.createXULElement('toolbarbutton');
  17.                     var currentProfileDirectory = Services.dirsvc.get("ProfD", Ci.nsIFile).path.replace(/\\/g, "/");
  18.                     var buttonicon = "toolbar.png"
  19.                     var props = {
  20.                         id: 'PersonalToolbar-button',
  21.                         class: 'toolbarbutton-1 chromeclass-toolbar-additional',
  22.                         removable: true,
  23.                         label: 'Toggle',
  24.                         tooltiptext: 'Toggle Bookmarktoolbar',
  25.                         style: 'list-style-image: url("' + ("file:" + currentProfileDirectory + "/chrome/icons/" + buttonicon) +'");',
  26.                     };
  27.                    
  28.                
  29.                     for(var p in props)
  30.                         toolbaritem.setAttribute(p, props[p]);
  31.                     return toolbaritem;
  32.                    
  33.                    
  34.                 }
  35.         });
  36.         CustomizableUI.registerToolbarNode(tb);
  37.     } catch(e) { };
  38.  
  39.  
  40. document.getElementById('PersonalToolbar-button').addEventListener( "click", onClick );
  41.    
  42. document.addEventListener('keydown', (event) => {
  43.         var keyName = event.key;
  44.  
  45.  
  46.         // Mac : Funktion wird ausgeführt, wenn Cmd + < gedrückt wird
  47.         if (event.metaKey && keyName == '<') {
  48.            onClick(event);        
  49.         }
  50.     }, false
  51. );
  52.     function onClick(aEvent) {
  53.  
  54.         var d2 = document.getElementById('PersonalToolbar');
  55.        
  56.         if (d2.style.width == "") {
  57.             d2.style.width = "40px";
  58.         } else if (d2.style.width == "130px") {
  59.             d2.style.width = "40px";
  60.         } else if (d2.style.width == "40px") {
  61.             d2.style.width = "130px";
  62.         }
  63.       }
  64. })();
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
Advertisement
Add Comment
Please, Sign In to add comment