Change: report updatable after the install button is prepared
This commit is contained in:
parent
a194f7eb26
commit
8cec0e7a65
|
@ -93,9 +93,26 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function prepareInstallButton() {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
const observer = new MutationObserver(check);
|
||||||
|
observer.observe(document.documentElement, {
|
||||||
|
childList: true,
|
||||||
|
subtree: true
|
||||||
|
});
|
||||||
|
check();
|
||||||
|
|
||||||
|
function check() {
|
||||||
|
if (document.querySelector('#install_style_button')) {
|
||||||
|
resolve();
|
||||||
|
observer.disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function reportUpdatable(isUpdatable) {
|
function reportUpdatable(isUpdatable) {
|
||||||
// USO doesn't bind these listeners immediately
|
prepareInstallButton().then(() => {
|
||||||
setTimeout(() => {
|
|
||||||
sendEvent({
|
sendEvent({
|
||||||
type: isUpdatable
|
type: isUpdatable
|
||||||
? 'styleCanBeUpdatedChrome'
|
? 'styleCanBeUpdatedChrome'
|
||||||
|
@ -104,7 +121,7 @@
|
||||||
updateUrl: installedStyle.updateUrl
|
updateUrl: installedStyle.updateUrl
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}, 300);
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user