Проверка состояния
Данный метод позволяет определить, установлено ли расширение у пользователя, введен ли ключ и на каком сайте посредника
function checkExtension(e) {
// отлавливаем все сообщения на странице и фильтруем, нас интересуют только сообщения от api.waix.ru
if (e.origin.indexOf('api.waix.ru') < 0)
return;
if (e.data.key) { // false or true
// key entered or not
}
if (e.data.user) {
// user is active or not
}
if (location.host != e.data.domain) {
// the Google Extension is being used by another company
}
if (!e.data.key || !e.data.user) {
// the Google Extension installed but not used
}
}
window.addEventListener("message", checkExtension, false);Last updated