How do I execute a client redirect (based on page content) to a html file?
I am trying to help someone who has a Firefox Add-on that prevents access to adult sites. It works fine and when a blocked URL is entered, this is returned:
The http://www.blocked-site.com domain is blocked to protect this computer from malware or pornographic content.
[NOTE the "www.blocked-site.com" above is just an example; in actuality, the domain is shown]
My friend has created a html file on his computer with a stronger admonition and would like for the browser to redirect to, and display, his custom html file instead of what is currently served.
I am pretty sure something would have to examine the incoming page for some text excluding the actual domain because that would change depending on which site access was attempted. Maybe examine the incoming page for "domain is blocked to protect this computer" and, if present, display the html file. I just don't know how to do it.
I would appreciate any help.
Izabrano rješenje
Thank you very much - it performs exactly as I wanted (in principle). I will have fun tweaking it.
Thanks for introducing me to the monkey user scripts. I installed TamperMonkey and it works fine.
Pročitajte ovaj odgovor sa objašnjenjem 👍 0All Replies (14)
This might be a hard request to fulfill because web content, and even extensions, are not supposed to have access to file:/// URLs on your computer. It might be easier if the message page were on the internet; I think there probably are extensions to redirect from one web address to another. Then it would just be a matter of finding a good place to host the page (maybe a OneDrive folder, Google Drive, Dropbox, etc.?).
I guess I did not describe it clearly. The message displayed IS on a web page. The URL is
http://haydentech.com/private/dns/dns.php?report=www.blocked-site.com
The message shown in the original post is displayed on the page for which I just provided the URL. I really messed up the question, I'm afraid.
Thanks for your response, though, it helped me clarify the issue.
I know that within Firefox we can open a file:/// URL and that is precisely what we want when such a message as above is shown. I hope that makes sense.
dasadler said
I know that within Firefox we can open a file:/// URL and that is precisely what we want when such a message as above is shown.
Yes, a human user can direct Firefox to do that, but websites and add-ons are not trusted to go to random parts of the hard drive...
It sounds as though the URL is very consistent and you could use an add-on to modify the page contents directly. For example, a "user script" applied using an extension like Tampermonkey, Violentmonkey or Greasemonkey could change the text from
The www.blocked-site.com domain is blocked to protect this computer from malware or pornographic content.
to something like
Just saved you from ruining your career at www.blocked-site.com. You're welcome.
The script also could modify the colors, font sizes, inject images, etc.
If that's of interest.
But a script could not open a file:/// stored on the user's computer?
I thought scripts could basically act as a proxy for the user as defined by the code.
jscher2000 said
It sounds as though the URL is very consistent and you could use an add-on to modify the page contents directly. For example, a "user script" applied using an extension like Tampermonkey, Violentmonkey or Greasemonkey could change the text from The www.blocked-site.com domain is blocked to protect this computer from malware or pornographic content. to something like Just saved you from ruining your career at www.blocked-site.com. You're welcome. The script also could modify the colors, font sizes, inject images, etc.
If I understand your reply... you're saying that a script could effectively create a web page dynamically? If that is the case, then I suppose it could create the same as the html file he wants displayed. Maybe even better because it could incorporate the name of the blocked site.
But where or how would someone (a very non technical someone) even begin to develop such code?
Izmjenjeno
dasadler said
a Firefox Add-on that prevents access
Ugh., wouldn't you be better off with system-wide parental permissions?.. A (local) proxy, VPN and /or a (router) firewall made for this and similar? :-o
Izmjenjeno
That would involve some subscription fee. Thanks anyway, I appreciate your thoughts.
dasadler said
kgb saidUgh., wouldn't you be better off with system-wide parental permissions?That would involve some subscription fee.
I think some are free: http://www1.k9webprotection.com/
dasadler said
If I understand your reply... you're saying that a script could effectively create a web page dynamically? If that is the case, then I suppose it could create the same as the html file he wants displayed. Maybe even better because it could incorporate the name of the blocked site. But where or how would someone (a very non technical someone) even begin to develop such code?
This sounds like a call for volunteers. ;-)
I can create a template for the script. The tedious part is filling in the desired HTML because it needs to be properly quoted in order to inserted by the script.
Thank you.
I think that given a template, I might (??) be able to do the HTML. The html page that has already been created is fairly simplistic. Basically changing the background color to red, an image centered at top, and a couple of lines of white text with different point size.
I would need some guidance on how/where to actually use this script. I don't know if it would go in the userChrome.css or if I would need to use one of the monkey add-ons (and how to actually use it).
jscher2000 said
I can create a template for the script. The tedious part is filling in the desired HTML because it needs to be properly quoted in order to inserted by the script.
Did I miss it or was the template for the script not done? If there will not be a template created, please advise so I can seek a solution elsewhere.
Thanks.
I don't know what happened to my draft script from last month, but I created a new one and posted it here:
https://greasyfork.org/en/scripts/367925-customize-hayden-technologies-dns-block-page
You would apply that using Violentmonkey / Tampermonkey / Greasemonkey. I only tested in Violentmonkey. Screenshot of the current HTML/CSS/image attached.
Odabrano rješenje
Thank you very much - it performs exactly as I wanted (in principle). I will have fun tweaking it.
Thanks for introducing me to the monkey user scripts. I installed TamperMonkey and it works fine.
jscher2000 said
I think some are free: http://www1.k9webprotection.com/
Yes, ofc. There would have to be free services... For example, something like,
@https://www.google.com/search?q=free+adult+parental+windows+localhost+vpn
Then, there's the OpenDNS Family Shield, https://www.opendns.com/home-internet-security/
... And so on,
@https://www.google.com/search?q=free+parental+controls+dns+proxy