Forked from jeffkarney/gist:7b12542b7ae3f370299b
Last active
August 29, 2015 14:11
-
-
Save shawn-crigger/95d480709b2304bc7efd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// set the url of the page you would have previously linked to in the iframe | |
//$url = 'http://www.website-to-request.com/'; | |
$url = 'http://www.example.com/'; | |
// Setup the new css you want to inject into the page | |
$css = ' | |
<style type="text/css"> | |
body { background: green; } | |
.some-other-elements { ... } | |
</style> | |
'; | |
// Get the file contents (you may want to replace this with a curl request | |
$site_content = file_get_contents($url); | |
// a simple way to inject style into this page would be to ad it directly above the closing head tag (if there is one) | |
// this can be changed to any element, or even using the dom class you could ammend this with more detail. | |
$site_content = str_replace('</head>', $css.'</head>', $site_content); | |
// you may also need to inject a base href tag so all the links inside are still correct | |
// comment out the next line if not needed | |
$site_content = str_replace('<head>', '<head><base href="'.$url.'" />', $site_content); | |
// return the site contents to the browser | |
echo $site_content; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment