开发者

browser extension to replace JavaScript file on a live site for testing

开发者 https://www.devze.com 2023-01-04 13:40 出处:网络
I\'m looking for a browser extension (Firefox, Chrome) allowing to replace a Javascript file on a live Web site to do some testing/hacking.

I'm looking for a browser extension (Firefox, Chrome) allowing to replace a Javascript file on a live Web site to do some testing/hacking.

Basically, it should take a URL and load anoth开发者_如何学JAVAer one instead (locally or on a HTTP development server).

Any idea?


Try http://www.fiddler2.com/fiddler2/version.asp

It does that and much more. But it's not a browser extension.


I think this is a task for a personal proxy. You can sniff traffic on the proxy and apply rules to modify requests/content


The Opera browser has similar functionality:

  1. View source code of the page (Ctrl+U).
  2. Make some changes. Or paste and replace the entire file.
  3. Press Apply Changes in the toolbar (Ctrl+R).

For editing linked resources (such as javascript or CSS files), use the following approach:

  1. Open the linked resource in a new tab.
  2. View "source code" of the resource (Ctrl+U).
  3. Make some changes.
  4. Press Apply Changes in the toolbar (Ctrl+R).
  5. Return to the tab with the webpage and realod (Ctrl+R).


Alternatives:

  • Using chrome you can change code on the fly (Developer tools -> Sources tab) and just save it (command + s)
  • Use the LiveReload app that actually attaches an extension (that kind of does what you want) http://livereload.com/

This may not be the "exact" answer to your question, yet I almost sure one of those will do what you want to do.


Not sure if this helps or not, but I just encountered a chrome plugin called Resource Override, which sounds like it does something similar. Im trying out the Fiddler which someone else mentioned, but I think i'm also going to try this one at some point. https://chrome.google.com/webstore/detail/resource-override/pkoacgokdfckfpndoffpifphamojphii?hl=en


You can intercept and block requests in browsers. For example in Chrome you can use the beforeload event check if it's a JS (event.target is script tag or event.url ends in .js) call event.preventDefault() and then load your own script instead.

I'm pretty sure there's a similar way to do this in FF.


There is https everywhere which lets you define rules for url rewrites. This should work on all request, including script requests.

Tamper data might do the job, but I don't know how automated/permanent you can set it up.

And there is also an extension called redirector. I didn't test that one. Potentially it only works on the address bar.

Update:

That is unfortunate. In that case probably a proxy is you only way. What about a firefox extension that is a proxy, like Foxyproxy


ColBeseder correctly brings up Fiddler (http://www.fiddler2.com/fiddler2/version.asp) as a solution to your issue.

Fiddler is perfectly capable of handling and decrypting HTTPS traffic as well - see the documentation on the page for how to configure it.

To directly answer the OP question, you can use the autoresponder feature in Fiddler to hack your production JS for testing.

Enable the autoresponder tab in Fiddler, making sure to leave pass through for unmatched requests checked, entering the URL of the JS files you want to substitute as the pattern. Select the response file from your local filesystem, and go to town!

See http://yuiblog.com/blog/2008/06/27/fiddler/ (bottom of article is most relevant) for an example.


You should probably consider robohydra, since it is specifically developed for your case. They do not support https yet, but they are open to including it in the future.


Disclaimer: I'm the author of the software :-)

A different approach that might suit your usecase better is to use a RoboHydra-based development proxy. The idea here would be that you want to keep ALL Javascript files in your machine, and use another server simply as a backend. It's great for eg. front-end developers that don't want to have the whole backend installed in their machines.

You can see the documentation, tutorials and such at http://robohydra.org/, and have an article describing exactly that usecase at http://dev.opera.com/articles/view/robohydra-a-new-testing-tool-for-client-server-interactions/.

However, as of now it can't proxy to HTTPS URLs, but that should be a trivial change that I intend to do soon anyway.


How about Greasemonkey? That should be the thing you're searching for!

0

精彩评论

暂无评论...
验证码 换一张
取 消