最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How can I create a shortcut for firefox in Greasemonkey? - Stack Overflow

programmeradmin0浏览0评论

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

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

Share Improve this question edited Jul 3, 2010 at 3:45 Bruno 'Shady' asked Jul 2, 2010 at 19:28 Bruno 'Shady'Bruno 'Shady' 4,51615 gold badges56 silver badges75 bronze badges 1
  • 1 Sorry I don't understand this fully... do you want dynamically generate a button an a greasemonkey-manipulated page for bookmarking something? – JanD Commented Jul 2, 2010 at 22:27
Add a comment  | 

1 Answer 1

Reset to default 19

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.

发布评论

评论列表(0)

  1. 暂无评论