Reputation: 405
I am not frontend developer, So i am did not have chrome dev tools usually open, but i am looking for possibility to run js code in different pages to improve my internet usage.
I tried Chrome Extension that runs js code But it works bad for me. I also tried Chrome Code snippets , but for me this looks like i need to open chrome console, and then run predefined snippet.
To summarize, my question is:
Is it any way(extension,js workaround) to execute predefined js code on any chrome tab via shortcut.
Upvotes: 2
Views: 2761
Reputation: 408
I've been very happy with TamperMonkey
All you have to do is set the URL you want it to run on and then the code will run. With some coding experience you could bind the code to a key press or if not you could simply have it only run when there is a query param present in the URL (like ?runcode=true).
edit: for anyone who does want to go with TamperMonkey you can create your own key shortcuts with code like this:
function KeyPress(e) {
var evtobj = window.event? event : e
if (evtobj.keyCode == 90 && evtobj.ctrlKey) {
// Code to run on Ctrl + Z
}
}
document.onkeydown = KeyPress;
Also, here is a website that will tell you the key code for every key.
Upvotes: 4