@@ -165,6 +165,20 @@ async function createMenus() {
165
165
title : "Download All Tabs as Markdown" ,
166
166
contexts : [ "tab" ]
167
167
} , ( ) => { } ) ;
168
+
169
+ browser . contextMenus . create ( {
170
+ id : "separator-0" ,
171
+ type : "separator" ,
172
+ contexts : [ "tab" ]
173
+ } , ( ) => { } ) ;
174
+
175
+ browser . contextMenus . create ( {
176
+ id : "tabtoggle-includeTemplate" ,
177
+ type : "checkbox" ,
178
+ title : "Include front/back template" ,
179
+ contexts : [ "tab" ] ,
180
+ checked : options . includeTemplate
181
+ } , ( ) => { } ) ;
168
182
} catch {
169
183
// add the download all tabs option to the page context menu instead
170
184
browser . contextMenus . create ( {
@@ -249,7 +263,7 @@ browser.contextMenus.onClicked.addListener(function (info, tab) {
249
263
downloadMarkdownFromContext ( info , tab ) ;
250
264
}
251
265
// a settings toggle command
252
- else if ( info . menuItemId . startsWith ( "toggle-" ) ) {
266
+ else if ( info . menuItemId . startsWith ( "toggle-" ) || info . menuItemId . startsWith ( "tabtoggle-" ) ) {
253
267
toggleSetting ( info . menuItemId . split ( '-' ) [ 1 ] ) ;
254
268
}
255
269
} ) ;
@@ -265,6 +279,16 @@ async function toggleSetting(setting, options = null) {
265
279
// toggle the option and save back to storage
266
280
options [ setting ] = ! options [ setting ] ;
267
281
await browser . storage . sync . set ( options ) ;
282
+ if ( setting == "includeTemplate" ) {
283
+ browser . contextMenus . update ( "toggle-includeTemplate" , {
284
+ checked : options . includeTemplate
285
+ } ) ;
286
+ try {
287
+ browser . contextMenus . update ( "tabtoggle-includeTemplate" , {
288
+ checked : options . includeTemplate
289
+ } ) ;
290
+ } catch { }
291
+ }
268
292
}
269
293
}
270
294
0 commit comments