2

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.

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

3 Comments

This is not what I am looking for, but i will like like this comment, because for someone this could be really easy. BTW i could not find buildin way to match snippets for keyboard shortcuts. Doing this inside JS looks OK, but not perfect way.
Understood, sorry for not providing an extension that more closely matches your needs. In case someone does take this route I have made an edit to show how to use key combinations to fire code in JS.
Okay, thanks you for your help, i am still will try to do my own extension. But all this suggestions looks like complex resolution, so yeah, will mark this as correct answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.