4

What I want to do is be able to see how it will look any website with my javascript attached . I want to create something like selectorgadget working on any website.

The first idea is to use a proxy (eg privoxy) and define a regular expression changing in html: </head> to <script src="http://myserver.com/my_javascript.js"></script></head>. It works, but in such case, I need to set proxy in my browser. And it is not cool because It visible only for me.

Another idea is to write a website that will download page under the hood and show it. How it will work:

  1. Go to page eg.: http://myserver.com/

  2. My index.php will download eg.: www.google.com using http client or curl, replace page source (add my <script> before </head>) and return page to user. It works, but when page contains relative images I'm not able to see it. Rewriting image src, and other script src is not so simple.

Because I want to add only javascript, I thought that you can use iframes. But there is a restriction to the same domain.

Any ideas on how to do it? Maybe some tool? Something with cross-domain iframe?

3
  • Don't use a proxy. That will not guarantee that the website will function normally. Commented Jan 28, 2011 at 9:38
  • With a proper proxy (that does not require you to type some different address in the browser), it should work normally, no? Commented Jan 28, 2011 at 9:57
  • I do not need that all links will works OK. I just want to see how this page will be looks like. The apache reverse proxy mode is what I need. Commented Jan 28, 2011 at 15:28

5 Answers 5

2

You can configure Apache web server to work in reverse proxy mode and use your first approach. Hence it will work very similar to your second case, but all replacement Apache server will do for you.

Sign up to request clarification or add additional context in comments.

Comments

2

I'll throw Greasemonkey into the list of suggestions. Also note that FireBug allows you to run arbitrary JavaScript on a page, plus a lot more useful stuff for developing & debugging web apps.

(Although from your short description, I agree with awoodland that bookmarklets are probably the best solution.)

Comments

1

Bookmarklets let you do exactly this without any kludges.

Comments

1

if you are using Chrome, you can develop a simple extension and use the content scripts.

Comments

0

You can use the following project which is a node based proxy that can allow you to include any arbitrary JS or CSS in all pages

https://github.com/amitamb/plugin-proxy

I am the developer of the project.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.