15 lines
339 B
TypeScript
15 lines
339 B
TypeScript
export { isWindowAlive, getFocusedWindow };
|
|
|
|
function isWindowAlive(win?: Window) {
|
|
return win && !Components.utils.isDeadWrapper(win) && !win.closed;
|
|
}
|
|
|
|
function getFocusedWindow() {
|
|
const wins = Services.wm.getEnumerator(null) as Window[];
|
|
for (const win of wins) {
|
|
if (win.document.hasFocus()) {
|
|
return win;
|
|
}
|
|
}
|
|
}
|