views:

49

answers:

3

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 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

+3  A: 

(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 location object has an attribute hostname. If you have the IP address, you can just assign it to location.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 load event to the gBrowser object. 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.

Felix Kling
+1  A: 

This cant't work for the most domains in the world, because the IP points to a server, not to a domain. If there are hosted different domains on the same server(often hundreds of domains are hosted on one server), there is no way to point at the wanted domain without knowledge of the virtualhost-settings(which are usually not public).

You may take a look at this and see, how many domains can depend on a single IP:
http://www.robtex.com/ip/194.117.254.46.html

Also see, how many domains are hosted on the facebook-IP:
http://www.robtex.com/ip/66.220.153.11.html

Dr.Molle
A: 

Why don't you use a proxy to bypass the blocks?

Peter van Kekem