File tree Expand file tree Collapse file tree 1 file changed +32
-22
lines changed Expand file tree Collapse file tree 1 file changed +32
-22
lines changed Original file line number Diff line number Diff line change 1
1
import { defineProperty , DDGPromise } from '../utils'
2
2
import ContentFeature from '../content-feature'
3
3
4
+ function injectNavigatorInterface ( args ) {
5
+ try {
6
+ // @ts -expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
7
+ if ( navigator . duckduckgo ) {
8
+ return
9
+ }
10
+ if ( ! args . platform || ! args . platform . name ) {
11
+ return
12
+ }
13
+ defineProperty ( Navigator . prototype , 'duckduckgo' , {
14
+ value : {
15
+ platform : args . platform . name ,
16
+ isDuckDuckGo ( ) {
17
+ return DDGPromise . resolve ( true )
18
+ }
19
+ } ,
20
+ enumerable : true ,
21
+ configurable : false ,
22
+ writable : false
23
+ } )
24
+ } catch {
25
+ // todo: Just ignore this exception?
26
+ }
27
+ }
28
+
4
29
export default class NavigatorInterface extends ContentFeature {
5
- init ( args ) {
6
- try {
7
- // @ts -expect-error https://app.asana.com/0/1201614831475344/1203979574128023/f
8
- if ( navigator . duckduckgo ) {
9
- return
10
- }
11
- if ( ! args . platform || ! args . platform . name ) {
12
- return
13
- }
14
- defineProperty ( Navigator . prototype , 'duckduckgo' , {
15
- value : {
16
- platform : args . platform . name ,
17
- isDuckDuckGo ( ) {
18
- return DDGPromise . resolve ( true )
19
- }
20
- } ,
21
- enumerable : true ,
22
- configurable : false ,
23
- writable : false
24
- } )
25
- } catch {
26
- // todo: Just ignore this exception?
30
+ load ( args ) {
31
+ if ( this . matchDomainFeatureSetting ( 'privilegedDomains' ) . length ) {
32
+ injectNavigatorInterface ( args )
27
33
}
28
34
}
35
+
36
+ init ( args ) {
37
+ injectNavigatorInterface ( args )
38
+ }
29
39
}
You can’t perform that action at this time.
0 commit comments