在自己的网站中显示外部内容(将浏览器模拟为Web应用程序)

I would like to build a Web application that provides additional information about website "on the fly". For example, users go to my website but there they can browse other pages, e.g., within an iframe as the main part of my site. But now, depending on the website the user is currently browsing on, I also want to display additional information like some comments or ratings associated with that site.

The solution using an iframe to display the external pages would be straightforward. However, due to security isses, there's no way to keep track of the currently loaded URL in the iframe if the URL is not of the domain as the parent page. As soon as a user would click on a link in the external page, my parent page would not know the new location an could not update the additional information accordingly.

I've tried some simple workarounds, includung using a PHP script grab.php to fetch and display external content:

<?php
  $ch = curl_init($_GET['url']);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  $content = curl_exec($ch);
  curl_close($ch); 
  echo $content;
?>

Then the src of the iframe would always be something like

<iframe src="grab.php?url=http://www.google.com" width="1200" height="800"></iframe>

This comes with several problems though. Firstly, relative source, e.g., to images, point to a location with my domain and are therefore not displayed. Secondly, I would also need to tweak all relative and absolute links contained in the external page to something like grab.php?url=.... And lastly, this doesn't work with content the external page has to load dynamically. The last point seems to be a major buzzkill.

My question is now, is there any way this could be realized?

(I currently have a solution using a browser extension which opens a popup window to show the additional information. But obviously the extension is browser dependent, and an alternative solution that doesn't require users to install an extension at all would be great. Everything would be trivial if I could get the current URL of the iframe).