Many google apis use javascript to work, in authentication they use <meta name="google-signin-client_id" content="api-key">
and javascript le this to authenticate, how do they do for JavaScript to read this?
Many google apis use javascript to work, in authentication they use <meta name="google-signin-client_id" content="api-key">
and javascript le this to authenticate, how do they do for JavaScript to read this?
You can use document.querySelector
to select elements from the DOM / page and extract what you are looking for.
To read the example you indicated you can do this:
var apiKey = document.querySelector('[name="google-signin-client_id"]').getAttribute('content');
console.log(apiKey);
What this code does, step by step:
document.querySelector
- search the page for an element that matches the passed selector, where the name
attribute: _ "google-signin-client_id" _ getAttribute
- fetch this element from the value of the attribute passed to the method