mirror of
https://github.com/zen-browser/components.git
synced 2025-07-08 05:39:57 +02:00
47 lines
967 B
TypeScript
47 lines
967 B
TypeScript
var gZenOperatingSystemCommonUtils = {
|
|
kZenOSToSmallName: {
|
|
WINNT: 'windows',
|
|
Darwin: 'macos',
|
|
Linux: 'linux',
|
|
},
|
|
|
|
get currentOperatingSystem() {
|
|
let os = Services.appinfo.OS;
|
|
return this.kZenOSToSmallName[os];
|
|
},
|
|
};
|
|
|
|
class ZenMultiWindowFeature {
|
|
constructor() {}
|
|
|
|
static get browsers() {
|
|
return Services.wm.getEnumerator('navigator:browser');
|
|
}
|
|
|
|
static get currentBrowser() {
|
|
return Services.wm.getMostRecentWindow('navigator:browser');
|
|
}
|
|
|
|
isActiveWindow() {
|
|
return ZenMultiWindowFeature.currentBrowser === window;
|
|
}
|
|
|
|
async foreachWindowAsActive(callback) {
|
|
if (!this.isActiveWindow()) {
|
|
return;
|
|
}
|
|
for (const browser of ZenMultiWindowFeature.browsers) {
|
|
try {
|
|
await callback(browser);
|
|
} catch (e) {
|
|
console.error(e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
class ZenDOMOperatedFeature {
|
|
constructor() {
|
|
window.addEventListener('DOMContentLoaded', this.init.bind(this));
|
|
}
|
|
}
|