File tree 4 files changed +38
-13
lines changed
4 files changed +38
-13
lines changed Original file line number Diff line number Diff line change 35
35
"build" : " yarn run clean && build --win --mac --linux" ,
36
36
"build:mac" : " yarn run clean && build --mac" ,
37
37
"build:win" : " yarn run clean && build --win" ,
38
- "plugins" : " yarn run plugin:autoconfirm" ,
38
+ "plugins" : " yarn run plugin:adblocker && yarn run plugin:autoconfirm" ,
39
+ "plugin:adblocker" : " rimraf plugins/adblocker/ad-blocker-engine.bin && node plugins/adblocker/blocker.js" ,
39
40
"plugin:autoconfirm" : " yarn run generate:package YoutubeNonStop" ,
40
41
"release:linux" : " yarn run clean && build --linux -p always" ,
41
42
"release:mac" : " yarn run clean && build --mac -p always" ,
Original file line number Diff line number Diff line change
1
+ /ad-blocker-engine.bin
Original file line number Diff line number Diff line change 1
- const { ElectronBlocker } = require ( "@cliqz/adblocker-electron" ) ;
2
- const { session } = require ( "electron" ) ;
3
- const fetch = require ( "node-fetch" ) ;
4
-
5
- const SOURCES = [
6
- "https://raw.githubusercontent.com/kbinani/adblock-youtube-ads/master/signed.txt"
7
- ] ;
8
-
9
- module . exports = ( ) =>
10
- ElectronBlocker . fromLists ( fetch , SOURCES )
11
- . then ( blocker => blocker . enableBlockingInSession ( session . defaultSession ) )
12
- . catch ( err => console . log ( "Error loading adBlocker" , err ) ) ;
1
+ const { loadAdBlockerEngine } = require ( "./blocker" ) ;
2
+ module . exports = ( ) => loadAdBlockerEngine ( true ) ;
Original file line number Diff line number Diff line change
1
+ const { promises } = require ( "fs" ) ; // used for caching
2
+ const path = require ( "path" ) ;
3
+
4
+ const { ElectronBlocker } = require ( "@cliqz/adblocker-electron" ) ;
5
+ const { session } = require ( "electron" ) ;
6
+ const fetch = require ( "node-fetch" ) ;
7
+
8
+ const SOURCES = [
9
+ "https://raw.githubusercontent.com/kbinani/adblock-youtube-ads/master/signed.txt"
10
+ ] ;
11
+
12
+ const loadAdBlockerEngine = ( enableBlocking = false ) =>
13
+ ElectronBlocker . fromLists (
14
+ fetch ,
15
+ SOURCES ,
16
+ { } ,
17
+ {
18
+ path : path . resolve ( __dirname , "ad-blocker-engine.bin" ) ,
19
+ read : promises . readFile ,
20
+ write : promises . writeFile
21
+ }
22
+ )
23
+ . then ( blocker => {
24
+ if ( enableBlocking ) {
25
+ blocker . enableBlockingInSession ( session . defaultSession ) ;
26
+ }
27
+ } )
28
+ . catch ( err => console . log ( "Error loading adBlocker engine" , err ) ) ;
29
+
30
+ module . exports = { loadAdBlockerEngine } ;
31
+ if ( require . main === module ) {
32
+ loadAdBlockerEngine ( false ) ; // Generate the engine without enabling it
33
+ }
You can’t perform that action at this time.
0 commit comments