apply js to 3rd party web pages using iframes or something else

Is it possible to load different 3rd party web pages and apply a js script to each one?

Suppose we want to first load yahoo.com, and then get the innerHTML of the body and do something with it, and then load google.com and again get the innerHTML of the body an do something with it?