11const assignManager = {
22 MENU_ASSIGN_ID : "open-in-this-container" ,
33 MENU_REMOVE_ID : "remove-open-in-this-container" ,
4+ MENU_SEPARATOR_ID : "separator" ,
5+ MENU_HIDE_ID : "hide-container" ,
6+ MENU_MOVE_ID : "move-to-new-window-container" ,
7+
48 storageArea : {
59 area : browser . storage . local ,
610 exemptedTabs : { } ,
@@ -163,15 +167,31 @@ const assignManager = {
163167 async _onClickedHandler ( info , tab ) {
164168 const userContextId = this . getUserContextIdFromCookieStore ( tab ) ;
165169 // Mapping ${URL(info.pageUrl).hostname} to ${userContextId}
170+ let remove ;
166171 if ( userContextId ) {
167- // let actionName;
168- let remove ;
169- if ( info . menuItemId === this . MENU_ASSIGN_ID ) {
170- remove = false ;
171- } else {
172- remove = true ;
172+ switch ( info . menuItemId ) {
173+ case this . MENU_ASSIGN_ID :
174+ case this . MENU_REMOVE_ID :
175+ if ( info . menuItemId === this . MENU_ASSIGN_ID ) {
176+ remove = false ;
177+ } else {
178+ remove = true ;
179+ }
180+ await this . _setOrRemoveAssignment ( tab . id , info . pageUrl , userContextId , remove ) ;
181+ break ;
182+ case this . MENU_MOVE_ID :
183+ backgroundLogic . moveTabsToWindow ( {
184+ cookieStoreId : tab . cookieStoreId ,
185+ windowId : tab . windowId ,
186+ } ) ;
187+ break ;
188+ case this . MENU_HIDE_ID :
189+ backgroundLogic . hideTabs ( {
190+ cookieStoreId : tab . cookieStoreId ,
191+ windowId : tab . windowId ,
192+ } ) ;
193+ break ;
173194 }
174- await this . _setOrRemoveAssignment ( tab . id , info . pageUrl , userContextId , remove ) ;
175195 }
176196 } ,
177197
@@ -260,6 +280,9 @@ const assignManager = {
260280 // See: https://bugzilla.mozilla.org/show_bug.cgi?id=1352102
261281 browser . contextMenus . remove ( this . MENU_ASSIGN_ID ) ;
262282 browser . contextMenus . remove ( this . MENU_REMOVE_ID ) ;
283+ browser . contextMenus . remove ( this . MENU_SEPARATOR_ID ) ;
284+ browser . contextMenus . remove ( this . MENU_HIDE_ID ) ;
285+ browser . contextMenus . remove ( this . MENU_MOVE_ID ) ;
263286 } ,
264287
265288 async calculateContextMenu ( tab ) {
@@ -270,19 +293,37 @@ const assignManager = {
270293 if ( siteSettings === false ) {
271294 return false ;
272295 }
273- // ✓ This is to mitigate https://bugzilla.mozilla.org/show_bug.cgi?id=1351418
274- let prefix = " " ; // Alignment of non breaking space, unknown why this requires so many spaces to align with the tick
296+ let checked = false ;
275297 let menuId = this . MENU_ASSIGN_ID ;
276298 const tabUserContextId = this . getUserContextIdFromCookieStore ( tab ) ;
277299 if ( siteSettings &&
278300 Number ( siteSettings . userContextId ) === Number ( tabUserContextId ) ) {
279- prefix = "✓" ;
301+ checked = true ;
280302 menuId = this . MENU_REMOVE_ID ;
281303 }
282304 browser . contextMenus . create ( {
283305 id : menuId ,
284- title : `${ prefix } Always Open in This Container` ,
285- checked : true ,
306+ title : "Always Open in This Container" ,
307+ checked,
308+ type : "checkbox" ,
309+ contexts : [ "all" ] ,
310+ } ) ;
311+
312+ browser . contextMenus . create ( {
313+ id : this . MENU_SEPARATOR_ID ,
314+ type : "separator" ,
315+ contexts : [ "all" ] ,
316+ } ) ;
317+
318+ browser . contextMenus . create ( {
319+ id : this . MENU_HIDE_ID ,
320+ title : "Hide This Container" ,
321+ contexts : [ "all" ] ,
322+ } ) ;
323+
324+ browser . contextMenus . create ( {
325+ id : this . MENU_MOVE_ID ,
326+ title : "Move Tabs to a New Window" ,
286327 contexts : [ "all" ] ,
287328 } ) ;
288329 } ,
0 commit comments