mirror of
https://github.com/zen-browser/components.git
synced 2025-07-08 14:49:57 +02:00
Synced workspaces across windows and also implemented MultiWindowFeatures
This commit is contained in:
parent
fbe5727705
commit
2ea7024eea
5 changed files with 273 additions and 244 deletions
42
src/ZenCommonUtils.mjs
Normal file
42
src/ZenCommonUtils.mjs
Normal file
|
@ -0,0 +1,42 @@
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue