GetScatter / ScatterWebExtension

Extension that allows you to sign transactions with your private keys securely from within the browser without ever exposing them.
MIT License
366 stars 127 forks source link

How to detect the presence of Scatter on page load? #145

Closed acoutts closed 6 years ago

acoutts commented 6 years ago

I can always check the window.scatter reference after a timeout, but is there a more reliable way to check if Scatter is installed?

str commented 6 years ago
document.addEventListener('scatterLoaded', scatterExtension => {
    const scatter = window.scatter;
    window.scatter = null;
    callYourCallback(scatter);
 });
acoutts commented 6 years ago

I do that but won't that CB only execute if the scatterLoaded event fires?

What I'm looking for is a way to detect when that doesn't work, perhaps the timeout I'm using is the best option but I wanted to see what else was available.

nsjames commented 6 years ago

Yup, only a timeout. Scatter can't tell you that it doesn't exist.