File tree Expand file tree Collapse file tree 3 files changed +12
-24
lines changed Expand file tree Collapse file tree 3 files changed +12
-24
lines changed Original file line number Diff line number Diff line change 28
28
],
29
29
"homepage_url" : " https://github.com/febaoshan/edge-extensions-github-code-viewer" ,
30
30
"permissions" : [
31
- " contextMenus" ,
32
- " declarativeContent"
31
+ " contextMenus"
33
32
],
34
33
"background" : {
35
34
"scripts" : [" src/background.js" ]
Original file line number Diff line number Diff line change 1
- chrome . contextMenus . create ( {
2
- title : 'open with github-code-viewer' ,
3
- contexts : [ 'page' ] ,
4
- onclick : function ( params ) {
5
- const { pageUrl } = params ;
6
- console . log ( 'pageUrl: ' , pageUrl ) ;
7
- chrome . tabs . create ( { url : pageUrl . replace ( / g i t h u b .c o m / , 'github1s.com' ) } ) ;
8
- } ,
9
- documentUrlPatterns : [ 'https://*.github.com/*/*' ]
10
- } ) ;
11
-
12
- chrome . runtime . onInstalled . addListener ( function ( ) {
13
- chrome . declarativeContent . onPageChanged . removeRules ( undefined , function ( ) {
14
- chrome . declarativeContent . onPageChanged . addRules ( [
15
- {
16
- conditions : [
17
- new chrome . declarativeContent . PageStateMatcher ( { pageUrl : { urlContains : 'github.com' } } )
18
- ] ,
19
- actions : [ new chrome . declarativeContent . ShowPageAction ( ) ]
20
- }
21
- ] ) ;
1
+ if ( chrome && chrome . contextMenus ) {
2
+ chrome . contextMenus . create ( {
3
+ title : 'open with github-code-viewer' ,
4
+ contexts : [ 'page' ] ,
5
+ onclick : function ( params ) {
6
+ const { pageUrl = '' } = params ;
7
+
8
+ chrome . tabs . create ( { url : pageUrl . replace ( / g i t h u b .c o m / , 'github1s.com' ) } ) ;
9
+ } ,
10
+ documentUrlPatterns : [ 'https://*.github.com/*/*' ]
22
11
} ) ;
23
- } ) ;
12
+ }
You can’t perform that action at this time.
0 commit comments