getstation / electron-better-web-request Goto Github PK
View Code? Open in Web Editor NEWExtended behaviour for Electron WebRequest : add multiple listeners capabilities.
Extended behaviour for Electron WebRequest : add multiple listeners capabilities.
class BetterWebRequest {
...
hasCallback(method: WebRequestMethod): boolean {
switch (method) {
case 'onBeforeRequest':
case 'onBeforeSendHeaders':
case 'onHeadersReceived':
return true;
default:
return false;
}
}
...
}
prefer
const methodsWithCallback = [
'onBeforeRequest',
'onBeforeSendHeaders',
'onHeadersReceived',
]
class BetterWebRequest {
...
hasCallback(method: WebRequestMethod): boolean {
return methodsWithCallback.includes(method);
}
...
}
Docs: https://www.electronjs.org/docs/latest/api/structures/web-request-filter
webRequest.onBeforeSendHeaders({
types: ['xhr'],
urls: ['file:///*'],
});
types
are ignored.
prefer use js some
From NodeJs v14.17.0 is available in crypto module.
Example:
import { randomUUID: uuid } from 'crypto';
uuid();
Hi,
Not technically an issue but a small question if any of the devs could help.
Do you think we can get the request properties including the post data in the onCompleted event?
Only the response properties seem to be available.
It appears that when for example using multiple onBeforeRequest
events, only the last one gets executed.
webRequest.onBeforeRequest(
{ urls: ['<all_urls>'] },
async (details: Electron.OnBeforeRequestDetails, callback: any) => {
console.log('test1');
callback({ cancel: false });
},
);
webRequest.onBeforeRequest(
{ urls: ['<all_urls>'] },
async (details: Electron.OnBeforeRequestDetails, callback: any) => {
console.log('test2');
callback({ cancel: false });
},
);
Prints: test2
electron-better-web-request/src/store.ts
Line 11 in 62e0d42
electron-better-web-request/src/store.ts
Line 17 in 62e0d42
is
type SessionWithBetterWebRequests = Electron.Session & { webRequest: BetterWebRequest };
const enhanceWebRequest = (session: Electron.Session) => SessionWithBetterWebRequests
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.