Skip to content

Instantly share code, notes, and snippets.

@neodigm
Created February 14, 2021 20:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neodigm/f36c8d50919be0706f72d0728e003334 to your computer and use it in GitHub Desktop.
Save neodigm/f36c8d50919be0706f72d0728e003334 to your computer and use it in GitHub Desktop.
// Scott C. Krause 👁️ neodigm | 2021
// Wait for Vue.js to mount and make VUEX auth token available to the chrome extension.
var _d = document, eScr = _d.createElement("script");
eScr.innerHTML = `
setInterval(() => {
var _d = document;
if( !_d.querySelector("[data-ext-auth]")){
var eV = _d.querySelector( 'DIV#app' );
if( eV?.__vue__?.$store?.state?.auth?.token ){
eV.dataset.extAuth = eV.__vue__.$store.state.auth.token;
}
}
}, 6000);
`;// Content Script | Run at end of doc | once
_d.head.appendChild( eScr );
@neodigm
Copy link
Author

neodigm commented Feb 14, 2021

JavaScript Nullish coalescing operator Chaining

"content_scripts": [ { "matches": [ "https://*/*", "http://*/*" ], "js": ["chrome_extension_vue_auth_token.js"], "run_at": "document_end" } ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment