├── public ├── .DS_Store ├── icon │ ├── logo.png │ ├── logo.psd │ ├── eno-logo.png │ ├── omi-logo.png │ └── eno-logo-128.png └── screenshot │ └── 1.png ├── push.sh ├── dist ├── index.html ├── index.prod.js ├── index.dev.js └── axios.min.js ├── manifest.json ├── test ├── test2.html ├── test3.html └── test1.html ├── README.md └── index.js /public/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wscats/spy/HEAD/public/.DS_Store -------------------------------------------------------------------------------- /public/icon/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wscats/spy/HEAD/public/icon/logo.png -------------------------------------------------------------------------------- /public/icon/logo.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wscats/spy/HEAD/public/icon/logo.psd -------------------------------------------------------------------------------- /public/screenshot/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wscats/spy/HEAD/public/screenshot/1.png -------------------------------------------------------------------------------- /public/icon/eno-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wscats/spy/HEAD/public/icon/eno-logo.png -------------------------------------------------------------------------------- /public/icon/omi-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wscats/spy/HEAD/public/icon/omi-logo.png -------------------------------------------------------------------------------- /public/icon/eno-logo-128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wscats/spy/HEAD/public/icon/eno-logo-128.png -------------------------------------------------------------------------------- /push.sh: -------------------------------------------------------------------------------- 1 | git add . 2 | echo -n "enter commit message:" ---: 3 | read name 4 | git commit -m"$name" 5 | git push origin master -------------------------------------------------------------------------------- /dist/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Document 9 | 10 | 11 | 12 | 13 | 14 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Spy", 3 | "manifest_version": 2, 4 | "version": "0.74", 5 | "description": "This extension allows you to quickly see a DOM element's attributes by simply hovering your mouse over it inside your browser.", 6 | "icons": { 7 | "16": "public/icon/eno-logo-128.png", 8 | "48": "public/icon/eno-logo-128.png", 9 | "128": "public/icon/eno-logo-128.png" 10 | }, 11 | "content_scripts": [ 12 | { 13 | "matches": [ 14 | "https://*/*", 15 | "http://*/*" 16 | ], 17 | "js": [ 18 | "dist/axios.min.js", 19 | "dist/index.dev.js" 20 | ] 21 | } 22 | ], 23 | "browser_action": { 24 | "default_title": "", 25 | "default_icon": { 26 | "16": "public/icon/eno-logo-128.png", 27 | "48": "public/icon/eno-logo-128.png", 28 | "128": "public/icon/eno-logo-128.png" 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /test/test2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Document 9 | 10 | 11 | 12 | 13 | 30 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /test/test3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Document 9 | 10 | 11 | 12 | 13 | 48 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /dist/index.prod.js: -------------------------------------------------------------------------------- 1 | "use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}!function(){function t(e){if(e&&"object"===_typeof(e)){var t=e.which||e.keyCode||e.charCode;t&&(e=t)}if("number"==typeof e)return a[e];var o,n=String(e);return(o=r[n.toLowerCase()])?o:(o=c[n.toLowerCase()])||(1===n.length?n.charCodeAt(0):void 0)}t.isEventKey=function(e,t){if(e&&"object"===_typeof(e)){var o=e.which||e.keyCode||e.charCode;if(null==o)return!1;if("string"==typeof t){var n;if(n=r[t.toLowerCase()])return n===o;if(n=c[t.toLowerCase()])return n===o}else if("number"==typeof t)return t===o;return!1}};var r={backspace:8,tab:9,enter:13,shift:16,ctrl:17,alt:18,"pause/break":19,"caps lock":20,esc:27,space:32,"page up":33,"page down":34,end:35,home:36,left:37,up:38,right:39,down:40,insert:45,delete:46,command:91,"left command":91,"right command":93,"numpad *":106,"numpad +":107,"numpad -":109,"numpad .":110,"numpad /":111,"num lock":144,"scroll lock":145,"my computer":182,"my calculator":183,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222},c={windows:91,"⇧":16,"⌥":18,"⌃":17,"⌘":91,ctl:17,control:17,option:18,pause:19,break:19,caps:20,return:13,escape:27,spc:32,spacebar:32,pgup:33,pgdn:34,ins:45,del:46,cmd:91};for(e=97;e<123;e++)r[String.fromCharCode(e)]=e-32;for(var e=48;e<58;e++)r[e-48]=e;for(e=1;e<13;e++)r["f"+e]=e+111;for(e=0;e<10;e++)r["numpad "+e]=e+96;var a={};for(e in r)a[r[e]]=e;for(var o in c)r[o]=c[o];document.addEventListener("keyup",function(e){console.log("You pressed",t(e))})}(),console.log(1),function(){var r="spyon-container",c=3;function e(e){document.getElementById(r).style.display="none"}function t(e){var t=document.getElementById(r);t?"block"!==t.style.display&&(t.style.display="block"):d()}function o(e){var t=document.getElementById(r);if(t){var o=e.clientX+a().left+c,n=e.clientY+a().top+c;t.innerHTML=function(e){var t=''.concat(e.nodeName.toLowerCase(),"
"),o=Array.from(e.attributes).reduce(function(e,t){return e+=''.concat(t.nodeName,'="').concat(t.nodeValue,'"
')},"");return t+o}(e.target),o+t.offsetWidth>window.innerWidth?t.style.left=o-t.offsetWidth+"px":t.style.left=o+"px",t.style.top=n+"px"}else d()}function a(){return!document.all?{left:document.documentElement.scrollLeft,top:document.documentElement.scrollTop}:{left:document.body.scrollLeft,top:document.body.scrollTop}}function d(){var e=document.createElement("div");e.id=r,e.setAttribute("style","\n position: absolute;\n left: 0;\n top: 0;\n width: auto;\n height: auto;\n padding: 10px;\n box-sizing: border-box;\n color: #fff;\n background-color: #444;\n z-index: 100000;\n font-size: 12px;\n border-radius: 5px;\n line-height: 20px;\n max-width: 45%;\n "),document.body.appendChild(e)}document.body.addEventListener("mousemove",o),document.body.addEventListener("mouseover",t),document.body.addEventListener("mouseleave",e)}(); -------------------------------------------------------------------------------- /test/test1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Document 9 | 10 | 11 | 12 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Spy 2 | 3 | Download: [Google Extension](https://chrome.google.com/webstore/detail/spy/fjidbhefebofcjhnjbifaejndlhlffoo?hl=zh-CN) 4 | 5 | A simple module that displays DOM attributes on mouseover inside a tooltip. 6 | 7 | # Demo 8 | 9 | 10 | 11 | # Instructions 12 | 13 | Copy and paste the entire code into your web console 14 | Include the JS file in your code base 15 | This is implemented as an IIFE so the spy is turned on immediately upon execution. 16 | 17 | # Use cases 18 | Help troubleshoot a UI bug 19 | Ensure that your app's DOM elements are working as expected (getting the right class on click, etc) 20 | Find out how another web app is structured 21 | 22 | # Thanks 23 | 24 | - [spyon](https://github.com/eddieherm/spyon) 25 | 26 | ## License 27 | 28 | Spy is released under the MIT. 29 | 30 | -------------------------------------------------------------------------------- /dist/index.dev.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } 4 | 5 | (function () { 6 | function keyCode(searchInput) { 7 | // Keyboard Events 8 | if (searchInput && 'object' === _typeof(searchInput)) { 9 | var hasKeyCode = searchInput.which || searchInput.keyCode || searchInput.charCode; 10 | if (hasKeyCode) searchInput = hasKeyCode; 11 | } // Numbers 12 | 13 | 14 | if ('number' === typeof searchInput) return names[searchInput]; // Everything else (cast to string) 15 | 16 | var search = String(searchInput); // check codes 17 | 18 | var foundNamedKey = codes[search.toLowerCase()]; 19 | if (foundNamedKey) return foundNamedKey; // check aliases 20 | 21 | var foundNamedKey = aliases[search.toLowerCase()]; 22 | if (foundNamedKey) return foundNamedKey; // weird character? 23 | 24 | if (search.length === 1) return search.charCodeAt(0); 25 | return undefined; 26 | } 27 | /** 28 | * Compares a keyboard event with a given keyCode or keyName. 29 | * 30 | * @param {Event} event Keyboard event that should be tested 31 | * @param {Mixed} keyCode {Number} or keyName {String} 32 | * @return {Boolean} 33 | * @api public 34 | */ 35 | 36 | 37 | keyCode.isEventKey = function isEventKey(event, nameOrCode) { 38 | if (event && 'object' === _typeof(event)) { 39 | var keyCode = event.which || event.keyCode || event.charCode; 40 | 41 | if (keyCode === null || keyCode === undefined) { 42 | return false; 43 | } 44 | 45 | if (typeof nameOrCode === 'string') { 46 | // check codes 47 | var foundNamedKey = codes[nameOrCode.toLowerCase()]; 48 | 49 | if (foundNamedKey) { 50 | return foundNamedKey === keyCode; 51 | } // check aliases 52 | 53 | 54 | var foundNamedKey = aliases[nameOrCode.toLowerCase()]; 55 | 56 | if (foundNamedKey) { 57 | return foundNamedKey === keyCode; 58 | } 59 | } else if (typeof nameOrCode === 'number') { 60 | return nameOrCode === keyCode; 61 | } 62 | 63 | return false; 64 | } 65 | }; 66 | /** 67 | * Get by name 68 | * 69 | * exports.code['enter'] // => 13 70 | */ 71 | 72 | 73 | var codes = { 74 | 'backspace': 8, 75 | 'tab': 9, 76 | 'enter': 13, 77 | 'shift': 16, 78 | 'ctrl': 17, 79 | 'alt': 18, 80 | 'pause/break': 19, 81 | 'caps lock': 20, 82 | 'esc': 27, 83 | 'space': 32, 84 | 'page up': 33, 85 | 'page down': 34, 86 | 'end': 35, 87 | 'home': 36, 88 | 'left': 37, 89 | 'up': 38, 90 | 'right': 39, 91 | 'down': 40, 92 | 'insert': 45, 93 | 'delete': 46, 94 | 'command': 91, 95 | 'left command': 91, 96 | 'right command': 93, 97 | 'numpad *': 106, 98 | 'numpad +': 107, 99 | 'numpad -': 109, 100 | 'numpad .': 110, 101 | 'numpad /': 111, 102 | 'num lock': 144, 103 | 'scroll lock': 145, 104 | 'my computer': 182, 105 | 'my calculator': 183, 106 | ';': 186, 107 | '=': 187, 108 | ',': 188, 109 | '-': 189, 110 | '.': 190, 111 | '/': 191, 112 | '`': 192, 113 | '[': 219, 114 | '\\': 220, 115 | ']': 221, 116 | "'": 222 117 | }; // Helper aliases 118 | 119 | var aliases = { 120 | 'windows': 91, 121 | '⇧': 16, 122 | '⌥': 18, 123 | '⌃': 17, 124 | '⌘': 91, 125 | 'ctl': 17, 126 | 'control': 17, 127 | 'option': 18, 128 | 'pause': 19, 129 | 'break': 19, 130 | 'caps': 20, 131 | 'return': 13, 132 | 'escape': 27, 133 | 'spc': 32, 134 | 'spacebar': 32, 135 | 'pgup': 33, 136 | 'pgdn': 34, 137 | 'ins': 45, 138 | 'del': 46, 139 | 'cmd': 91 140 | }; 141 | /*! 142 | * Programatically add the following 143 | */ 144 | // lower case chars 145 | 146 | for (i = 97; i < 123; i++) { 147 | codes[String.fromCharCode(i)] = i - 32; 148 | } // numbers 149 | 150 | 151 | for (var i = 48; i < 58; i++) { 152 | codes[i - 48] = i; 153 | } // function keys 154 | 155 | 156 | for (i = 1; i < 13; i++) { 157 | codes['f' + i] = i + 111; 158 | } // numpad keys 159 | 160 | 161 | for (i = 0; i < 10; i++) { 162 | codes['numpad ' + i] = i + 96; 163 | } 164 | /** 165 | * Get by code 166 | * 167 | * exports.name[13] // => 'Enter' 168 | */ 169 | 170 | 171 | var names = {}; // title for backward compat 172 | // Create reverse mapping 173 | 174 | for (i in codes) { 175 | names[codes[i]] = i; 176 | } // Add aliases 177 | 178 | 179 | for (var alias in aliases) { 180 | codes[alias] = aliases[alias]; 181 | } 182 | 183 | document.addEventListener('keyup', function (e) { 184 | // axios({ 185 | // method: 'post', 186 | // url: 'http://localhost:12345', 187 | // data: { 188 | // keyCode: keyCode(e), 189 | // } 190 | // }); 191 | console.log("You pressed", keyCode(e)); 192 | }); 193 | })(); 194 | 195 | console.log(1); 196 | 197 | (function SpyOn() { 198 | var _id = 'spyon-container', 199 | _posBuffer = 3; 200 | 201 | function init() { 202 | document.body.addEventListener('mousemove', glide); 203 | document.body.addEventListener('mouseover', show); 204 | document.body.addEventListener('mouseleave', hide); 205 | } 206 | 207 | function hide(e) { 208 | document.getElementById(_id).style.display = 'none'; 209 | } 210 | 211 | function show(e) { 212 | var spyContainer = document.getElementById(_id); 213 | 214 | if (!spyContainer) { 215 | create(); 216 | return; 217 | } 218 | 219 | if (spyContainer.style.display !== 'block') { 220 | spyContainer.style.display = 'block'; 221 | } 222 | } 223 | 224 | function glide(e) { 225 | var spyContainer = document.getElementById(_id); 226 | 227 | if (!spyContainer) { 228 | create(); 229 | return; 230 | } 231 | 232 | var left = e.clientX + getScrollPos().left + _posBuffer; 233 | 234 | var top = e.clientY + getScrollPos().top + _posBuffer; 235 | 236 | spyContainer.innerHTML = showAttributes(e.target); 237 | 238 | if (left + spyContainer.offsetWidth > window.innerWidth) { 239 | spyContainer.style.left = left - spyContainer.offsetWidth + 'px'; 240 | } else { 241 | spyContainer.style.left = left + 'px'; 242 | } 243 | 244 | spyContainer.style.top = top + 'px'; 245 | } 246 | 247 | function getScrollPos() { 248 | var ieEdge = document.all ? false : true; 249 | 250 | if (!ieEdge) { 251 | return { 252 | left: document.body.scrollLeft, 253 | top: document.body.scrollTop 254 | }; 255 | } else { 256 | return { 257 | left: document.documentElement.scrollLeft, 258 | top: document.documentElement.scrollTop 259 | }; 260 | } 261 | } 262 | 263 | function showAttributes(el) { 264 | var nodeName = "".concat(el.nodeName.toLowerCase(), "
"); 265 | var attrArr = Array.from(el.attributes); 266 | var attributes = attrArr.reduce(function (attrs, attr) { 267 | attrs += "".concat(attr.nodeName, "=\"").concat(attr.nodeValue, "\"
"); 268 | return attrs; 269 | }, ''); 270 | return nodeName + attributes; 271 | } 272 | 273 | function create() { 274 | var div = document.createElement('div'); 275 | div.id = _id; 276 | div.setAttribute('style', "\n position: absolute;\n left: 0;\n top: 0;\n width: auto;\n height: auto;\n padding: 10px;\n box-sizing: border-box;\n color: #fff;\n background-color: #444;\n z-index: 100000;\n font-size: 12px;\n border-radius: 5px;\n line-height: 20px;\n max-width: 45%;\n "); 277 | document.body.appendChild(div); 278 | } 279 | 280 | init(); 281 | })(); -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | (() => { 2 | function keyCode(searchInput) { 3 | // Keyboard Events 4 | if (searchInput && 'object' === typeof searchInput) { 5 | var hasKeyCode = searchInput.which || searchInput.keyCode || searchInput.charCode 6 | if (hasKeyCode) searchInput = hasKeyCode 7 | } 8 | 9 | // Numbers 10 | if ('number' === typeof searchInput) return names[searchInput] 11 | 12 | // Everything else (cast to string) 13 | var search = String(searchInput) 14 | 15 | // check codes 16 | var foundNamedKey = codes[search.toLowerCase()] 17 | if (foundNamedKey) return foundNamedKey 18 | 19 | // check aliases 20 | var foundNamedKey = aliases[search.toLowerCase()] 21 | if (foundNamedKey) return foundNamedKey 22 | 23 | // weird character? 24 | if (search.length === 1) return search.charCodeAt(0) 25 | 26 | return undefined 27 | } 28 | 29 | /** 30 | * Compares a keyboard event with a given keyCode or keyName. 31 | * 32 | * @param {Event} event Keyboard event that should be tested 33 | * @param {Mixed} keyCode {Number} or keyName {String} 34 | * @return {Boolean} 35 | * @api public 36 | */ 37 | keyCode.isEventKey = function isEventKey(event, nameOrCode) { 38 | if (event && 'object' === typeof event) { 39 | var keyCode = event.which || event.keyCode || event.charCode 40 | if (keyCode === null || keyCode === undefined) { return false; } 41 | if (typeof nameOrCode === 'string') { 42 | // check codes 43 | var foundNamedKey = codes[nameOrCode.toLowerCase()] 44 | if (foundNamedKey) { return foundNamedKey === keyCode; } 45 | 46 | // check aliases 47 | var foundNamedKey = aliases[nameOrCode.toLowerCase()] 48 | if (foundNamedKey) { return foundNamedKey === keyCode; } 49 | } else if (typeof nameOrCode === 'number') { 50 | return nameOrCode === keyCode; 51 | } 52 | return false; 53 | } 54 | } 55 | 56 | /** 57 | * Get by name 58 | * 59 | * exports.code['enter'] // => 13 60 | */ 61 | 62 | var codes = { 63 | 'backspace': 8, 64 | 'tab': 9, 65 | 'enter': 13, 66 | 'shift': 16, 67 | 'ctrl': 17, 68 | 'alt': 18, 69 | 'pause/break': 19, 70 | 'caps lock': 20, 71 | 'esc': 27, 72 | 'space': 32, 73 | 'page up': 33, 74 | 'page down': 34, 75 | 'end': 35, 76 | 'home': 36, 77 | 'left': 37, 78 | 'up': 38, 79 | 'right': 39, 80 | 'down': 40, 81 | 'insert': 45, 82 | 'delete': 46, 83 | 'command': 91, 84 | 'left command': 91, 85 | 'right command': 93, 86 | 'numpad *': 106, 87 | 'numpad +': 107, 88 | 'numpad -': 109, 89 | 'numpad .': 110, 90 | 'numpad /': 111, 91 | 'num lock': 144, 92 | 'scroll lock': 145, 93 | 'my computer': 182, 94 | 'my calculator': 183, 95 | ';': 186, 96 | '=': 187, 97 | ',': 188, 98 | '-': 189, 99 | '.': 190, 100 | '/': 191, 101 | '`': 192, 102 | '[': 219, 103 | '\\': 220, 104 | ']': 221, 105 | "'": 222 106 | } 107 | 108 | // Helper aliases 109 | 110 | var aliases = { 111 | 'windows': 91, 112 | '⇧': 16, 113 | '⌥': 18, 114 | '⌃': 17, 115 | '⌘': 91, 116 | 'ctl': 17, 117 | 'control': 17, 118 | 'option': 18, 119 | 'pause': 19, 120 | 'break': 19, 121 | 'caps': 20, 122 | 'return': 13, 123 | 'escape': 27, 124 | 'spc': 32, 125 | 'spacebar': 32, 126 | 'pgup': 33, 127 | 'pgdn': 34, 128 | 'ins': 45, 129 | 'del': 46, 130 | 'cmd': 91 131 | } 132 | 133 | /*! 134 | * Programatically add the following 135 | */ 136 | 137 | // lower case chars 138 | for (i = 97; i < 123; i++) codes[String.fromCharCode(i)] = i - 32 139 | 140 | // numbers 141 | for (var i = 48; i < 58; i++) codes[i - 48] = i 142 | 143 | // function keys 144 | for (i = 1; i < 13; i++) codes['f' + i] = i + 111 145 | 146 | // numpad keys 147 | for (i = 0; i < 10; i++) codes['numpad ' + i] = i + 96 148 | 149 | /** 150 | * Get by code 151 | * 152 | * exports.name[13] // => 'Enter' 153 | */ 154 | 155 | var names = {} // title for backward compat 156 | 157 | // Create reverse mapping 158 | for (i in codes) names[codes[i]] = i 159 | 160 | // Add aliases 161 | for (var alias in aliases) { 162 | codes[alias] = aliases[alias] 163 | } 164 | 165 | document.addEventListener('keyup', function (e) { 166 | // axios({ 167 | // method: 'post', 168 | // url: 'http://localhost:12345', 169 | // data: { 170 | // keyCode: keyCode(e), 171 | // } 172 | // }); 173 | console.log("You pressed", keyCode(e)) 174 | }) 175 | })(); 176 | console.log(1); 177 | (function SpyOn() { 178 | 179 | const _id = 'spyon-container', 180 | _posBuffer = 3; 181 | 182 | function init() { 183 | document.body.addEventListener('mousemove', glide); 184 | document.body.addEventListener('mouseover', show); 185 | document.body.addEventListener('mouseleave', hide); 186 | } 187 | 188 | function hide(e) { 189 | document.getElementById(_id).style.display = 'none'; 190 | } 191 | 192 | function show(e) { 193 | const spyContainer = document.getElementById(_id); 194 | if (!spyContainer) { 195 | create(); 196 | return; 197 | } 198 | if (spyContainer.style.display !== 'block') { 199 | spyContainer.style.display = 'block'; 200 | } 201 | } 202 | 203 | function glide(e) { 204 | const spyContainer = document.getElementById(_id); 205 | if (!spyContainer) { 206 | create(); 207 | return; 208 | } 209 | const left = e.clientX + getScrollPos().left + _posBuffer; 210 | const top = e.clientY + getScrollPos().top + _posBuffer; 211 | spyContainer.innerHTML = showAttributes(e.target); 212 | if (left + spyContainer.offsetWidth > window.innerWidth) { 213 | spyContainer.style.left = left - spyContainer.offsetWidth + 'px'; 214 | } else { 215 | spyContainer.style.left = left + 'px'; 216 | } 217 | spyContainer.style.top = top + 'px'; 218 | } 219 | 220 | function getScrollPos() { 221 | const ieEdge = document.all ? false : true; 222 | if (!ieEdge) { 223 | return { 224 | left: document.body.scrollLeft, 225 | top: document.body.scrollTop 226 | }; 227 | } else { 228 | return { 229 | left: document.documentElement.scrollLeft, 230 | top: document.documentElement.scrollTop 231 | }; 232 | } 233 | } 234 | 235 | function showAttributes(el) { 236 | const nodeName = `${el.nodeName.toLowerCase()}
`; 237 | const attrArr = Array.from(el.attributes); 238 | const attributes = attrArr.reduce((attrs, attr) => { 239 | attrs += `${attr.nodeName}="${attr.nodeValue}"
`; 240 | return attrs; 241 | }, ''); 242 | return nodeName + attributes; 243 | } 244 | 245 | function create() { 246 | const div = document.createElement('div'); 247 | div.id = _id; 248 | div.setAttribute('style', ` 249 | position: absolute; 250 | left: 0; 251 | top: 0; 252 | width: auto; 253 | height: auto; 254 | padding: 10px; 255 | box-sizing: border-box; 256 | color: #fff; 257 | background-color: #444; 258 | z-index: 100000; 259 | font-size: 12px; 260 | border-radius: 5px; 261 | line-height: 20px; 262 | max-width: 45%; 263 | ` 264 | ); 265 | document.body.appendChild(div); 266 | } 267 | init(); 268 | })(); -------------------------------------------------------------------------------- /dist/axios.min.js: -------------------------------------------------------------------------------- 1 | /* axios v0.19.0 | (c) 2019 by Matt Zabriskie */ 2 | !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.axios=t():e.axios=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";function r(e){var t=new i(e),n=s(i.prototype.request,t);return o.extend(n,i.prototype,t),o.extend(n,t),n}var o=n(2),s=n(3),i=n(5),a=n(22),u=n(11),c=r(u);c.Axios=i,c.create=function(e){return r(a(c.defaults,e))},c.Cancel=n(23),c.CancelToken=n(24),c.isCancel=n(10),c.all=function(e){return Promise.all(e)},c.spread=n(25),e.exports=c,e.exports.default=c},function(e,t,n){"use strict";function r(e){return"[object Array]"===j.call(e)}function o(e){return"[object ArrayBuffer]"===j.call(e)}function s(e){return"undefined"!=typeof FormData&&e instanceof FormData}function i(e){var t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer}function a(e){return"string"==typeof e}function u(e){return"number"==typeof e}function c(e){return"undefined"==typeof e}function f(e){return null!==e&&"object"==typeof e}function p(e){return"[object Date]"===j.call(e)}function d(e){return"[object File]"===j.call(e)}function l(e){return"[object Blob]"===j.call(e)}function h(e){return"[object Function]"===j.call(e)}function m(e){return f(e)&&h(e.pipe)}function y(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams}function g(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}function x(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)}function v(e,t){if(null!==e&&"undefined"!=typeof e)if("object"!=typeof e&&(e=[e]),r(e))for(var n=0,o=e.length;n 6 | * @license MIT 7 | */ 8 | e.exports=function(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}},function(e,t,n){"use strict";function r(e){this.defaults=e,this.interceptors={request:new i,response:new i}}var o=n(2),s=n(6),i=n(7),a=n(8),u=n(22);r.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=u(this.defaults,e),e.method=e.method?e.method.toLowerCase():"get";var t=[a,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)n=n.then(t.shift(),t.shift());return n},r.prototype.getUri=function(e){return e=u(this.defaults,e),s(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},o.forEach(["delete","get","head","options"],function(e){r.prototype[e]=function(t,n){return this.request(o.merge(n||{},{method:e,url:t}))}}),o.forEach(["post","put","patch"],function(e){r.prototype[e]=function(t,n,r){return this.request(o.merge(r||{},{method:e,url:t,data:n}))}}),e.exports=r},function(e,t,n){"use strict";function r(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var o=n(2);e.exports=function(e,t,n){if(!t)return e;var s;if(n)s=n(t);else if(o.isURLSearchParams(t))s=t.toString();else{var i=[];o.forEach(t,function(e,t){null!==e&&"undefined"!=typeof e&&(o.isArray(e)?t+="[]":e=[e],o.forEach(e,function(e){o.isDate(e)?e=e.toISOString():o.isObject(e)&&(e=JSON.stringify(e)),i.push(r(t)+"="+r(e))}))}),s=i.join("&")}if(s){var a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}},function(e,t,n){"use strict";function r(){this.handlers=[]}var o=n(2);r.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},r.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},r.prototype.forEach=function(e){o.forEach(this.handlers,function(t){null!==t&&e(t)})},e.exports=r},function(e,t,n){"use strict";function r(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var o=n(2),s=n(9),i=n(10),a=n(11),u=n(20),c=n(21);e.exports=function(e){r(e),e.baseURL&&!u(e.url)&&(e.url=c(e.baseURL,e.url)),e.headers=e.headers||{},e.data=s(e.data,e.headers,e.transformRequest),e.headers=o.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),o.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]});var t=e.adapter||a.adapter;return t(e).then(function(t){return r(e),t.data=s(t.data,t.headers,e.transformResponse),t},function(t){return i(t)||(r(e),t&&t.response&&(t.response.data=s(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)})}},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t,n){return r.forEach(n,function(n){e=n(e,t)}),e}},function(e,t){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,n){"use strict";function r(e,t){!s.isUndefined(e)&&s.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}function o(){var e;return"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process)?e=n(13):"undefined"!=typeof XMLHttpRequest&&(e=n(13)),e}var s=n(2),i=n(12),a={"Content-Type":"application/x-www-form-urlencoded"},u={adapter:o(),transformRequest:[function(e,t){return i(t,"Accept"),i(t,"Content-Type"),s.isFormData(e)||s.isArrayBuffer(e)||s.isBuffer(e)||s.isStream(e)||s.isFile(e)||s.isBlob(e)?e:s.isArrayBufferView(e)?e.buffer:s.isURLSearchParams(e)?(r(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):s.isObject(e)?(r(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};u.headers={common:{Accept:"application/json, text/plain, */*"}},s.forEach(["delete","get","head"],function(e){u.headers[e]={}}),s.forEach(["post","put","patch"],function(e){u.headers[e]=s.merge(a)}),e.exports=u},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t){r.forEach(e,function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])})}},function(e,t,n){"use strict";var r=n(2),o=n(14),s=n(6),i=n(17),a=n(18),u=n(15);e.exports=function(e){return new Promise(function(t,c){var f=e.data,p=e.headers;r.isFormData(f)&&delete p["Content-Type"];var d=new XMLHttpRequest;if(e.auth){var l=e.auth.username||"",h=e.auth.password||"";p.Authorization="Basic "+btoa(l+":"+h)}if(d.open(e.method.toUpperCase(),s(e.url,e.params,e.paramsSerializer),!0),d.timeout=e.timeout,d.onreadystatechange=function(){if(d&&4===d.readyState&&(0!==d.status||d.responseURL&&0===d.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in d?i(d.getAllResponseHeaders()):null,r=e.responseType&&"text"!==e.responseType?d.response:d.responseText,s={data:r,status:d.status,statusText:d.statusText,headers:n,config:e,request:d};o(t,c,s),d=null}},d.onabort=function(){d&&(c(u("Request aborted",e,"ECONNABORTED",d)),d=null)},d.onerror=function(){c(u("Network Error",e,null,d)),d=null},d.ontimeout=function(){c(u("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",d)),d=null},r.isStandardBrowserEnv()){var m=n(19),y=(e.withCredentials||a(e.url))&&e.xsrfCookieName?m.read(e.xsrfCookieName):void 0;y&&(p[e.xsrfHeaderName]=y)}if("setRequestHeader"in d&&r.forEach(p,function(e,t){"undefined"==typeof f&&"content-type"===t.toLowerCase()?delete p[t]:d.setRequestHeader(t,e)}),e.withCredentials&&(d.withCredentials=!0),e.responseType)try{d.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&d.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&d.upload&&d.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){d&&(d.abort(),c(e),d=null)}),void 0===f&&(f=null),d.send(f)})}},function(e,t,n){"use strict";var r=n(15);e.exports=function(e,t,n){var o=n.config.validateStatus;!o||o(n.status)?e(n):t(r("Request failed with status code "+n.status,n.config,null,n.request,n))}},function(e,t,n){"use strict";var r=n(16);e.exports=function(e,t,n,o,s){var i=new Error(e);return r(i,t,n,o,s)}},function(e,t){"use strict";e.exports=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},function(e,t,n){"use strict";var r=n(2),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,s,i={};return e?(r.forEach(e.split("\n"),function(e){if(s=e.indexOf(":"),t=r.trim(e.substr(0,s)).toLowerCase(),n=r.trim(e.substr(s+1)),t){if(i[t]&&o.indexOf(t)>=0)return;"set-cookie"===t?i[t]=(i[t]?i[t]:[]).concat([n]):i[t]=i[t]?i[t]+", "+n:n}}),i):i}},function(e,t,n){"use strict";var r=n(2);e.exports=r.isStandardBrowserEnv()?function(){function e(e){var t=e;return n&&(o.setAttribute("href",t),t=o.href),o.setAttribute("href",t),{href:o.href,protocol:o.protocol?o.protocol.replace(/:$/,""):"",host:o.host,search:o.search?o.search.replace(/^\?/,""):"",hash:o.hash?o.hash.replace(/^#/,""):"",hostname:o.hostname,port:o.port,pathname:"/"===o.pathname.charAt(0)?o.pathname:"/"+o.pathname}}var t,n=/(msie|trident)/i.test(navigator.userAgent),o=document.createElement("a");return t=e(window.location.href),function(n){var o=r.isString(n)?e(n):n;return o.protocol===t.protocol&&o.host===t.host}}():function(){return function(){return!0}}()},function(e,t,n){"use strict";var r=n(2);e.exports=r.isStandardBrowserEnv()?function(){return{write:function(e,t,n,o,s,i){var a=[];a.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(o)&&a.push("path="+o),r.isString(s)&&a.push("domain="+s),i===!0&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(e,t){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t){t=t||{};var n={};return r.forEach(["url","method","params","data"],function(e){"undefined"!=typeof t[e]&&(n[e]=t[e])}),r.forEach(["headers","auth","proxy"],function(o){r.isObject(t[o])?n[o]=r.deepMerge(e[o],t[o]):"undefined"!=typeof t[o]?n[o]=t[o]:r.isObject(e[o])?n[o]=r.deepMerge(e[o]):"undefined"!=typeof e[o]&&(n[o]=e[o])}),r.forEach(["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","maxContentLength","validateStatus","maxRedirects","httpAgent","httpsAgent","cancelToken","socketPath"],function(r){"undefined"!=typeof t[r]?n[r]=t[r]:"undefined"!=typeof e[r]&&(n[r]=e[r])}),n}},function(e,t){"use strict";function n(e){this.message=e}n.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},n.prototype.__CANCEL__=!0,e.exports=n},function(e,t,n){"use strict";function r(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var n=this;e(function(e){n.reason||(n.reason=new o(e),t(n.reason))})}var o=n(23);r.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},r.source=function(){var e,t=new r(function(t){e=t});return{token:t,cancel:e}},e.exports=r},function(e,t){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}}])}); 9 | //# sourceMappingURL=axios.min.map --------------------------------------------------------------------------------