Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.webContents.addListener('did-start-navigation', (...args: any[]) => {
this.updateNavigationState();
const url = this.webContents.getURL();
const { styles, scripts } = engine.getCosmeticsFilters({
url,
...parse(url),
});
this.webContents.insertCSS(styles);
for (const script of scripts) {
this.webContents.executeJavaScript(script);
}
// appWindow.webContents.send(`load-commit-${this.tabId}`, ...args);
this.emitWebNavigationEvent('onBeforeNavigate', {
tabId: this.tabId,
url: this.webContents.getURL(),
frameId: 0,
timeStamp: Date.now(),
processId: process.pid,
export function processRawRequest(request: IRawRequest) {
// Extract hostname
const url = request.url.toLowerCase();
const { host, domain } = parse(url);
// Process source url
let sourceUrl = request.sourceUrl;
let sourceHostname = '';
let sourceDomain = '';
if (sourceUrl) {
// It can happen when source is not a valid URL, then we simply
// leave `sourceHostname` and `sourceGD` as empty strings to allow
// some filter matching on the request URL itself.
sourceUrl = sourceUrl.toLowerCase();
const sourceUrlParts = parse(sourceUrl);
sourceHostname = sourceUrlParts.host || '';
sourceDomain = sourceUrlParts.domain || '';
}
export function processRawRequest(request: IRawRequest) {
// Extract hostname
const url = request.url.toLowerCase();
const { host, domain } = parse(url);
// Process source url
let sourceUrl = request.sourceUrl;
let sourceHostname = '';
let sourceDomain = '';
if (sourceUrl) {
// It can happen when source is not a valid URL, then we simply
// leave `sourceHostname` and `sourceGD` as empty strings to allow
// some filter matching on the request URL itself.
sourceUrl = sourceUrl.toLowerCase();
const sourceUrlParts = parse(sourceUrl);
sourceHostname = sourceUrlParts.host || '';
sourceDomain = sourceUrlParts.domain || '';
}
// Wrap informations needed to match the request
return mkRequest({
cpt: request.cpt,
// SourceUrl
sourceDomain,
sourceHostname,
// Url
domain: domain || '',
hostname: host || '',
url,
const parseCookies = (url, str) => {
const domain = `.${getDomain(url)}`
return str.split(';').reduce((acc, str) => {
const [name, value] = str.split('=')
const cookie = {
name: name.trim(),
value,
domain,
url,
path: '/'
}
return [...acc, cookie]
}, [])
}
({ url, sourceUrl }) => ((getHostname(url || '') || '').length + (getHostname(sourceUrl || '') || '').length) > 0,
requests,