Override Javascript file in chrome

后端 未结 6 1327
天涯浪人
天涯浪人 2020-12-07 21:09

I would like to override a javascript file with my own version of the similar javascript file in chrome.

Let me explain:

1) Lets say a site \'http://example.

6条回答
  •  感情败类
    2020-12-07 21:56

    you can load your file into the page by adding (or executing in the console) this script.

    window.onload = function () {
      var script = document.createElement('script');
      script.src = '//localhost/your/script';
      script.onload = function() {
        console.log('your script have been loaded');
      }
      document.body.appendChild(script);
    }
    

    If the file that you want to override contains global functions/variables will be override with the new version in your file or if the elements that you want to override are namespaced just follow the path (e.g My.namespace.method = myNewMethod)

提交回复
热议问题