├── .gitignore ├── 1.png ├── README.md └── app.js /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea/ 2 | -------------------------------------------------------------------------------- /1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/phith0n/vueinfo/bbba869e2e4f0d0606c77766abcabb8f448fa2ae/1.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VUEInfo 2 | 3 | Extract info from Vue based website. 4 | 5 | Paste the [app.js](app.js) into browser console directly: 6 | 7 | ![](1.png) 8 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | function findVueRoot(root) { 2 | const queue = [root]; 3 | while (queue.length > 0) { 4 | const currentNode = queue.shift(); 5 | 6 | if (currentNode.__vue__ || currentNode.__vue_app__ || currentNode._vnode) { 7 | console.log("vue detected on root element:", currentNode); 8 | return currentNode 9 | } 10 | 11 | for (let i = 0; i < currentNode.childNodes.length; i++) { 12 | queue.push(currentNode.childNodes[i]); 13 | } 14 | } 15 | 16 | return null; 17 | } 18 | 19 | function findVueRouter(vueRoot) { 20 | let router; 21 | 22 | try { 23 | if (vueRoot.__vue_app__) { 24 | router = vueRoot.__vue_app__.config.globalProperties.$router.options.routes 25 | console.log("find router in Vue object", vueRoot.__vue_app__) 26 | } else if (vueRoot.__vue__) { 27 | router = vueRoot.__vue__.$root.$options.router.options.routes 28 | console.log("find router in Vue object", vueRoot.__vue__) 29 | } 30 | } catch (e) {} 31 | 32 | try { 33 | if (vueRoot.__vue__ && !router) { 34 | router = vueRoot.__vue__._router.options.routes 35 | console.log("find router in Vue object", vueRoot.__vue__) 36 | } 37 | } catch (e) {} 38 | 39 | return router 40 | } 41 | 42 | function walkRouter(rootNode, callback) { 43 | const stack = [{node: rootNode, path: ''}]; 44 | 45 | while (stack.length) { 46 | const { node, path} = stack.pop(); 47 | 48 | if (node && typeof node === 'object') { 49 | if (Array.isArray(node)) { 50 | for (const key in node) { 51 | stack.push({node: node[key], path: mergePath(path, node[key].path)}) 52 | } 53 | } else if (node.hasOwnProperty("children")) { 54 | stack.push({node: node.children, path: path}); 55 | } 56 | } 57 | 58 | callback(path, node); 59 | } 60 | } 61 | 62 | function mergePath(parent, path) { 63 | if (path.indexOf(parent) === 0) { 64 | return path 65 | } 66 | 67 | return (parent ? parent + '/' : '') + path 68 | } 69 | 70 | function main() { 71 | const vueRoot = findVueRoot(document.body); 72 | if (!vueRoot) { 73 | console.error("This website is not developed by Vue") 74 | return 75 | } 76 | 77 | let vueVersion; 78 | if (vueRoot.__vue__) { 79 | vueVersion = vueRoot.__vue__.$options._base.version; 80 | } else { 81 | vueVersion = vueRoot.__vue_app__.version; 82 | } 83 | 84 | console.log("Vue version is ", vueVersion) 85 | const routers = []; 86 | 87 | const vueRouter = findVueRouter(vueRoot) 88 | if (!vueRouter) { 89 | console.error("No Vue-Router detected") 90 | return 91 | } 92 | 93 | console.log(vueRouter) 94 | walkRouter(vueRouter, function (path, node) { 95 | if (node.path) { 96 | routers.push({name: node.name, path}) 97 | } 98 | }) 99 | 100 | return routers 101 | } 102 | 103 | console.table(main()) 104 | --------------------------------------------------------------------------------