forked from joseph/notebooklm-api
Compare commits
1 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
b7e7ab2b45 |
2
.env
2
.env
|
|
@ -1,4 +1,4 @@
|
||||||
PORT=3456
|
PORT=3456
|
||||||
HEADLESS=false
|
HEADLESS=true
|
||||||
# CHROME_PATH=/Applications/Google Chrome.app/Contents/MacOS/Google Chrome
|
# CHROME_PATH=/Applications/Google Chrome.app/Contents/MacOS/Google Chrome
|
||||||
API_KEY=
|
API_KEY=
|
||||||
|
|
|
||||||
|
|
@ -40,14 +40,21 @@ class BrowserManager {
|
||||||
console.log(`[${this._tag}] Sử dụng: ${chromePath || 'bundled Chromium'}`);
|
console.log(`[${this._tag}] Sử dụng: ${chromePath || 'bundled Chromium'}`);
|
||||||
console.log(`[${this._tag}] Profile : ${this.profileDir}`);
|
console.log(`[${this._tag}] Profile : ${this.profileDir}`);
|
||||||
|
|
||||||
|
const isHeadless = process.env.HEADLESS === 'true';
|
||||||
|
// NotebookLM ẩn cột Sources khi cửa sổ quá hẹp — cần viewport rộng
|
||||||
|
const WIN_W = parseInt(process.env.WINDOW_WIDTH || '1920', 10);
|
||||||
|
const WIN_H = parseInt(process.env.WINDOW_HEIGHT || '1080', 10);
|
||||||
|
|
||||||
const opts = {
|
const opts = {
|
||||||
headless: process.env.HEADLESS === 'true',
|
headless: isHeadless,
|
||||||
userDataDir: this.profileDir,
|
userDataDir: this.profileDir,
|
||||||
defaultViewport: null,
|
// headless=true: --start-maximized không có tác dụng, phải set viewport tường minh
|
||||||
|
defaultViewport: isHeadless ? { width: WIN_W, height: WIN_H } : null,
|
||||||
args: [
|
args: [
|
||||||
'--no-sandbox',
|
'--no-sandbox',
|
||||||
'--disable-setuid-sandbox',
|
'--disable-setuid-sandbox',
|
||||||
'--disable-infobars',
|
'--disable-infobars',
|
||||||
|
`--window-size=${WIN_W},${WIN_H}`,
|
||||||
'--start-maximized',
|
'--start-maximized',
|
||||||
'--no-default-browser-check',
|
'--no-default-browser-check',
|
||||||
'--no-first-run',
|
'--no-first-run',
|
||||||
|
|
@ -76,6 +83,11 @@ class BrowserManager {
|
||||||
this.page = null;
|
this.page = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Đảm bảo viewport đủ rộng (headless không auto-maximize)
|
||||||
|
if (isHeadless) {
|
||||||
|
await this.page.setViewport({ width: WIN_W, height: WIN_H });
|
||||||
|
}
|
||||||
|
|
||||||
// macOS: kéo cửa sổ lên trước (chỉ slot 0)
|
// macOS: kéo cửa sổ lên trước (chỉ slot 0)
|
||||||
if (process.platform === 'darwin' && this.slotIndex === 0) {
|
if (process.platform === 'darwin' && this.slotIndex === 0) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue