Skip to content

Commit d05d68c

Browse files
committed
Add option to show 'Open All' as the first item in the submenu
1 parent 40761af commit d05d68c

File tree

7 files changed

+52
-13
lines changed

7 files changed

+52
-13
lines changed

CHANGES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 4.1.0
4+
5+
- Add option to show 'Open All' as the first item
6+
37
## 4.0.0
48

59
- Complete rewrite with Manifest v3 and Svelte framework with a slightly updated UI

public/_locales/de/messages.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,8 @@
8686
},
8787
"showOpenAll": {
8888
"message": "'Alle öffnen' anzeigen"
89+
},
90+
"showOpenAllAtTop": {
91+
"message": "'Alle öffnen' als Erstes anzeigen"
8992
}
9093
}

public/_locales/en/messages.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,8 @@
8686
},
8787
"showOpenAll": {
8888
"message": "Show 'Open All'"
89+
},
90+
"showOpenAllAtTop": {
91+
"message": "Show 'Open All' at the top"
8992
}
9093
}

public/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"name": "__MSG_extensionName__",
55
"description": "__MSG_extensionDescription__",
66
"author": "Andreas Bielawski",
7-
"version": "4.0.0",
7+
"version": "4.1.0",
88
"icons": {
99
"16": "icons/16.png",
1010
"32": "icons/32.png",

source/default-options.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"openInBackground": false,
33
"openTabAt": "right",
44
"showOpenAll": true,
5+
"showOpenAllAtTop": false,
56
"searchAllByDefault": false,
67
"storageProviders": [
78
{

source/options/components/Form.svelte

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,24 @@
9696
</div>
9797
</div>
9898

99+
<div class="row">
100+
<label
101+
class="col-sm-3 col-form-label form-check-label"
102+
for="showOpenAllAtTop">{getMessage('showOpenAllAtTop')}</label
103+
>
104+
<div class="col-sm-9">
105+
<input
106+
id="showOpenAllAtTop"
107+
class="form-check-input mt-2"
108+
name="showOpenAllAtTop"
109+
type="checkbox"
110+
bind:checked={$options.showOpenAllAtTop}
111+
disabled={$options.searchAllByDefault === true ||
112+
$options.showOpenAll === false}
113+
/>
114+
</div>
115+
</div>
116+
99117
<div class="row">
100118
<label
101119
class="col-sm-3 col-form-label form-check-label"

source/service-worker/service-worker-functions.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const OPEN_ALL_ID = 'openAll';
77
export const setupContextMenu = ({
88
storageProviders,
99
showOpenAll,
10+
showOpenAllAtTop,
1011
searchAllByDefault,
1112
}) => {
1213
const selectedProviders = storageProviders.filter((p) => p.selected);
@@ -21,13 +22,31 @@ export const setupContextMenu = ({
2122
return;
2223
}
2324

25+
const separator = {
26+
parentId: PARENT_ID,
27+
id: 'image-reverse-search-separator',
28+
type: 'separator',
29+
};
30+
31+
const openAllEntry = {
32+
parentId: PARENT_ID,
33+
id: OPEN_ALL_ID,
34+
title: getMessageForServiceWorker('contextMenuOpenAll'),
35+
contexts: ['image'],
36+
};
37+
2438
/* Create menu and submenu entries */
2539
chrome.contextMenus.create({
2640
id: PARENT_ID,
2741
title: getMessageForServiceWorker('contextMenuTitle'),
2842
contexts: ['image'],
2943
});
3044

45+
if (showOpenAll && showOpenAllAtTop) {
46+
chrome.contextMenus.create(openAllEntry);
47+
chrome.contextMenus.create(separator);
48+
}
49+
3150
for (const provider of selectedProviders) {
3251
const contextMenuOptions = {
3352
parentId: PARENT_ID,
@@ -47,18 +66,9 @@ export const setupContextMenu = ({
4766
}
4867
}
4968

50-
if (showOpenAll) {
51-
chrome.contextMenus.create({
52-
parentId: PARENT_ID,
53-
id: 'imag-ereverse-search-seperator',
54-
type: 'separator',
55-
});
56-
chrome.contextMenus.create({
57-
parentId: PARENT_ID,
58-
id: OPEN_ALL_ID,
59-
title: getMessageForServiceWorker('contextMenuOpenAll'),
60-
contexts: ['image'],
61-
});
69+
if (showOpenAll && !showOpenAllAtTop) {
70+
chrome.contextMenus.create(separator);
71+
chrome.contextMenus.create(openAllEntry);
6272
}
6373
};
6474

0 commit comments

Comments
 (0)