[DONE] RFE: work around ?ModPagespeed=noscript

Bug reports and enhancement requests
Post Reply
thunderscript
Posts: 16
Joined: Sat Mar 23, 2013 8:24 pm

[DONE] RFE: work around ?ModPagespeed=noscript

Post by thunderscript »

Hello Giorgio. After the holidays, would you please work around ModPagespeed (an Apache module by Google) which hides already downloaded pages? Maybe as a script surrogate? Websites are increasingly using this for optimization.

In short, if scripts are disabled, ModPagespeed creates a <noscript> element with both a redirect and a stylesheet to hide already downloaded page.
Redirection can be blocked with noscript.forbidMetaRefresh set to true.
Website is downloaded, but hidden from view within the <noscript> tag's <style>.

I believe a surrogate could only strip <style> from inside <noscript> if ModPagespeed is detected, so if a user is already blocking meta-redirects inside <noscript>, they get a working website.

Code: Select all

<noscript><meta HTTP-EQUIV="refresh" content="0;url='http://www.example.com/?ModPagespeed=noscript'" /><style><!--table,div,span,font,p{display:none} --></style><div style="display:block">Please click <a href="http://www.example.com/?ModPagespeed=noscript">here</a> if you are not redirected within a few seconds.</div></noscript>
An example URL and where it redirects to:

Code: Select all

http://www.mhpbooks.com/
http://www.mhpbooks.com/?ModPagespeed=noscript
I wish you pleasant time and happy holidays. :)
Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:26.0) Gecko/20100101 Firefox/26.0
barbaz
Senior Member
Posts: 11110
Joined: Sat Aug 03, 2013 5:45 pm

Re: RFE: work around ?ModPagespeed=noscript

Post by barbaz »

for now, try this surrogate?

Code: Select all

noscript.surrogate.modpagespeed.replacement : window.addEventListener("load", function(){for(let o of document.querySelectorAll("noscript style"))o.parentNode.removeChild(o);}, false)
noscript.surrogate.modpagespeed.sources : !^https?://
you might want to modify the "sources" pref so that this doesn't apply to all pages
*Always* check the changelogs BEFORE updating that important software!
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:26.0) Gecko/20100101 Firefox/26.0 SeaMonkey/2.23
barbaz
Senior Member
Posts: 11110
Joined: Sat Aug 03, 2013 5:45 pm

Re: RFE: work around ?ModPagespeed=noscript

Post by barbaz »

and if modpagespeed *always* inserts a meta element that tries to redirect you to a url containing "ModPagespeed" (case-sensitive), you can try this surrogate

Code: Select all

noscript.surrogate.modpagespeed.replacement : window.addEventListener("load", function(){if(document.querySelector('meta[content*="ModPagespeed"]') != null){for(let o of document.querySelectorAll("noscript style"))o.parentNode.removeChild(o);}}, false)
noscript.surrogate.modpagespeed.sources : !^https?://
*Always* check the changelogs BEFORE updating that important software!
Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20100101 Firefox/17.0
thunderscript
Posts: 16
Joined: Sat Mar 23, 2013 8:24 pm

Re: RFE: work around ?ModPagespeed=noscript

Post by thunderscript »

Hello barbaz. Thank you, that works like a charm. Yes, Google programmed it to always contain ModPagespeed in the redirected URL.

Have a nice day and a happy New Year! :)

@Giorgio, would you please consider adding this to your list of surrogates?
Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:26.0) Gecko/20100101 Firefox/26.0
User avatar
Giorgio Maone
Site Admin
Posts: 9530
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: RFE: work around ?ModPagespeed=noscript

Post by Giorgio Maone »

thunderscript wrote:@Giorgio, would you please consider adding this to your list of surrogates?
Slightly modified version in latest development build 2.6.8.12rc4. Thank you both!
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:26.0) Gecko/20100101 Firefox/26.0
thunderscript
Posts: 16
Joined: Sat Mar 23, 2013 8:24 pm

Re: RFE: work around ?ModPagespeed=noscript

Post by thunderscript »

Sweet, works great. Thank you.
Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:26.0) Gecko/20100101 Firefox/26.0
Post Reply