A kind reminder we would like all registered users to weigh in on one of our forum's security policies.
Please take a moment to read this thread and place a vote.
https://forum.palemoon.org/viewtopic.php?f=17&t=32935

Custom Buttons Enhanced 0.0.6

Dedicated board for extension releases/support threads

Moderators: FranklinDM, Lootyhoof

Forum rules
Please do not create new topics here unless you are an extension author in need of a dedicated releases&support thread!
User avatar
tellu-white
Lunatic
Lunatic
Posts: 274
Joined: 2022-03-08, 22:02

Custom Buttons Enhanced 0.0.6

Post by tellu-white » 2025-08-03, 21:16

jars_ wrote:
small upd in defense of CustomButtons ...
https://forum.palemoon.org/viewtopic.php?f=3&t=32588#p264400

I use Custom Buttons too. I like this add-on but I had a frustration with it: in "tooltipText" I couldn't add "line-breaks" to help me remember the button options.

To solve this problem, I added the following lines to the add-on code:

Code: Select all

setTimeout (function () {
	try{
		var button_name = oBtn.name;
		button_name = button_name.replace(/\\n/g, "\n");
		oBtn.tooltipText = button_name;
	} catch(err){
		// alert(err.message);
	}
}, 100);
Since I've modified the add-on, I've inserted three more files in the XPI archive:

1. jquery.js ( jQuery Core 3.7.1 )
2. test_load_jquery.js
3. empty_HTML_page.html

The files 1 and 3 are useful in certain circumstances, and the file 2 I added just to test the "mozIJSSubScriptLoader.loadSubScript" function.

This is what a button looks like when I use "line-breaks" to display the button options:
01.png
Before modifying the add-on, "\n" inside the button's "Name" box did not produce a "line-break":
02.png
Screenshots showing the changes made to the add-on:
03.png
04.png
05.png
06.png
After modifying the add-on, "\n" in the "Name" box of the button generated a "line break":
07.png
Testing the functionality of the "jquery.js" file added to the add-on:
08.png
09.png
***

Anyone who wants to test the enhanced version of the Custom Buttons add-on ( Custom Buttons Enhanced 0.0.6 ) can download it here:

https://www.mediafire.com/file/xkjjewlp4h0hrnw/Custom_Buttons_Enhanced_0_0_6.zip/file
You do not have the required permissions to view the files attached to this post.

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

Re: Custom Buttons Enhanced 0.0.6

Post by jars_ » 2025-08-03, 22:51

... add "line-breaks" to help me remember the button options.
We must write an extended tooltips ourselves:

Code: Select all

/* init */
// Sort Tabs by Domain or Name

  this.setAttribute("context", false);
  this.onclick = clickFunc;


this.tooltipText = "¤ LMB - Sort Tabs by Domain and domain by tab name\n\
¤ MMB - Stop All tabs \(mod edit btn\)\n\
¤ RMB - Sort Tabs by Name (mod menu btn\)\n" + this.id;

    
   function clickFunc(e) {
       const mod = ( e.ctrlKey || e.altKey || e.shiftKey ) ? true : false;
     switch(e.button) {
        case 0: sortTabs4(false); break;
        case 1: mod ? custombuttons.editButton(this) : allStop3(); break;
        case 2: mod ? gShowPopup(this) : sortTabs4(true); break;
        }
    }


 // --- Сортирует по домену, без учета www и верхних приставок, а домен по имени  ---
 function sortTabs4(mod) {
    let tabs = [...gBrowser.visibleTabs].filter(tab => !tab.pinned), num = gBrowser._numPinnedTabs;
         tabs.sort( (a, b) => {
                   const domA = getDomain(a.linkedBrowser.currentURI.spec), domB = getDomain(b.linkedBrowser.currentURI.spec),
                         namA = cleanText(a.label), namB = cleanText(b.label);
                    return mod ? namA.localeCompare(namB) : domA.localeCompare(domB) ? domA.localeCompare(domB) : namA.localeCompare(namB);
                   });
    tabs.forEach( tab => gBrowser.moveTabTo(tab, num++) );
    animate( document.getElementById('TabsToolbar'), "brightness(140%)" );
   };


  const getDomain = url => url.startsWith("http") ? Services.eTLD.getBaseDomain(Services.io.newURI(url, null, null)) : url;

