How can I control chrome with javascript?

I can control with right click,inspect and console a webpage.But,When the web page is refreshed, the javascript codes I wrote in the console are not valid.
So,I want to control chrome from a fixed javascript console window.The javascript codes I write should work not only on one website, but also on all websites.
Can you help me?