1

Good afternoon.

I try to do a chrome extension that need to access the main vue object on a Vue.js website. To do that, I type let vue=document.getElementById('app').__vue__ in chrome's console, and I can well read its values. In my chrome extension I have a script that contains exactly the same code but vue is undefined. I tried to debug like that.

let app=document.getElementById('app')
let vue=app.__vue__
console.log(app, vue)

the result is 'app=<div...> vue=undefined'. When I right click on app -> store as global variable (its often called temp1), and I do temp1.__vue__ then the result is not undefined and contains the object I was looking for (as if I wrote let vue=document.getElementById('app').__vue__).

Since my skills in web technologies are very bad, I would greatly appreciate a little help in figuring out what is going on and solving this problem. Thanks in advance !

Best

dfsfs
  • 11
  • 1
  • it's more like your extension run before `vue.js` execute. – apple apple Jan 25 '22 at 17:39
  • Hi, thank you for your answer ! Unfortunately it doesn't seems to be that. I tried to wait 30s before accessing the __vue__, nothing changes. Let's try the code below on https://popcat.click : in the console it will show you the vue after 5s, in a chrome extension it will show you undefined after 5s (it is the only code in my extension, i tried with just that) ``` async function f() { function wait(ms) { return new Promise(res => setTimeout(res, 5000)); } await wait(5000).then(x => console.log(document.getElementById('app').__vue__)) } f() ``` – dfsfs Jan 25 '22 at 21:39
  • I cannot access `__vue__` from content script as well, and still didn't find the answer yet. – J.Zhang Nov 18 '22 at 14:21

0 Answers0