4 ms·
Is there any way around having to click a bookmarklet on the bookmarks toolbar? I do not keep a bookmarks toolbar active, and also prefer to do things on the k
by josinalvo 6y ago
Is there any way around having to click a bookmarklet on the bookmarks toolbar?
I do not keep a bookmarks toolbar active, and also prefer to do things on the keyboard whenever possible.
- chrismorgan 6y agoDrop it in a user script with Greasemonkey or similar, and add a keypress event listener. The bones of it: // ==UserScript== // @name Personal jmapui tweaks // @version 1 // @grant none // ==/UserScript== addEventListener("keypress", event => { if (event.target …) { return; } if (event.key == 'x' && event.ctrlKey && !event.metaKey …) { window.eval('…'); } }); You’ll want to do things like skip events targeted at form elements or within a contenteditable, perhaps unless you use a suitable modifier. It may be helpful to flatten the modifiers and key into a single string, like "Ctrl-Meta-Shift-S", and match on that. The security interactions between your user script code and document code are fiddly and troublesome, and debugging is distressingly limited. I find using window.eval(`…`) to be a good technique for executing arbitrary code in the security context of the page itself.
- emanuensis 6y agoin Chrome i use this extension https://chrome.google.com/webstore/detail/speed-dial-for-google-chr/mgnlacbnbihgghlfdnpedhlnnkomldlg https://chrome.google.com/webstore/detail/speed-dial-for-goo... There are other more powerful ones i am playing with