Browse Source

event for logout

feature/oauth
Phillip Lang Martinez 2 months ago
parent
commit
aaf6a68dc7
  1. 12
      public/content-script.js
  2. 6
      src/background.ts

12
public/content-script.js

@ -180,3 +180,15 @@ document.addEventListener('qortalExtensionRequests', async (event) => {
}
// Handle other request types as needed...
});
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
console.log({message})
if (message.type === "LOGOUT") {
// Notify the web page
window.postMessage({
type: "LOGOUT",
from: 'qortal'
}, "*");
}
});

6
src/background.ts

@ -811,6 +811,12 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
// Handle error
console.error(chrome.runtime.lastError.message);
} else {
chrome.tabs.query({}, function(tabs) {
tabs.forEach(tab => {
console.log({tab})
chrome.tabs.sendMessage(tab.id, { type: "LOGOUT" });
});
});
// Data removed successfully
sendResponse(true);
}

Loading…
Cancel
Save