Skip to content

Commit

Permalink
Add Close Duplicate Tabs context menu (#297)
Browse files Browse the repository at this point in the history
SEMVER_MAJOR
  • Loading branch information
asamuzaK committed Jun 15, 2024
1 parent 21510d5 commit 53e37ac
Show file tree
Hide file tree
Showing 18 changed files with 750 additions and 149 deletions.
2 changes: 0 additions & 2 deletions resource/dark-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
"button_primary_color": "rgb(43, 42, 51)",
"input_background": "#42414D",
"input_color": "rgb(251,251,254)",
"input_border": "#8f8f9d",
"urlbar_popup_separator": "rgb(82,82,94)",
"tab_icon_overlay_stroke": "rgb(66,65,77)",
"tab_icon_overlay_fill": "rgb(251,251,254)"
Expand All @@ -75,7 +74,6 @@
"button_primary_color": "--button-primary-color",
"input_background": "--input-bgcolor",
"input_color": "--input-color",
"input_border": "--input-border-color",
"urlbar_popup_separator": "--urlbarView-separator-color",
"zoom_controls": "--zoom-controls-bgcolor",
"tab_icon_overlay_stroke": "--tab-icon-overlay-stroke",
Expand Down
3 changes: 0 additions & 3 deletions resource/light-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"panel_active": "color-mix(in srgb, currentColor 20%, transparent)",
"panel_active_darker": "color-mix(in srgb, currentColor 27%, transparent)",
"toolbar_field_icon_opacity": "0.72",
"input_border_color": "color-mix(in srgb, currentColor 41%, transparent)",
"zap_gradient": "linear-gradient(90deg, #9059FF 0%, #FF4AA2 52.08%, #FFBD4F 100%)"
}
},
Expand All @@ -77,7 +76,6 @@
"button_primary_color": "--button-primary-color",
"input_background": "--input-bgcolor",
"input_color": "--input-color",
"input_border": "--input-border-color",
"urlbar_popup_hover": "--urlbarView-hover-background",
"urlbar_popup_separator": "--urlbarView-separator-color",
"tab_icon_overlay_stroke": "--tab-icon-overlay-stroke",
Expand All @@ -88,7 +86,6 @@
"panel_active": "--arrowpanel-dimmed-further",
"panel_active_darker": "--panel-item-active-bgcolor",
"toolbar_field_icon_opacity": "--urlbar-icon-fill-opacity",
"input_border_color": "--input-border-color",
"zap_gradient": "--panel-separator-zap-gradient"
}
}
Expand Down
30 changes: 30 additions & 0 deletions src/_locales/de/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@
}
}
},
"closeDuplicateTabs_menu": {
"message": "&Doppelte Tabs schließen",
"description": "Refer to https://pontoon.mozilla.org/[lang]/firefox/browser/browser/tabContextMenu.ftl",
"placeholders": {
"key": {
"content": "$1",
"example": "(&U)"
}
}
},
"closeMultipleTabs_menu": {
"message": "&Mehrere Tabs schließen",
"description": "Refer to https://pontoon.mozilla.org/[lang]/firefox/browser/browser/tabContextMenu.ftl",
Expand Down Expand Up @@ -146,6 +156,26 @@
}
}
},
"closedTab": {
"message": "$NUM$ Tab geschlossen",
"description": "Refer to https://pontoon.mozilla.org/[lang]/firefox/browser/browser/confirmationHints.ftl",
"placeholders": {
"num": {
"content": "$1",
"example": "1"
}
}
},
"closedTabs": {
"message": "$NUM$ Tabs geschlossen",
"description": "Refer to https://pontoon.mozilla.org/[lang]/firefox/browser/browser/confirmationHints.ftl",
"placeholders": {
"num": {
"content": "$1",
"example": "2"
}
}
},
"collapseOtherTabGroups_menu": {
"message": "C&ollapse Other Tab Groups",
"placeholders": {
Expand Down
30 changes: 30 additions & 0 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@
}
}
},
"closeDuplicateTabs_menu": {
"message": "Close D&uplicate Tabs",
"description": "Refer to https://pontoon.mozilla.org/[lang]/firefox/browser/browser/tabContextMenu.ftl",
"placeholders": {
"key": {
"content": "$1",
"example": "(&U)"
}
}
},
"closeMultipleTabs_menu": {
"message": "Close &Multiple Tabs",
"description": "Refer to https://pontoon.mozilla.org/[lang]/firefox/browser/browser/tabContextMenu.ftl",
Expand Down Expand Up @@ -146,6 +156,26 @@
}
}
},
"closedTab": {
"message": "Closed $NUM$ tab",
"description": "Refer to https://pontoon.mozilla.org/[lang]/firefox/browser/browser/confirmationHints.ftl",
"placeholders": {
"num": {
"content": "$1",
"example": "1"
}
}
},
"closedTabs": {
"message": "Closed $NUM$ tabs",
"description": "Refer to https://pontoon.mozilla.org/[lang]/firefox/browser/browser/confirmationHints.ftl",
"placeholders": {
"num": {
"content": "$1",
"example": "2"
}
}
},
"collapseOtherTabGroups_menu": {
"message": "C&ollapse Other Tab Groups",
"placeholders": {
Expand Down
30 changes: 30 additions & 0 deletions src/_locales/fa/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@
}
}
},
"closeDuplicateTabs_menu": {
"message": "Close Duplicate Tabs $KEY$",
"description": "Refer to https://pontoon.mozilla.org/[lang]/firefox/browser/browser/tabContextMenu.ftl",
"placeholders": {
"key": {
"content": "$1",
"example": "(&U)"
}
}
},
"closeMultipleTabs_menu": {
"message": "بستن چندین زبانه $KEY$",
"description": "Refer to https://pontoon.mozilla.org/[lang]/firefox/browser/browser/tabContextMenu.ftl",
Expand Down Expand Up @@ -146,6 +156,26 @@
}
}
},
"closedTab": {
"message": "Closed $NUM$ tab",
"description": "Refer to https://pontoon.mozilla.org/[lang]/firefox/browser/browser/confirmationHints.ftl",
"placeholders": {
"num": {
"content": "$1",
"example": "1"
}
}
},
"closedTabs": {
"message": "Closed $NUM$ tabs",
"description": "Refer to https://pontoon.mozilla.org/[lang]/firefox/browser/browser/confirmationHints.ftl",
"placeholders": {
"num": {
"content": "$1",
"example": "2"
}
}
},
"collapseOtherTabGroups_menu": {
"message": "گروه زبانه های دیگر را جمع کن $KEY$",
"placeholders": {
Expand Down
30 changes: 30 additions & 0 deletions src/_locales/ja/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@
}
}
},
"closeDuplicateTabs_menu": {
"message": "重複タブを閉じる$KEY$",
"description": "Refer to https://pontoon.mozilla.org/[lang]/firefox/browser/browser/tabContextMenu.ftl",
"placeholders": {
"key": {
"content": "$1",
"example": "(&U)"
}
}
},
"closeMultipleTabs_menu": {
"message": "複数のタブを閉じる$KEY$",
"description": "Refer to https://pontoon.mozilla.org/[lang]/firefox/browser/browser/tabContextMenu.ftl",
Expand Down Expand Up @@ -146,6 +156,26 @@
}
}
},
"closedTab": {
"message": "$NUM$個のタブを閉じました",
"description": "Refer to https://pontoon.mozilla.org/[lang]/firefox/browser/browser/confirmationHints.ftl",
"placeholders": {
"num": {
"content": "$1",
"example": "1"
}
}
},
"closedTabs": {
"message": "$NUM$個のタブを閉じました",
"description": "Refer to https://pontoon.mozilla.org/[lang]/firefox/browser/browser/confirmationHints.ftl",
"placeholders": {
"num": {
"content": "$1",
"example": "2"
}
}
},
"collapseOtherTabGroups_menu": {
"message": "他のタブグループをすべて折りたたむ$KEY$",
"placeholders": {
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"browser_specific_settings": {
"gecko": {
"id": "sidebarTabs@asamuzak.jp",
"strict_min_version": "112.0"
"strict_min_version": "127.0"
}
},
"commands": {
Expand Down
22 changes: 22 additions & 0 deletions src/mjs/browser-tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,28 @@ export const closeTabs = async nodes => {
return func || null;
};

/**
* close duplicate tabs
* @param {Array} ids - array of id
* @param {object} elm - element
* @returns {Promise.<?Promise>} - removeTab()
*/
export const closeDupeTabs = async (ids, elm) => {
if (!Array.isArray(ids)) {
throw new TypeError(`Expected Array but got ${getType(ids)}.`);
}
let func;
if (ids.length) {
await removeTab(ids);
if (elm) {
// TODO: notify closed tabs count, i.e. `Closed n tabs`
// ref: https://searchfox.org/mozilla-central/source/browser/base/content/browser.js#7928
// func = notifyClosedTabsCount(elm, ids.length);
}
}
return func || null;
};

/**
* close other tabs
* @param {Array} nodes - array of node
Expand Down
15 changes: 9 additions & 6 deletions src/mjs/constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,7 @@ export const TAB_ALL_RELOAD = 'reloadAllTabs';
export const TAB_ALL_SELECT = 'selectAllTabs';
export const TAB_BOOKMARK = 'bookmarkTab';
export const TAB_CLOSE = 'closeTab';
export const TAB_CLOSE_DBLCLICK = 'closeTabsByDoubleClick';
export const TAB_CLOSE_END = 'closeTabsToTheEnd';
export const TAB_CLOSE_MDLCLICK = 'closeTabsByMiddleClick';
export const TAB_CLOSE_MDLCLICK_PREVENT = 'preventCloseTabsByMiddleClick';
export const TAB_CLOSE_OTHER = 'closeOtherTabs';
export const TAB_CLOSE_START = 'closeTabsToTheStart';
export const TAB_CLOSED = 'closedTab';
export const TAB_CLOSE_UNDO = 'undoCloseTab';
export const TAB_DUPE = 'dupeTab';
export const TAB_GROUP = 'tabGroup';
Expand Down Expand Up @@ -180,7 +175,15 @@ export const TAB_SWITCH_SCROLL = 'switchTabByScrolling';
export const TAB_SWITCH_SCROLL_ALWAYS = 'alwaysSwitchTabByScrolling';
export const TABS_BOOKMARK = 'bookmarkTabs';
export const TABS_CLOSE = 'closeTabs';
export const TABS_CLOSED = 'closedTabs';
export const TABS_CLOSE_DBLCLICK = 'closeTabsByDoubleClick';
export const TABS_CLOSE_DUPE = 'closeDuplicateTabs';
export const TABS_CLOSE_END = 'closeTabsToTheEnd';
export const TABS_CLOSE_MDLCLICK = 'closeTabsByMiddleClick';
export const TABS_CLOSE_MDLCLICK_PREVENT = 'preventCloseTabsByMiddleClick';
export const TABS_CLOSE_MULTIPLE = 'closeMultipleTabs';
export const TABS_CLOSE_OTHER = 'closeOtherTabs';
export const TABS_CLOSE_START = 'closeTabsToTheStart';
export const TABS_DUPE = 'dupeTabs';
export const TABS_MOVE = 'moveTabs';
export const TABS_MOVE_END = 'moveTabsToEnd';
Expand Down
Loading

0 comments on commit 53e37ac

Please sign in to comment.