开发者

Run my own script inside Chrome's debugger console?

开发者 https://www.devze.com 2023-02-15 18:56 出处:网络
I\'m tired of re-typing the same com开发者_运维问答mands into Chrome\'s developer console. Is it possible to load a script that I have saved on my local machine?If you\'re running developer tools on a

I'm tired of re-typing the same com开发者_运维问答mands into Chrome's developer console. Is it possible to load a script that I have saved on my local machine?


If you're running developer tools on a file:// URL, you can do something like:

s = document.createElement('script'); 
s.src = 'file://path/to/script.js'; 
document.body.appendChild(s);

As a workaround you could also paste in your oft-repeated code snippet into the developer tools.


As @PaulIrish pointed out in the comments Chrome's Snippets are their solution to this problem. This screenshot below shows were to find snippets within Chrome's developer tools as of this writing. To run a snippet right click on its entry in the snippet pane, pictured on the left, and select "Run":

Run my own script inside Chrome's debugger console?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号