Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async (details: Electron.OnBeforeRequestListenerDetails, callback: any) => {
const tabId = getTabByWebContentsId(window, details.webContentsId);
if (engine) {
const { match, redirect } = engine.match(
makeRequest({ type: details.resourceType, url: details.url }, parse),
);
if (match || redirect) {
// if(file.get("adblockEnabled") == true) {
appWindow.webContents.send(`blocked-ad-${tabId}`);
if (redirect) {
callback({ redirectURL: redirect });
} else {
callback({ cancel: true });
}
return;
// }
}
async (details: Electron.OnBeforeRequestDetails, callback: any) => {
const tabId = getTabByWebContentsId(window, details.webContentsId);
if (engine && settings.isShieldToggled) {
const { match, redirect } = engine.match(
makeRequest({ type: details.resourceType, url: details.url }, parse),
);
if (match || redirect) {
appWindow.webContents.send(`blocked-ad-${tabId}`);
if (redirect) {
callback({ redirectURL: redirect });
} else {
callback({ cancel: true });
}
return;
}
}
await onBeforeRequest(details, callback);
async (details: Electron.OnHeadersReceivedDetails, callback: any) => {
updateResponseHeadersWithCSP(
{
url: details.url,
type: details.resourceType as any,
tabId: getTabByWebContentsId(window, details.webContentsId),
method: details.method,
statusCode: details.statusCode,
statusLine: details.statusLine,
requestId: details.id.toString(),
frameId: 0,
parentFrameId: -1,
timeStamp: details.timestamp,
},
engine.getCSPDirectives(
makeRequest(
{
sourceUrl: details.url,
type: details.resourceType,
url: details.url,
},
parse,
),
),
),
await onHeadersReceived(details, callback);
},
);
async (details: Electron.OnHeadersReceivedListenerDetails, callback: any) => {
updateResponseHeadersWithCSP(
{
url: details.url,
type: details.resourceType as any,
tabId: getTabByWebContentsId(window, details.webContentsId),
method: details.method,
statusCode: details.statusCode,
statusLine: details.statusLine,
requestId: details.id.toString(),
frameId: 0,
parentFrameId: -1,
timeStamp: details.timestamp,
},
engine.getCSPDirectives(
makeRequest(
{
sourceUrl: details.url,
type: details.resourceType,
url: details.url,
},
parse,
),
),
),
await onHeadersReceived(details, callback);
},
);