How can I add a Firefox bookmark as toolbar button?

21

11

I have a bookmark that I use to 'zap colours' from websites:

javascript:(function(){var%20newSS,%20styles='*%20{%20background:%20white%20!%20important;%20color:%20black%20!important%20}%20:link,%20:link%20*%20{%20color:%20#0000EE%20!important%20}%20:visited,%20:visited%20*%20{%20color:%20#551A8B%20!important%20}';%20if(document.createStyleSheet)%20{%20document.createStyleSheet("javascript:'"+styles+"'");%20}%20else%20{%20newSS=document.createElement('link');%20newSS.rel='stylesheet';%20newSS.href='data:text/css,'+escape(styles);%20document.getElementsByTagName("head")[0].appendChild(newSS);%20}%20})();

I would really like to make it an actual button on the toolbar in Firefox (for instance, to the right of the 'help' button). I know it's easy to move it onto the bookmarks toolbar, but I like to have the bookmark toolbar hidden, so would rather have an actual button in Firefox for this, and maybe some other bookmarks if it's easy!

How can I add a Firefox bookmark as toolbar button?

falter

Posted 2009-11-04T13:03:54.387

Reputation: 2 009

1

I didn't want to edit your questions as this might apply to plain bookmarks as well, but just in case you don't know: JavaScript bookmarks are often referred to as "bookmarklets". (My new favourite: The Printliminator at http://css-tricks.com/examples/ThePrintliminator/)

– Arjan – 2009-11-04T14:11:38.157

Thanks for your comment - I'll be looking for some more interesting booklets in the future! I am currently trying to use the solution below, but not having much look at the moment – falter – 2009-11-04T18:24:20.237

Answers

12

I realise this is very very old - but I came across it today while looking for an answer to this question. Use the custom bookmark tool as recommended above and then add the line of javascript that appears in your bookmarklet where URL appears in the code below:

loadURI ("*URL*");

Stuart Burrows

Posted 2009-11-04T13:03:54.387

Reputation: 221

If your bookmarklet has double quotes in the code then this will fail. You will have to replace the double quotes in the bookmarklet code with single quotes – Nat – 2016-04-19T14:57:28.217

This work perfectly! – Acorn – 2011-03-12T01:09:23.027

wooo! glad it helped :) – Stuart Burrows – 2011-03-12T08:06:51.980

ReferenceError: loadURI is not defined :( – Gringo Suave – 2013-02-02T06:37:27.843

@GringoSuave are you following the instructions that A Dwarf outlines? The v0.0.5.5 of the plugin is working perfectly with my FF 18 – Stuart Burrows – 2013-02-04T08:32:05.233

12

You can use an extension to create Custom Buttons.

alt text

You can add text to the button if you wish, use it to launch a specific website or execute code. Initialization Code is executed when the browser is launched and the button is first created.

Usage is simple.

  • Right-click an empty space in your toolbar and select the new option called Add new button...
  • You get to see the dialog above.
  • Once done, the button is created. All you need is to now add it to wherever you like through the Customize option of the toolbar context menu.

alt text

A Dwarf

Posted 2009-11-04T13:03:54.387

Reputation: 17 756

This doesn't work under Quantum and seems to break Waterfox, too. :( – endolith – 2018-03-08T19:48:29.313

4If you follow @Inrbob's instructions of placing the bookmarklet code inside loadURI("BOOKMARKLET HERE"); it works perfectly! – Acorn – 2011-03-12T01:12:09.950

Thank you for this - I have installed it, and tried to paste the javascript into the code section, and also tried it in the URL section, but neither seem to work. I have the button on my toolbar, but at the moment it does nothing!

my code is in my OP – falter – 2009-11-04T18:22:45.187

I'm not familiar with javascript. But I suspect you need to edit your snippet as to remove "javascript:" and possibly also "function()". Essentially alter it to be executed from the code box which, I believe, internally uses a evaluate function. – A Dwarf – 2009-11-04T18:39:35.230

Sadly I tried removing both of those, and neither solution worked. I also tried to add it as a URL (after all it is only a URL in my bookmarks) but that didn't work either – falter – 2009-11-05T11:39:31.487

3

This may not be exactly answering your question,
But, if you want to save the bookmark toolbar space (and not just hide and unhide it at times),
you can reduce the bookmark toolbar content and move it completely besides the 'Help' button.
This way you are done with just two 'bars' under the firefox title.
The Menu bar and the Address bar... Does that work for you?

To get this done,

  1. right-click in the space besides the Help button
    • select 'customize...'
    • drag the bookmarks toolbar from its position to the new one besides 'Help'
    • end customization with the 'Done' button
    • Now, if your bookmark has a good icon, you can even delete its name string and
      make it look quite like a button there...

nik

Posted 2009-11-04T13:03:54.387

Reputation: 50 788

Thanks for the suggestion, but I do want to keep my bookmarks toolbar which has several items on it hidden, but need a 2nd bookmark toolbar really! – falter – 2009-11-06T11:26:30.127

2

On the initialization tab add this code:

    var link = "place your bookmarklet code here"
    this.leftclick = function(evt){
    openUILink(link);}
    this.setAttribute( 'onclick', 'gQuot( event, this )' );

This will load your bookmarklet in the active tab.

Shah Zor

Posted 2009-11-04T13:03:54.387

Reputation: 596

Greetings, Shah, welcome to SuperUser. No need for disclaimers, if an answer is useful it doesn't matter whether it's old or new. I've suggested an edit to remove the "non-answer" portion of the answer, but if it doesn't fit with your intentions please go ahead and modify it. – Jonathan Garber – 2013-02-15T20:36:11.887

0

I used the bookmarklet tool at http://custombuttons.sourceforge.net/forum/viewtopic.php?f=4&t=1155 but you could equally well read their code and use that to make the button direct (loadURI method here wasn't working for me for some reason).

pbhj

Posted 2009-11-04T13:03:54.387

Reputation: 76