How to include JavaScript file or library in Chrome console?

后端 未结 10 1892
广开言路
广开言路 2020-11-27 08:58

Is there a simpler (native perhaps?) way to include an external script file in the Google Chrome browser?

Currently I’m doing it like this:

document.         


        
10条回答
  •  鱼传尺愫
    2020-11-27 09:43

    In the modern browsers you can use the fetch to download resource (Mozilla docs) and then eval to execute it.

    For example to download Angular1 you need to type:

    fetch('https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.min.js')
        .then(response => response.text())
        .then(text => eval(text))
        .then(() => { /* now you can use your library */ })
    

提交回复
热议问题