Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create a shortcut for firefox in Greasemonkey?

How can I create a shortcut for Greasemonkey for the firefox bookmarks, or, a shortcut that opens a website?

Sorry,

I want a greasemonkey script that contain some script that bind some key for firefox bookmark

for example, press key 1 = open bookmark 1, and so on

like image 927
Bruno 'Shady' Avatar asked Jul 02 '10 19:07

Bruno 'Shady'


People also ask

How do I set up shortcuts in Firefox?

Step 1: Install the Firefox extension called Customizable Shortcuts from Mozilla. Step 2: Click on the orange Firefox button, then Options. Step 3: Click on the last tab called Shortcuts. Step 4: Double-click on the shortcut you want to customize, then type in the key combination you prefer to use.


1 Answers

I want a greasemonkey script that contain some script that bind some key for firefox bookmark

Here is an example:

// ==UserScript==
// @name           Google Shortcut
// @namespace      googleShortcut
// ==/UserScript==

(function(){
document.addEventListener('keydown', function(e) {
  // pressed alt+g
  if (e.keyCode == 71 && !e.shiftKey && !e.ctrlKey && e.altKey && !e.metaKey) {
   window.location = "http://google.com"; // go to google.
  }
}, false);
})();

This user script can be found at userscripts.org here.

This adds a "alt+g" hotkey to all pages which when pressed will take the user to google.com.

This is a very good document explaining how to hook on to different hotkeys, providing all of the keycodes, and information about cross platforms quirks, etc.

You'll have to read this documentation on Greasemonkey to learn how to customize the header information.

Then just save the file with a .user.js extension, and drag and drop it to a Firefox window to install it. When your done upload it to userscripts.org in case someone else would like the script.

like image 182
erikvold Avatar answered Sep 23 '22 20:09

erikvold