1
-
2
1
importScripts ( 'utilities.js' ) ;
3
2
importScripts ( 'functions.js' ) ;
4
3
@@ -11,7 +10,7 @@ chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
11
10
// updateIcon(tabId);
12
11
} ) ;
13
12
14
- function updateIcon ( tabId ) {
13
+ async function updateIcon ( tabId ) {
15
14
chrome . tabs . get ( tabId , function ( change ) {
16
15
17
16
chrome . tabs . get ( tabId , function ( tab ) {
@@ -35,4 +34,82 @@ function updateIcon(tabId) {
35
34
} ) ;
36
35
} ) ;
37
36
} ) ;
38
- } ;
37
+ } ;
38
+
39
+ async function removeAllContextMenus ( ) {
40
+ return new Promise ( ( resolve ) => {
41
+ chrome . contextMenus . removeAll ( ( ) => {
42
+ resolve ( ) ;
43
+ } ) ;
44
+ } ) ;
45
+ }
46
+
47
+ async function createActionContextMenus ( ) {
48
+ await removeAllContextMenus ( ) ;
49
+
50
+ chrome . contextMenus . create ( {
51
+ id : "support" ,
52
+ title : "❤️ Support" ,
53
+ contexts : [ "action" ]
54
+ } ) ;
55
+
56
+ chrome . contextMenus . create ( {
57
+ id : "issues" ,
58
+ title : "🤔 Issues and Suggestions" ,
59
+ contexts : [ "action" ]
60
+ } ) ;
61
+
62
+ chrome . contextMenus . create ( {
63
+ id : "github" ,
64
+ title : "🌐 GitHub" ,
65
+ parentId : "issues" ,
66
+ contexts : [ "action" ]
67
+ } ) ;
68
+
69
+ chrome . contextMenus . create ( {
70
+ id : "reportIssue" ,
71
+ title : "🐛 Report Issue" ,
72
+ parentId : "issues" ,
73
+ contexts : [ "action" ]
74
+ } ) ;
75
+
76
+ // Sous-menus de "Support"
77
+ chrome . contextMenus . create ( {
78
+ id : "donate" ,
79
+ title : "🍕 Buy me a pizza" ,
80
+ parentId : "support" ,
81
+ contexts : [ "action" ]
82
+ } ) ;
83
+
84
+ chrome . contextMenus . create ( {
85
+ id : "review" ,
86
+ title : "🌟 Leave a review" ,
87
+ parentId : "support" ,
88
+ contexts : [ "action" ]
89
+ } ) ;
90
+ }
91
+
92
+ chrome . runtime . onInstalled . addListener ( async ( ) => {
93
+ await createActionContextMenus ( ) ;
94
+ } ) ;
95
+
96
+ chrome . runtime . onStartup . addListener ( async ( ) => {
97
+ await createActionContextMenus ( ) ;
98
+ } ) ;
99
+
100
+ chrome . contextMenus . onClicked . addListener ( async ( info , tab ) => {
101
+ switch ( info . menuItemId ) {
102
+ case "github" :
103
+ chrome . tabs . create ( { url : 'https://github.com/shevabam/get-rss-feed-url-extension' } ) ;
104
+ break ;
105
+ case "reportIssue" :
106
+ chrome . tabs . create ( { url : 'https://github.com/shevabam/get-rss-feed-url-extension/issues' } ) ;
107
+ break ;
108
+ case "donate" :
109
+ chrome . tabs . create ( { url : 'https://buymeacoffee.com/shevabam' } ) ;
110
+ break ;
111
+ case "review" :
112
+ chrome . tabs . create ( { url : `https://chromewebstore.google.com/detail/${ chrome . runtime . id } /reviews` } ) ;
113
+ break ;
114
+ }
115
+ } ) ;
0 commit comments