|
@@ -1,62 +1,4 @@
|
|
|
;(function() {
|
|
|
- function loadJS (url, success, inject) {
|
|
|
- var scripts = document.getElementsByTagName('script')
|
|
|
- for (var i = 0; i < scripts.length; i++) {
|
|
|
- if (scripts[i].src && scripts[i].src.indexOf(url) > -1) {
|
|
|
- if (success) success();
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- var domScript = document.createElement('script');
|
|
|
- domScript.src = url;
|
|
|
- typeof inject === 'function' ? inject(domScript) : null;
|
|
|
- success = success || function () {};
|
|
|
- domScript.onload = domScript.onreadystatechange = function () {
|
|
|
- if (!this.readyState || 'loaded' === this.readyState || 'complete' === this.readyState) {
|
|
|
- success();
|
|
|
- this.onload = this.onreadystatechange = null;
|
|
|
- //this.parentNode.removeChild(this);
|
|
|
- }
|
|
|
- }
|
|
|
- document.getElementsByTagName('head')[0].appendChild(domScript);
|
|
|
- }
|
|
|
-
|
|
|
- function injectDevTools () {
|
|
|
-
|
|
|
- const devToolsAssets = [
|
|
|
- 'https://pagespy.jydev.jianyu360.com/page-spy/index.min.js',
|
|
|
- 'https://pagespy.jydev.jianyu360.com/plugin/data-harbor/index.min.js',
|
|
|
- 'https://pagespy.jydev.jianyu360.com/plugin/rrweb/index.min.js',
|
|
|
- ]
|
|
|
- const waitStates = [false, false, false]
|
|
|
- function checkLoadState () {
|
|
|
- const result = !waitStates.some(v => !v)
|
|
|
- if (result) {
|
|
|
- console.log('注入远程调试依赖成功')
|
|
|
- window.$harbor = new DataHarborPlugin();
|
|
|
- window.$rrweb = new RRWebPlugin();
|
|
|
-
|
|
|
- [window.$harbor, window.$rrweb].forEach(p => {
|
|
|
- PageSpy.registerPlugin(p)
|
|
|
- })
|
|
|
-
|
|
|
- window.$pageSpy = new PageSpy();
|
|
|
- }
|
|
|
- }
|
|
|
- function loadToolsSuccess (i) {
|
|
|
- waitStates[i] = true
|
|
|
- checkLoadState()
|
|
|
- }
|
|
|
- for (let i = 0; i < devToolsAssets.length; i++) {
|
|
|
- loadJS(devToolsAssets[i], () => {
|
|
|
- loadToolsSuccess(i)
|
|
|
- }, (scriptDom) => {
|
|
|
- scriptDom.crossorigin = 'anonymous'
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- injectDevTools();
|
|
|
var host = location.host
|
|
|
var hm = document.createElement("script");
|
|
|
// 去除query后的location
|