This and many other helpful things can be done trough Snippets. You can find a lot of them here.
How we can use them:
- Open Developers Tools in Chrome.
- Click on Sources Tab.
- On the left panel you will have several tabs: Sources, Content scripts and Snippets.
- Click on the last one.
- Click with the right mouse button on the empty tab content and should appear a new option.
- Click on new option, you are going to write your first Snippet. Write a name for it.
- Write the code in the right panel and save it.
After that you can use your snippet, to do it, click the snippet with the right button and and select run option.