i am trying to basically replace a webpage’s url with its ip address for example, instead of
www.facebook.com
i want to replace it with
66.220.153.11
Rationale
i have recently discovered that our school blocks websites based on a particular string patern in the url for example www.facebook.com is blocked but 66.220.153.11 is not yet they are the same thing.
so i want to learn how to do this using javascript(is this possible?) so i can develop a firefox addon to automatically change the url http://www.facebook.com to 66.220.153.11 and beat the censorship.
i am usually a c programmer but i know little javascript. Help me out. Thanks
(Assuming accessing the site via the IP works)
I don’t know in how detailed you expect an answer to be, but here is a general approach:
Changing the host
This is easy. The
locationobject has an attributehostname. If you have the IP address, you can just assign it tolocation.hostname. On change, the site will reload (example – of course the target page does not exist).In your plugin, you can attach an event handler for the
loadevent to thegBrowserobject. Read about Intercepting Page Loads.Getting the IP address
This is trickier. The only thing that comes to my mind is to use some web service
that does host name to IP resolution. So you would have to use Ajax with (probably) JSONP for this.
I hope this gives you a start.