mirror of
https://github.com/lil-org/tokenary.git
synced 2024-11-26 04:04:20 +03:00
move visibility listener to shared content script
This commit is contained in:
parent
90735d7e6e
commit
d7c7e3c745
@ -131,3 +131,17 @@ function getFavicon() {
|
||||
function genId() {
|
||||
return new Date().getTime() + Math.floor(Math.random() * 1000);
|
||||
}
|
||||
|
||||
function didChangeVisibility() {
|
||||
if (document.pendingRequestsIds.size != 0 && document.visibilityState === 'visible') {
|
||||
document.pendingRequestsIds.forEach(id => {
|
||||
const request = {id: id, subject: "getResponse", host: window.location.host};
|
||||
browser.runtime.sendMessage(request).then(response => {
|
||||
sendToInpage(response, id);
|
||||
});
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
document.addEventListener('visibilitychange', didChangeVisibility);
|
||||
|
@ -1,15 +1 @@
|
||||
// Copyright © 2022 Tokenary. All rights reserved.
|
||||
|
||||
function didChangeVisibility() {
|
||||
if (document.visibilityState === 'visible' && document.pendingRequestsIds.size != 0) {
|
||||
document.pendingRequestsIds.forEach(id => {
|
||||
const request = {id: id, subject: "getResponse", host: window.location.host};
|
||||
browser.runtime.sendMessage(request).then(response => {
|
||||
sendToInpage(response, id);
|
||||
});
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
document.addEventListener('visibilitychange', didChangeVisibility);
|
||||
|
Loading…
Reference in New Issue
Block a user