Is it possible to load in a local version of a JavaScript file instead of the server version?

前端 未结 5 858
醉梦人生
醉梦人生 2021-02-08 04:59

Just had a quick question to throw out and see if there was a solution for this...

Let\'s pretend I have no access to the server. I load up a webpage and find out that t

5条回答
  •  终归单人心
    2021-02-08 05:12

    I actually found a solution for this. Posting details for anyone that comes here looking for it.

    Privoxy (www.privoxy.org/) [Free] Allows this for the most part through a redirect. Though Firefox may block the redirect depending on where you put it. This means you most likely will not be able to save the file locally and reference it via file://etc/

    ( I wish I had a way to tell you how to statically fiddle with JavaScript on web pages you have limited access to... but I have not found it. If an answer comes along I will accept it over this. )

    Of course, you have to set up Privoxy, and use it as a local proxy server. It's pretty simple if you only use it temporarily: Just point your browser to proxy 127.0.0.1 on port 8118 with it running.

    You have to add a redirect "default action" (Options > Edit Default Actions) to redirect the browser to use your new copy:

    { +redirect{/newLocation/some.js} }
     /scripts/js/some.js
    

提交回复
热议问题