Feat : open link on current firefox session
All checks were successful
release / build (push) Successful in 44s
release / verify-windows (push) Successful in 1m19s

This commit is contained in:
jeanotx32
2026-08-12 00:40:20 +02:00
parent 55bb55ae55
commit 6ad8429cf1
6 changed files with 176 additions and 22 deletions

View File

@@ -75,6 +75,37 @@ export async function openUrl(
});
}
/**
* Décharge le lecteur en confiant une page vide à la fenêtre existante.
*
* La fenêtre survit — donc la source OBS aussi — et le flux cesse d'être décodé.
* `about:blank` n'est pas une URL fournie par l'utilisateur : elle contourne
* légitimement le filtre http/https appliqué aux liens de streamers.
*/
export async function blankPage(
settings: BrowserSettings,
log: BrowserLog,
): Promise<{ command: string; url: string }> {
const args = [...settings.args, 'about:blank'];
log('info', 'Lecteur déchargé (page vide) — fenêtre conservée pour OBS', 'browser.closed');
const child = spawn(settings.command, args, {
detached: true,
stdio: 'ignore',
env: { ...x11Env(), MOZ_ENABLE_WAYLAND: '0' },
});
return new Promise((resolve, reject) => {
child.once('error', (err: NodeJS.ErrnoException) =>
reject(new Error(`Chargement de la page vide impossible : ${err.message}`)),
);
setTimeout(() => {
child.unref();
resolve({ command: settings.command, url: 'about:blank' });
}, 400);
});
}
/** Ferme la fenêtre du lecteur, sans toucher au reste de la session. */
export async function closeWindow(
windowMatch: string,

View File

@@ -31,7 +31,7 @@ import { runDiagnostics } from './doctor.ts';
import { ObsController } from './obs.ts';
import { StreamWatcher } from './watcher.ts';
import { currentBuildId, runningBundlePath, selfUpdate } from './updater.ts';
import { closeWindow, delay as sleep, openUrl } from './browser.ts';
import { blankPage, closeWindow, delay as sleep, openUrl } from './browser.ts';
import { sendHotkey } from './hotkey.ts';
import { cpuUsagePercent, diskUsage, memoryUsage } from './system.ts';
@@ -267,14 +267,19 @@ async function startCapture(params: Record<string, unknown>): Promise<unknown> {
async function stopCapture(): Promise<unknown> {
const result = await obs.execute('record.stop');
// Fermer la fenêtre détruit la source « capture de fenêtre » d'OBS, qu'il faut
// ensuite repointer à la main. D'où le défaut « page vide », qui décharge le
// lecteur sans faire disparaître la fenêtre.
let closed: unknown = 'conservée';
if (browserSettings.enabled && browserSettings.closeOnStop) {
closed = await closeWindow(watcher.snapshotSettings.fullscreen.windowMatch, report).catch(
(err: Error) => {
report('warn', `Fermeture de la fenêtre impossible : ${err.message}`, 'command.failed');
return `échec : ${err.message}`;
},
);
if (browserSettings.enabled && browserSettings.onStop !== 'keep') {
const action =
browserSettings.onStop === 'close'
? closeWindow(watcher.snapshotSettings.fullscreen.windowMatch, report)
: blankPage(browserSettings, report);
closed = await action.catch((err: Error) => {
report('warn', `Libération de la fenêtre impossible : ${err.message}`, 'command.failed');
return `échec : ${err.message}`;
});
}
report('info', 'Capture arrêtée', 'capture.stopped');