简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM