Updated UI style to be more modern
Updated headless browser to get images, videos and gifs!
This commit is contained in:
@@ -6,14 +6,15 @@ class HeadlessBrowser {
|
||||
|
||||
const win = new BrowserWindow({
|
||||
show: false,
|
||||
width: 800,
|
||||
height: 600,
|
||||
width: 1920,
|
||||
height: 1080,
|
||||
webPreferences: {
|
||||
offscreen: true,
|
||||
contextIsolation: false,
|
||||
nodeIntegration: false,
|
||||
images: true,
|
||||
images: false,
|
||||
webgl: false,
|
||||
backgroundThrottling: false,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -21,6 +22,26 @@ class HeadlessBrowser {
|
||||
const userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36';
|
||||
win.webContents.setUserAgent(userAgent);
|
||||
|
||||
const session = win.webContents.session;
|
||||
const filter = { urls: ['*://*/*'] };
|
||||
|
||||
session.webRequest.onBeforeRequest(filter, (details, callback) => {
|
||||
const url = details.url.toLowerCase();
|
||||
|
||||
const blockExtensions = [
|
||||
'.css', '.woff', '.woff2', '.ttf', '.svg', '.eot',
|
||||
'google-analytics', 'doubleclick', 'facebook', 'twitter', 'adsystem'
|
||||
];
|
||||
|
||||
const isBlocked = blockExtensions.some(ext => url.includes(ext));
|
||||
|
||||
if (isBlocked) {
|
||||
return callback({ cancel: true });
|
||||
}
|
||||
|
||||
return callback({ cancel: false });
|
||||
});
|
||||
|
||||
await win.loadURL(url, { userAgent });
|
||||
|
||||
if (waitSelector) {
|
||||
@@ -53,8 +74,7 @@ class HeadlessBrowser {
|
||||
clearTimeout(timer);
|
||||
resolve(true);
|
||||
} else {
|
||||
// FIX: Use setTimeout because requestAnimationFrame stops in hidden windows
|
||||
setTimeout(check, 100);
|
||||
setTimeout(check, 50);
|
||||
}
|
||||
};
|
||||
check();
|
||||
|
||||
Reference in New Issue
Block a user