Replace remote JavaScript file with a local debugging copy using Greasemonkey or userscript

Tom H picture Tom H · Oct 16, 2011 · Viewed 15.5k times · Source

While debugging a client app that uses a Google backend, I have added some debugging versions of the functions and inserted them using the Chrome Developer Tools script editor.

However there are a number of limitations with this approach, first is that the editor doesn't seem to always work with de-minified files, and when the JS file is 35K lines long, this is a problem.

Another issue is that all the initialization that is done during load time, uses the original "unpatched" functions, hence this is not ideal.

I would like to replace the remote javascript.js file with my own local copy, presumably using some regex on the file name, or whatever strategy was suitable, I am happy to use either Firefox or Chrome, if one was easier than the other.

Answer

sachinjain024 picture sachinjain024 · Mar 18, 2016

There is one more tool Requestly - Chrome Extension which can be used to rewrite URLs and replace your production libraries with local hosted libraries with much easy setup and very friendly interface.

Have a look at this:

enter image description here

PS: I know this was answered but I still answered this considering it will be very beneficial to future readers.