You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 12, 2020. It is now read-only.
We have been using Brave Ad-Block for our web-browser project for a long time. Recently, we upgraded the Electron version in our web browser application to v3.0.0 and observed that ad-block did not work for Electron v3.0.0. I figured there may be some flaw in our implementation for ad-block in our application and proceeded to check the implementation. This post is for all those who may encounter such issues in the future.
The way we have implemented ad-block is follows:
We get the easylist.txt file from the server.
We serialize it and create a buffer for the easylist.txt during the build.
fs.readFile(bufferPath, (err, buffer) => {
if ( err ) {
fail(err);
}
const adBlockClient = new AdBlockClient();
adBlockClient.deserialize(buffer);
done(adBlockClient);
});
We create an AdblockClient and match the url, the resource type and domain name to the deserialized buffer.
(client as any).matches(url, mapFilterType[details.resourceType], firstPartyUrl.host)
We had some problems in using ad-block in the past with Electron v2.x hence, we forked ad-block and were currently using v3.1.11. The problem being #117.
After the update to Electron v3.x, adblock stopped working. After some careful research, found out that the buffer creation and the serialization worked as usual but the deserialize function didn't. The way I solved it is by adding the code of deserialize from v3.1.11 into the forked v4.1.0 and it worked like a charm.
If you have any better solutions, feel free to tell us.
Thank you.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
We have been using Brave Ad-Block for our web-browser project for a long time. Recently, we upgraded the Electron version in our web browser application to
v3.0.0
and observed that ad-block did not work for Electronv3.0.0
. I figured there may be some flaw in our implementation for ad-block in our application and proceeded to check the implementation. This post is for all those who may encounter such issues in the future.The way we have implemented ad-block is follows:
We had some problems in using ad-block in the past with Electron
v2.x
hence, we forked ad-block and were currently usingv3.1.11
. The problem being #117.After the update to Electron
v3.x
, adblock stopped working. After some careful research, found out that the buffer creation and the serialization worked as usual but thedeserialize
function didn't. The way I solved it is by adding the code ofdeserialize
fromv3.1.11
into the forkedv4.1.0
and it worked like a charm.If you have any better solutions, feel free to tell us.
Thank you.
The text was updated successfully, but these errors were encountered: