At my job they use a "central login" facility on internal webpages. Whenever an internal webpage requires authentication, it forwards you to the central login, and after logging in, it sends you back to the page you were trying to view.
The very first line in the HTML for this central login page starts with this:
<!-- Encoding=ISO-8859-1;
But it never ends the comment, which means that all the HTML code in the whole document is actually commented out. This works fine in IE6 (which is the company standard - eek!), and it used to work in Firefox, but when I upgraded to Firefox 4, this no longer works (as it shouldn't - it is following standards).
I have saved the source and changed the first line to:
<!-- Encoding=ISO-8859-1; -->
And then the page will display, but since it is loaded from file:///
, I can't submit my credentials to the main server...
I hate using IE6, but for all internal pages I am stuck with it because Firefox renders an empty page every time I get sent to the central login.
Is it possible to create a Firefox addon (or even a Greasemonkey script) to modify the HTML as it is coming into the browser before it gets rendered? I see tons of examples of modifying HTML once it is already loaded, but can't find anything to manipulate while loading it.
I guess I'm open to other solutions besides an addon, but that was the only thing I could think of. Also, we are not allowed to use Chrome or Safari, so that is out. And no, I cannot talk to the person in charge of the central login page and get them to change it. Proxying would probably be very difficult too because of the nature of the page.
Thanks in advance!
Maybe a local Apache with mod_proxy and mod_subsitute could be used for this? Derived from an example from berkek.com:
<VirtualHost *>
ServerAdmin [email protected]
ServerName www.yourcompany.com
<Proxy *>
Order deny,allow
</Proxy>
ProxyRequests on
ProxyPass / http://www.yourcompany.com/
ProxyPassReverse / http://www.yourcompany.com/
AddOutputFilterByType SUBSTITUTE text/html
Substitute "s|<!-- Encoding=ISO-8859-1;|<!-- Encoding=ISO-8859-1; -->|n"
</VirtualHost>
Here is a method I found:
The Fiddler Web Debugging Proxy. It is basically doing what @Tatu Lahtela suggested and what @alex suggested, only without apache.
Here are the steps I took:
In my text editor, I found the OnBeforeResponse
function, and added this code:
if (oSession.oResponse.headers.ExistsAndContains("Content-Type", "html")){
// Remove any compression or chunking
oSession.utilDecodeResponse();
var oBody = System.Text.Encoding.UTF8.GetString(oSession.responseBodyBytes);
var oRegEx = /<!-- Encoding=ISO-8859-1; /gi;
oBody = oBody.replace(oRegEx, "<!-- Encoding=ISO-8859-1; -->");
oSession.utilSetResponseBody(oBody);
}
In Fiddler, under Tools->Options->Connections tab, click "Copy browser Proxy Configuration URL" (This is the proxy PAC file that @Tatu Lahtela mentioned).
I modified the PAC file to limit the sites that went to Fiddler like @Tatu Lahtela suggested.
This works for me, with minimal setup. A Firefox addon would be better for me since I wouldn't have to use an external program, but building one to do this seems pretty difficult.
Thanks to everyone who helped! I will mark @Tatu Lahtela 's answer as the accepted answer since that is how I was able to find what I needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With