Custom Buttons in the latest Firefox

General discussion about Custom Buttons, including feature requests.

Custom Buttons in the latest Firefox

Postby darkmatter » Sun Mar 18, 2018 7:54 pm

    Hello all!!! :)
Long time, no hear from...

I just thought I'd drop by to take a moment to thank srazzano for the time and dedication he has taken to put together his...


Recently my dad had an interest in reinstalling Mozilla Firefox, and I had at once remembered its incompatibility with Custom Buttons.

Thanks to the Custom Butttons³ posting, I was able to install Firefox on my dad's computer as he wished, while keeping the buttons he needs functional.

    Thank you very much for the many contributions to this, and other extensions you have taken the time to create, Sonny!

Long overdue from me ;)
darkmatter
 
Posts: 256
Joined: Sun Feb 26, 2012 7:37 pm
Location: California USA

Re: Custom Buttons in the latest Firefox

Postby steve.marks59 » Mon Mar 26, 2018 4:15 pm

I also wish to thank srazzano for his CB3
and for his ongoing help and the time and
effort he puts in to enable us to continue
using our Custom Buttons.
Thanks Sonny!
steve.marks59
 
Posts: 455
Joined: Fri Dec 23, 2011 11:23 pm
Location: Claymont, Delaware

Re: Custom Buttons in the latest Firefox

Postby karolkonar » Fri May 18, 2018 4:33 pm

Is it working for firefox 60?
karolkonar
 
Posts: 9
Joined: Fri Jan 27, 2012 3:25 pm

Re: Custom Buttons in the latest Firefox

Postby srazzano » Fri May 18, 2018 7:31 pm

I don't believe so, as it was coded for Waterfox browser https://www.waterfoxproject.org/en-US/w ... w/?scene=1
srazzano
 
Posts: 1545
Joined: Sat Mar 31, 2012 6:42 pm
Location: Las Vegas, Nevada

Re: Custom Buttons in the latest Firefox

Postby karolkonar » Fri May 18, 2018 11:53 pm

srazzano wrote:I don't believe so, as it was coded for Waterfox browser https://www.waterfoxproject.org/en-US/w ... w/?scene=1


I see - is there any alternative addon for firefox? In case I only want to navigate to a page with one parameter.
karolkonar
 
Posts: 9
Joined: Fri Jan 27, 2012 3:25 pm

Re: Custom Buttons in the latest Firefox

Postby srazzano » Sat May 19, 2018 3:52 am

I don't know off hand of an addon that will do what you want, as I mostly use Waterfox browser. However, I did manually create a dozen or so of my own buttons I use in Firefox 60.0.1 (no guaranty on how long the hack will last), but requires you to create a file and code your function. If you feel comfortable/capable of performing such changes, re-post and I can help you with the needed modifications.
Last edited by srazzano on Sun May 20, 2018 12:01 am, edited 2 times in total.
srazzano
 
Posts: 1545
Joined: Sat Mar 31, 2012 6:42 pm
Location: Las Vegas, Nevada

Re: Custom Buttons in the latest Firefox

Postby karolkonar » Sat May 19, 2018 11:34 am

srazzano wrote:I don't know off hand of an addon that will do what you want, as I mostly use Waterfox browser. I did, however, create a dozen or so of my own buttons I use in Firefox 60.0.1 (no guaranty on how long the hack will last), but requires you to create a file and code your function. If you feel comfortable/capable of performing such changes, re-post and I can help you with the needed modifications.


Yes, I would really like such short tutorial - might be helpful for other firefox users as well. In my case I need the simple navigating to a page with parameter like:

gBrowser.selectedTab = gBrowser.addTab("https://who.is/whois/" + keyword);
karolkonar
 
Posts: 9
Joined: Fri Jan 27, 2012 3:25 pm

Re: Custom Buttons in the latest Firefox

Postby morat » Sat May 19, 2018 2:52 pm

I'm using the CustomizableUI to create buttons in Firefox 60 release build.

CustomizableUI
http://developer.mozilla.org/en-US/docs ... ableUI.jsm

Someone got the userChrome.js file working with only the userChrome.css file.

Firefox Quantum compatible userChrome.js
http://github.com/Sporif/firefox-quantum-userchromejs

Restart Button
http://gist.github.com/Sporif/ad6e917d8 ... 80d3c8918c

Toggle Page Style Button
http://forums.mozillazine.org/viewtopic ... #p14795810
morat
 
Posts: 959
Joined: Wed Dec 28, 2011 2:38 pm

Re: Custom Buttons in the latest Firefox

Postby srazzano » Sat May 19, 2018 9:28 pm

@karolkonar,

(1) Create a chrome folder in your user profile, if it doesn't already exist.
(2) Create two files in the chrome folder and name them userChrome.xml and whois.js
(3) Copy/paste this into the userChrome.xml file:
Code: Select all
<?xml version="1.0"?>
<bindings xmlns="http://www.mozilla.org/xbl">
  <binding id="js" extends="chrome://global/content/bindings/toolbarbutton.xml#menu">
    <implementation>
      <constructor><![CDATA[
        if (window.userChromeJsMod) return;
        window.userChromeJsMod = true;
        let xulFiles = [],
            chromeFiles = FileUtils.getDir("UChrm", []).directoryEntries,
            ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService),
            sss = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService),
            scriptloader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
        while (chromeFiles.hasMoreElements()) {
          let file = chromeFiles.getNext().QueryInterface(Ci.nsIFile),
              fileURI = ios.newFileURI(file);
          if (file.isFile()) {
            if (/(^userChrome|(\.uc)?)\.js$/i.test(file.leafName))
              scriptloader.loadSubScriptWithOptions(fileURI.spec, {target: window, ignoreCache: true});
            else if (/(^userChrome|(\.uc)?)\.xul$/i.test(file.leafName)) xulFiles.push(fileURI.spec);
            else if (/\.as\.css$/i.test(file.leafName)) {
              if (!sss.sheetRegistered(fileURI, sss.AGENT_SHEET)) sss.loadAndRegisterSheet(fileURI, sss.AGENT_SHEET);
            } else if (/^(?!(userChrome|userContent)\.css$).+\.css$/i.test(file.leafName)) {
              if (!sss.sheetRegistered(fileURI, sss.USER_SHEET)) sss.loadAndRegisterSheet(fileURI, sss.USER_SHEET);
        } } }
        setTimeout(function loadXUL() {
          if (xulFiles.length > 0) {
            document.loadOverlay(xulFiles.shift(), null);
            setTimeout(loadXUL, 5);
          }
        }, 0);
      ]]></constructor>
    </implementation>
  </binding>
</bindings>

(4) Copy/paste this script into the whois.js file:
Code: Select all
// ==UserScript==
// @name                 Who Is
// @version              1.0
// @description          WHOIS Search, Domain Name, Website, and IP Tools
// ==/UserScript==

(function() {

  "use strict";

  var {classes: Cc, interfaces: Ci, utils: Cu} = Components;

  const baseDomain = true,
        btnLabel = "Who Is",
        btnTip = "WHOIS Search for Active Tab",
        btnImage = "list-style-image: url('https://who.is/favicon.ico')",
        eTLD = Cc["@mozilla.org/network/effective-tld-service;1"].getService(Ci.nsIEffectiveTLDService),
        webPage = "https://www.whois.com/whois/",
        xulns = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";

  function whoIs(e) {
    if (e.button === 0 && !e.shiftKey && !e.ctrlKey && !e.altKey) {
      if (location != "chrome://browser/content/browser.xul") return;
      let uri = gBrowser.currentURI.host, etl;
      try {
        etl = eTLD.getBaseDomainFromHost(uri);
      } catch(ex) {etl = uri}
      let domain = baseDomain ? etl : uri;
      openUILinkIn(webPage + domain, "tab");
  } }

  try {
    CustomizableUI.createWidget({
      id: "whois-button",
      type: "custom",
      onBuild: function(aDocument) {
        var toolbaritem = aDocument.createElementNS(xulns, "toolbarbutton");
        toolbaritem.onclick = event => whoIs(event);
        var props = {
          id: "whois-button",
          class: "toolbarbutton-1 chromeclass-toolbar-additional",
          label: btnLabel,
          tooltiptext: btnTip,
          style: btnImage
        };
        for (var p in props) toolbaritem.setAttribute(p, props[p]);
        return toolbaritem;
      }
    });
  } catch(e) {};

})();

(5) Else downlaod/insert attached whois.zip file into chrome folder and unzip/extract there, to create the two files for you (then you can delete the whois.zip file).

Will create the whois icon Image in your Customize Toolbar Palette. Drag it onto a toolbar and should be good to go. On button left-click, it will query the active tab domain in https://www.whois.com/whois/ web page.
Let us know if the function is not exactly what you are looking for and the script can be modified.
Once the userChrome.xml file is inserted into the chrome folder, you can create other toolbarbuttons by creating/coding js files.
Attachments
whois.zip
(1.8 KiB) Not downloaded yet
srazzano
 
Posts: 1545
Joined: Sat Mar 31, 2012 6:42 pm
Location: Las Vegas, Nevada


Return to General Discussion

cron