Please how can i attach a JavaScript file to my chrome, so as any page loads it runs the code on that page?
Does chrome save the html pages it loads somewhere on local disk c that it can be accessed?
You can make a chrome extension to run your script.
As a previous user said, you can build your own extension and you can run it in chrome.
IF it is only a temporary task, you can click on F12 (open the DevTools) and click on Console. There you can paste your own javascript function / script that will be run in the current page.
Note this works only for the current page (where you have the console opened).
You might want to try and use Selenium https://chrome.google.com/webstore/detail/selenium-ide/mooikfkahbdckldjjndioackbalphokd?hl=en