mirror of
https://github.com/lil-org/tokenary.git
synced 2024-11-26 04:04:20 +03:00
extension sanity checks
This commit is contained in:
parent
35f525ca0b
commit
710a7544ae
@ -107,6 +107,7 @@ window.addEventListener("message", event => {
|
||||
browser.runtime.sendMessage(disconnectRequest);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
function getFavicon() {
|
||||
|
@ -136,6 +136,7 @@ browser.action.onClicked.addListener(tab => {
|
||||
if (tab.url == "" && tab.pendingUrl == "") {
|
||||
justShowApp();
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
function genId() {
|
||||
@ -260,7 +261,7 @@ function hasVisiblePopup() {
|
||||
|
||||
function storePopupRequest(popupRequest) {
|
||||
getPopupsQueue().then(result => {
|
||||
if (Array.isArray(result)) {
|
||||
if (typeof result !== "undefined", Array.isArray(result)) {
|
||||
result.push(popupRequest);
|
||||
setPopupsQueue(result);
|
||||
} else {
|
||||
@ -272,7 +273,7 @@ function storePopupRequest(popupRequest) {
|
||||
function getNextStoredPopup() {
|
||||
return new Promise((resolve) => {
|
||||
getPopupsQueue().then(result => {
|
||||
if (Array.isArray(result) && result.length > 0) {
|
||||
if (typeof result !== "undefined", Array.isArray(result) && result.length > 0) {
|
||||
resolve(result[0]);
|
||||
} else {
|
||||
resolve();
|
||||
@ -299,7 +300,7 @@ function storeCurrentPopupId(id) {
|
||||
|
||||
function cleanupStoredPopup(id) {
|
||||
getPopupsQueue().then(result => {
|
||||
if (Array.isArray(result) && result.length > 0 && result[0].id == id) {
|
||||
if (typeof result !== "undefined", Array.isArray(result) && result.length > 0 && result[0].id == id) {
|
||||
result.shift();
|
||||
setPopupsQueue(result);
|
||||
browser.storage.session.remove("currentPopupId");
|
||||
@ -323,7 +324,7 @@ function setPopupsQueue(queue) {
|
||||
|
||||
function cleanupPopupsQueue() {
|
||||
getPopupsQueue().then(result => {
|
||||
if (Array.isArray(result) && result.length > 0) {
|
||||
if (typeof result !== "undefined", Array.isArray(result) && result.length > 0) {
|
||||
for (var i = 0; i < result.length; i++) {
|
||||
cancelPopupRequest(result[i]);
|
||||
}
|
||||
|
@ -4,11 +4,12 @@ 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) => {
|
||||
browser.runtime.sendMessage(request).then(response => {
|
||||
sendToInpage(response, id);
|
||||
});
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
document.addEventListener('visibilitychange', didChangeVisibility);
|
||||
|
@ -24,6 +24,7 @@ button.addEventListener('click', () => {
|
||||
});
|
||||
browser.runtime.sendMessage({subject: 'POPUP_DID_PROCEED', id: message.id});
|
||||
setTimeout(window.close, 437);
|
||||
return true;
|
||||
});
|
||||
|
||||
function setupButton() {
|
||||
|
Loading…
Reference in New Issue
Block a user