Sorry, not likely to happen (except as a security hole). Your in-page JavaScript is deliberately sandboxed and limited - it can interact with the page, and with the network through AJAX, but it cannot and should not interact with other things that happen in your computer - including the browser.
Answer from Piskvor left the building on Stack OverflowIs there a way to create and run javascript in Chrome? - Stack Overflow
Chrome dev console: Is there a way to execute JS with Ctrl+Enter as opposed to just Enter?
I have code that I run in Chrome's developer tools javascript console. Is there a way to do this programmatically?
I am currently exploring Chrome DevTools - Console Tab. Can you'll help me how can I use it to the maximum benefit while doing technical seo audit
"); (Reload the page to reset it.) The network tab can tell you about HTTP status codes and headers. The inspector tab shows the rendered DOM after JavaScript and CSS work on it. If you want to see the server-rendered HTML use ctrl-u (command-u on Mac) instead. Firefox is a little better than Chrome for that, because it will highlight HTML errors in red. More on reddit.com
Videos
Sorry, not likely to happen (except as a security hole). Your in-page JavaScript is deliberately sandboxed and limited - it can interact with the page, and with the network through AJAX, but it cannot and should not interact with other things that happen in your computer - including the browser.
It is not clear why you need to provide such link. DevTools is not a tool for the end user. If you don't like keyboard shortcuts, then there is a page chrome://inspect/ which has the list of pages and extensions, and each entry has a link that opens devtools.
Also, you may use remote debugging page which opens devtools in a page. https://developers.google.com/chrome-developer-tools/docs/remote-debugging
if you don't want to explicitly create a js file but still want to test your javascript code, you can use snippets to run your JS code.
Follow the steps here:
- Open Dev Tools
- Go to Sources Tab
- Under Sources tab go to snippets, + New snippet
- Paste your JS code in the editor then run Command + Enter on a Mac, or Ctrl + Enter on Windows or Linux. You should see the output in console if you are using console.log or similar to test. You can edit the current web page that you have open or run scripts, load more javascript files. (Just note: this snippets are not stored on as a js file, unless you explicitly did, on your computer so if you remove chrome you will lose all your snippets);
- You also have a option to save as your snippet if you right click on your snippet.
Try this:
1. Install Node.js from https://nodejs.org/
2. Place your JavaScript code into a .js file (e.g. someCode.js)
3. Open a cmd shell (or Terminal on Mac) and use Node's Read-Eval-Print-Loop (REPL) to execute someCode.js like this:
> node someCode.js
Hope this helps!
When writing multiline JS in the dev console, you have to hit Shit+Enter to create a new line. However, sometimes I mess up and hit just Enter which executes the whole script. It's not a big deal for most scripts, but I am working with JS that sends data to an API, so accidental execution can be an annoyance. If I could change the shortcut to Ctrl+Enter to execute and use Enter to create a new line, that would be ideal.
I run an online game and have some JS commands I run to get various data out of the game. There is no backend, and it's not sensitive info so idc about that.
I'd like to have a way to have a script run every day programmatically -- like just have a cron job that goes, executes the JS as if I was running it in dev console, and take the results and feed into another pipeline.
Is this achievable? Or am I overthinking some other obvious solution?