// -------------- Очистить текст от спецсимволов --------------------
 function cleanText(text) {
     const badSymbols = new RegExp(/[\!\@\#\$\%\^\+\=\:\;\.\,\`\"\'\?\)\(\]\[\|\*\\\/\/\<\>\»]+/ig),
                title = text.replace(badSymbols, '').replace(/\s+/g, ' ');
     return title.substring(0,70).trim();
   }


 function allStop3() {
     const visTabs = gBrowser.visibleTabs;
       visTabs.forEach( tab => {
           const browser = gBrowser.getBrowserForTab(tab);
               browser.stop();
               browser.webNavigation.stop(2);
          animate( document.getElementById('TabsToolbar'), "hue-rotate(270deg)" );
          })
   }


 function animate(el, fltr) {
   el.style.MozTransition="0.6s filter ease-out";
     setTimeout(()=> {el.style.filter = fltr ? fltr : "sepia(1)" }, 100);   // hue-rotate(270deg) sepia(100%) saturate(200%) sepia(100%) invert
     setTimeout(()=> {el.style.filter = "none" }, 1000);
     setTimeout(()=> {el.style.MozTransition = "none" }, 1500);
   }

If you want an updated tooltip on each mousehover, then like this:

Code: Select all

/* init */
// Darken page 2 (pseudo brightness)

  this.setAttribute("context", false);
  this.onclick = clickFunc;
  
  this.onmouseover = showTT;

  function showTT() {
    this.tooltipText = this.name + "\n\
       MMB - Edit button\n\
       RMB - Reset darknes 0\n\
        ¤ Wheel - darken page\n\
       now: " + getDarkLevel() + "%\n\
       id: " + this.id;
    };

// ------- Яркость страницы своими средствами, без ScreenDimmer -------------

 const appcontent = document.getElementById("appcontent"),
          browser = document.getElementById("browser"),
          darkLvl = "custombutton.darken.darkLevel",
       getOpacity = num => num ? (100 - num) / 100 : 1,
     getDarkLevel = ()=> Services.prefs.getIntPref(darkLvl) ?? 0;
  
  function clickFunc(e) {
 	const mod = ( e.ctrlKey || e.altKey || e.shiftKey ) ? true : false;
    switch (e.button) {
      case 1: custombuttons.editButton(this); break;
      case 2: mod ? gShowPopup(this) : (appcontent.style.opacity = "1", Services.prefs.setIntPref(darkLvl, 0)); break;
      }
   };

  this.onwheel =e=> darken_brigter(e.deltaY);

  function darken_brigter(delta) {
      let darkLevel = getDarkLevel();            //console.log("deltaY: " + delta + "\ndarkLevel: " + darkLevel + "\ngetOpacity: " + getOpacity());
        if (delta>0 && darkLevel < 100) darkLevel += delta-1; else if(delta<0 && darkLevel > 0) darkLevel += delta-1; else return;
       appcontent.style.opacity = getOpacity(darkLevel);
       Services.prefs.setIntPref(darkLvl, darkLevel);
       };

  browser.style.backgroundColor = "#000";
  appcontent.style.opacity = getOpacity(getDarkLevel());

"Don't shoot the pianist, he is doing his best" :)

Michaell
Lunatic
Lunatic
Posts: 393
Joined: 2018-05-26, 18:13

Re: Custom Buttons Enhanced 0.0.6

Post by Michaell » 2025-08-03, 22:59

I used Custom Buttons for years but gave up on it several years ago. It got confusing even then about which was the best for Pale Moon. Multiple versions by different maintainers. And the older the original got the more problems came up. Also, hardly anyone made updated buttons so many of the buttons I used no longer worked. I'm a little hesitant about you (tellu-white) patching old code without reworking the outdated parts. I'll try it and see if any of the old buttons work [no, site won't allow download without javascript]. But without an active community of button developers it probably isn't going to get many users because most of us aren't able to create our own buttons.
Win10home(1709), PM33.9.0.1-portable as of Sep. 24, 2025

User avatar
tellu-white
Lunatic
Lunatic
Posts: 274
Joined: 2022-03-08, 22:02

Re: Custom Buttons Enhanced 0.0.6

Post by tellu-white » 2025-08-04, 12:23

jars_ wrote:
2025-08-03, 22:51
We must write an extended tooltips ourselves
In your comment here:

https://forum.palemoon.org/viewtopic.php?f=3&t=32588#p264400

you objected that I use too much code for something that "we need something like this (8 lines)"

Now you propose a solution where you have to add a bunch of lines of code to each newly created button to get a "tooltipText" with "line-breaks", instead of my solution, which requires no additional lines of code! A little consistency in approaching solutions would not hurt ;)
Michaell wrote:
2025-08-03, 22:59
Also, hardly anyone made updated buttons so many of the buttons I used no longer worked. I'm a little hesitant about you (tellu-white) patching old code without reworking the outdated parts. I'll try it and see if any of the old buttons work [no, site won't allow download without javascript]. But without an active community of button developers it probably isn't going to get many users because most of us aren't able to create our own buttons.
I currently have 47 add-ons and 64 Custom Buttons installed in Pale Moon. Out of the 64 Custom Buttons (which work fine, all of them), only 6 buttons are not created by me, so I don't know what to answer to your objections.