-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.js
More file actions
267 lines (231 loc) · 38.4 KB
/
Copy pathsettings.js
File metadata and controls
267 lines (231 loc) · 38.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
/**
* Image Tools - Settings Logic
*/
const elements = {
quality: document.getElementById('quality'),
qualityVal: document.getElementById('quality-val'),
prefix: document.getElementById('prefix'),
groupMenu: document.getElementById('group-menu'),
subfolder: document.getElementById('subfolder'),
themeStatus: document.getElementById('theme-status'),
orderList: document.getElementById('order-list'),
};
let _saveTimer = null;
function autoSave() {
// Debounce: 'input' events fire per keystroke/slider tick, so wait for a
// quiet moment before writing to storage (each write re-syncs the menu).
if (_saveTimer) clearTimeout(_saveTimer);
_saveTimer = setTimeout(() => {
_saveTimer = null;
const newPrefs = {
quality: parseInt(elements.quality.value),
prefix: elements.prefix.value.trim(),
groupMenu: elements.groupMenu.checked,
subfolder: elements.subfolder.value.trim(),
menuOrder: currentOrder,
...currentEnabled
};
chrome.storage.sync.set(newPrefs);
}, 250);
}
elements.quality.addEventListener('change', autoSave);
elements.prefix.addEventListener('change', autoSave);
elements.prefix.addEventListener('input', autoSave);
elements.groupMenu.addEventListener('change', autoSave);
elements.subfolder.addEventListener('change', autoSave);
elements.subfolder.addEventListener('input', autoSave);
const icons = {
// Brand Color for formats
image: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="var(--primary)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"/></svg>',
// Official Search Logos
google: '<svg width="18" height="18" viewBox="0 0 192 192" xmlns="http://www.w3.org/2000/svg"><circle cx="154.752" cy="154.667" r="19.556" fill="#34a853"/><circle cx="96.086" cy="105.778" r="29.333" fill="#4285f4"/><path fill="#ea4335" d="M8,143.911C8,166.046,25.954,184,48.089,184H96v-19.556l-49.011-0.122 c-10.756,0-19.433-10.01-19.433-21.878v-22H8V143.911z"/><path fill="#fbbc05" d="M184,67.644c0-22.134-17.954-40.089-40.089-40.089h-23.467l24.444,19.556 c10.756,0,19.556,10.132,19.556,22v36.667H184V67.644z"/><path fill="#4285f4" d="M115.556,8H76.444L61.778,27.556H48.089C25.954,27.556,8,45.51,8,67.644v23.467h19.556v-22 c0-11.868,8.8-22,19.556-22h97.778L115.556,8z"/></svg>',
lenso: '<svg width="18" height="18" viewBox="0 0 192 192" xmlns="http://www.w3.org/2000/svg"><defs><filter id="a_lenso_settings" width="176" height="156.218" x="8" y="17.891" filterUnits="userSpaceOnUse"><feColorMatrix values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"/></filter></defs><mask id="b_lenso_settings" width="176" height="156.218" x="8" y="17.891" maskUnits="userSpaceOnUse"><path fill="#fff" d="M184.098,17.613H7.932v156.596h176.166V17.61V17.613z" filter="url(#a_lenso_settings)"/></mask><g mask="url(#b_lenso_settings)"><path fill="#140ea8" d="M79.752,26.642c4.791-8.367,15.409-11.236,23.71-6.404s11.146,15.534,6.35,23.901L40.39,165.36 c-4.791,8.367-15.406,11.234-23.71,6.402c-8.299-4.832-11.146-15.534-6.35-23.901L79.752,26.642z"/><path fill="#a1a6f3" d="M142.178,77.943c-3.221-5.656-9.238-9.138-15.747-9.113c-6.505-0.021-12.517,3.461-15.736,9.113 l-39.4,68.792c-4.99,8.716-2.028,19.859,6.617,24.893c8.645,5.031,19.701,2.044,24.691-6.672 c3.026-5.307,8.662-8.587,14.771-8.596h18.121c6.109,0.009,11.745,3.289,14.771,8.596c4.993,8.716,16.047,11.702,24.691,6.672 c8.647-5.034,11.61-16.177,6.617-24.893L142.18,77.943H142.178z"/><path fill="#5a66e9" d="M110.757,77.834c4.99-8.716,16.047-11.7,24.691-6.669c8.645,5.031,11.61,16.177,6.617,24.893 l-39.462,68.898c-4.99,8.716-16.047,11.702-24.691,6.672c-8.645-5.034-11.61-16.177-6.617-24.893 C71.295,146.735,110.757,77.834,110.757,77.834z"/></g></svg>',
bing: '<svg width="18" height="18" viewBox="0 0 192 192" xmlns="http://www.w3.org/2000/svg"><linearGradient id="a_bing_settings" gradientUnits="userSpaceOnUse" x1="55.7284" y1="155.5388" x2="70.7399" y2="146.8719" gradientTransform="matrix(5.5556 0 0 -5.5556 -210 958.6666)"><stop offset="0" stop-color="#37BDFF"/><stop offset="0.1832" stop-color="#33BFFD"/><stop offset="0.3576" stop-color="#28C5F5"/><stop offset="0.528" stop-color="#15D0E9"/><stop offset="0.5468" stop-color="#12D1E7"/><stop offset="0.5903" stop-color="#1CD2E5"/><stop offset="0.7679" stop-color="#42D8DC"/><stop offset="0.9107" stop-color="#59DBD6"/><stop offset="1" stop-color="#62DCD4"/></linearGradient><path d="M155.963,120.988c0,1.745-0.095,3.483-0.282,5.196 c-1.129,10.435-5.647,19.877-12.448,27.177c0.854-0.953,1.628-1.973,2.306-3.069c0.521-0.832,0.986-1.698,1.379-2.603 c0.143-0.297,0.271-0.605,0.378-0.913c0.132-0.297,0.238-0.609,0.334-0.917c0.106-0.282,0.202-0.583,0.286-0.88 c0.081-0.308,0.165-0.616,0.235-0.924c0.015-0.037,0.026-0.073,0.037-0.11c0.073-0.308,0.128-0.616,0.191-0.924 c0.059-0.323,0.121-0.645,0.165-0.964c0-0.011,0-0.011,0-0.022c0.048-0.297,0.084-0.594,0.11-0.906 c0.07-0.7,0.106-1.401,0.106-2.116c0-4.015-1.107-7.788-3.043-10.996c-0.44-0.748-0.928-1.459-1.463-2.138 c-0.627-0.81-1.305-1.569-2.042-2.27c-1.83-1.771-3.971-3.223-6.336-4.246c-1.023-0.451-2.09-0.818-3.186-1.093 c-0.011,0-0.033-0.015-0.048-0.015l-0.378-0.128l-5.54-1.903v-0.011l-14.491-4.983c-0.048-0.011-0.106-0.011-0.143-0.022 l-0.906-0.334c-2.911-1.14-5.324-3.278-6.835-6.002L99.06,91.38l-6.065-15.455l-1.166-2.985l-0.297-0.609 c-0.33-0.807-0.513-1.687-0.513-2.603c0-0.235,0-0.473,0.026-0.689c0.345-3.399,3.234-6.065,6.728-6.065 c0.928,0,1.819,0.191,2.629,0.535l27.005,13.849l5.324,2.721c2.82,1.679,5.445,3.652,7.847,5.874 c8.701,7.99,14.41,19.188,15.264,31.709C155.915,118.766,155.963,119.87,155.963,120.988L155.963,120.988z" fill="url(#a_bing_settings)"/><linearGradient id="b_bing_settings" gradientUnits="userSpaceOnUse" x1="46.4623" y1="145.3685" x2="68.3095" y2="145.3685" gradientTransform="matrix(5.5556 0 0 -5.5556 -210 958.6666)"><stop offset="0" stop-color="#39D2FF"/><stop offset="0.1501" stop-color="#38CEFE"/><stop offset="0.2931" stop-color="#35C3FA"/><stop offset="0.4327" stop-color="#2FB0F3"/><stop offset="0.5468" stop-color="#299AEB"/><stop offset="0.5827" stop-color="#2692EC"/><stop offset="0.7635" stop-color="#1A6CF1"/><stop offset="0.909" stop-color="#1355F4"/><stop offset="1" stop-color="#104CF5"/></linearGradient><path d="M148.747,139.014c0,1.379-0.128,2.71-0.37,4.008c-0.07,0.345-0.139,0.689-0.224,1.034 c-0.154,0.616-0.319,1.21-0.521,1.804c-0.11,0.312-0.216,0.62-0.334,0.917c-0.121,0.308-0.249,0.605-0.378,0.913 c-0.396,0.906-0.858,1.771-1.382,2.603c-0.675,1.096-1.452,2.116-2.306,3.069c-3.934,4.352-17.299,12.111-22.224,15.264 l-10.93,6.681c-8.012,4.939-15.587,8.43-25.135,8.668c-0.451,0.015-0.891,0.026-1.331,0.026c-0.616,0-1.225-0.011-1.83-0.033c-16.17-0.62-30.268-9.299-38.401-22.125c-3.718-5.863-6.182-12.591-7.014-19.818c1.749,9.878,10.358,17.369,20.735,17.369c3.641,0,7.051-0.917,10.036-2.534c0.022-0.015,0.048-0.026,0.073-0.037l1.067-0.642l4.352-2.567l5.54-3.282v-0.154l0.715-0.429l49.566-29.363l3.813-2.259l0.381,0.128c0.011,0,0.033,0.015,0.048,0.015c1.093,0.271,2.163,0.642,3.183,1.093c2.369,1.023,4.506,2.475,6.336,4.246c0.737,0.7,1.415,1.463,2.046,2.27c0.535,0.678,1.023,1.393,1.459,2.138 C147.639,131.226,148.747,134.995,148.747,139.014L148.747,139.014z" fill="url(#b_bing_settings)"/><linearGradient id="c_bing_settings" gradientUnits="userSpaceOnUse" x1="48.08" y1="139.8044" x2="48.08" y2="169.0177" gradientTransform="matrix(5.5556 0 0 -5.5556 -210 958.6666)"><stop offset="0" stop-color="#1B48EF"/><stop offset="0.1221" stop-color="#1C51F0"/><stop offset="0.3212" stop-color="#1E69F5"/><stop offset="0.5676" stop-color="#2190FB"/><stop offset="1" stop-color="#26B8F4"/></linearGradient><path d="M78.185,41.015l-0.018,109.314l-5.54,3.282l-4.356,2.567l-1.071,0.649 c-0.018,0-0.048,0.018-0.066,0.033c-2.988,1.61-6.398,2.534-10.039,2.534c-10.38,0-18.975-7.487-20.731-17.369 c-0.084-0.455-0.147-0.924-0.198-1.379c-0.062-0.865-0.11-1.709-0.128-2.57V15.051c0-3.883,3.153-7.051,7.051-7.051 c1.459,0,2.827,0.455,3.949,1.203l21.556,14.084c0.117,0.099,0.242,0.183,0.378,0.26C74.544,27.353,78.185,33.751,78.185,41.015 L78.185,41.015z" fill="url(#c_bing_settings)"/><linearGradient id="d_bing_settings" gradientUnits="userSpaceOnUse" x1="47.5642" y1="139.5736" x2="61.0465" y2="153.0558" gradientTransform="matrix(5.5556 0 0 -5.5556 -210 958.6666)"><stop offset="0" stop-color="#FFFFFF"/><stop offset="0.3726" stop-color="#FDFDFD"/><stop offset="0.5069" stop-color="#F6F6F6"/><stop offset="0.6026" stop-color="#EBEBEB"/><stop offset="0.68" stop-color="#DADADA"/><stop offset="0.7463" stop-color="#C4C4C4"/><stop offset="0.805" stop-color="#A8A8A8"/><stop offset="0.8581" stop-color="#888888"/><stop offset="0.9069" stop-color="#626262"/><stop offset="0.9523" stop-color="#373737"/><stop offset="0.9926" stop-color="#090909"/><stop offset="1" stop-color="#000000"/></linearGradient><path d="M148.747,139.014c0,1.379-0.128,2.71-0.37,4.008 c-0.07,0.345-0.139,0.689-0.224,1.034c-0.154,0.616-0.319,1.21-0.521,1.804c-0.11,0.312-0.216,0.62-0.334,0.917 c-0.121,0.308-0.249,0.605-0.378,0.913c-0.396,0.906-0.858,1.771-1.382,2.603c-0.675,1.096-1.448,2.116-2.306,3.069 c-3.934,4.352-17.299,12.111-22.224,15.264l-10.93,6.681c-8.012,4.939-15.587,8.43-25.135,8.668 c-0.451,0.015-0.891,0.026-1.331,0.026c-0.616,0-1.225-0.011-1.83-0.033c-16.17-0.62-30.268-9.299-38.401-22.125 c-3.718-5.863-6.182-12.591-7.014-19.818c1.749,9.878,10.358,17.369,20.735,17.369c3.641,0,7.051-0.917,10.036-2.534 c0.022-0.015,0.048-0.026,0.073-0.037l1.067-0.642l4.352-2.567l5.54-3.282v-0.154l0.715-0.429l49.566-29.363l3.813-2.259 l0.381,0.128c0.011,0,0.033,0.015,0.048,0.015c1.093,0.271,2.163,0.642,3.183,1.093c2.369,1.023,4.506,2.475,6.336,4.246 c0.737,0.7,1.415,1.463,2.046,2.27c0.535,0.678,1.023,1.393,1.459,2.138C147.639,131.226,148.747,134.995,148.747,139.014 L148.747,139.014z" fill="url(#d_bing_settings)" fill-opacity="0.15"/><linearGradient id="e_bing_settings" gradientUnits="userSpaceOnUse" x1="48.08" y1="169.536" x2="48.08" y2="140.1051" gradientTransform="matrix(5.5556 0 0 -5.5556 -210 958.6666)"><stop offset="0" stop-color="#FFFFFF"/><stop offset="0.3726" stop-color="#FDFDFD"/><stop offset="0.5069" stop-color="#F6F6F6"/><stop offset="0.6026" stop-color="#EBEBEB"/><stop offset="0.68" stop-color="#DADADA"/><stop offset="0.7463" stop-color="#C4C4C4"/><stop offset="0.805" stop-color="#A8A8A8"/><stop offset="0.8581" stop-color="#888888"/><stop offset="0.9069" stop-color="#626262"/><stop offset="0.9523" stop-color="#373737"/><stop offset="0.9926" stop-color="#090909"/><stop offset="1" stop-color="#000000"/></linearGradient><path d="M78.185,41.015l-0.018,109.314l-5.54,3.282l-4.356,2.567l-1.071,0.649 c-0.018,0-0.048,0.018-0.066,0.033c-2.988,1.61-6.398,2.534-10.039,2.534c-10.38,0-18.975-7.487-20.731-17.369 c-0.084-0.455-0.147-0.924-0.198-1.379c-0.062-0.865-0.11-1.709-0.128-2.57V15.051c0-3.883,3.153-7.051,7.051-7.051 c1.459,0,2.827,0.455,3.949,1.203l21.556,14.084c0.117,0.099,0.242,0.183,0.378,0.26C74.544,27.353,78.185,33.751,78.185,41.015 L78.185,41.015z" fill="url(#e_bing_settings)" fill-opacity="0.1"/></svg>',
yandex: '<svg width="18" height="18" viewBox="0 0 192 192" xmlns="http://www.w3.org/2000/svg"><path d="M8,96C8,47.399,47.399,8,96,8s88,39.399,88,88s-39.399,88-88,88S8,144.601,8,96z" fill="#fc3f1d"/><path d="M98.486,106.01c5.357,11.734,7.142,15.813,7.142,29.906V154.6H86.499v-31.498L50.405,44.603h19.96 L98.486,106.01z M122.081,44.602L98.678,97.785h19.448L141.595,44.6h-19.514L122.081,44.602z" fill="#fff"/></svg>',
baidu: '<svg width="18" height="18" viewBox="0 0 192 192" xmlns="http://www.w3.org/2000/svg"><g transform="translate(121.212121, 90.909091)" fill="#3388FF"><path d="M-46.082-28.519c10.601,0,19.167-12.163,19.167-27.203 c0-15.027-8.566-27.187-19.167-27.187c-10.588,0-19.177,12.16-19.177,27.187C-65.259-40.682-56.67-28.519-46.082-28.519"/><path d="M-0.426-26.72c14.175,1.831,23.286-13.244,25.097-24.67 c1.847-11.406-7.297-24.666-17.327-26.944c-10.056-2.297-22.608,13.755-23.75,24.223 C-17.772-41.317-14.566-28.539-0.426-26.72"/><path d="M-81.714,9.834c19.193-4.113,16.583-26.98,16.009-31.983 c-0.945-7.708-10.036-21.172-22.384-20.11c-15.535,1.388-17.804,23.76-17.804,23.76 C-107.996-8.154-100.865,13.946-81.714,9.834"/><path d="M55.749-7.536c0-5.462-4.551-21.926-21.446-21.926 c-16.927,0-19.187,15.535-19.187,26.517c0,10.484,0.886,25.116,21.907,24.65C58.051,21.246,55.749-2.039,55.749-7.536"/><path d="M-61.332,49.611c-0.562,1.608-1.818,5.721-0.734,9.303 c2.149,8.031,9.147,8.394,9.147,8.394h10.049V42.81h-10.767C-58.472,44.25-60.809,48-61.332,49.611"/><path d="M15.1,76.986h-28.713c-11.124-2.86-11.653-10.74-11.653-10.74V34.588 l11.653-0.188v28.456c0.711,3.029,4.492,3.579,4.492,3.579H2.713V34.588H15.1V76.986z M-31.375,77.158h-24.948 c-10.776-2.139-15.068-9.474-15.613-10.723c-0.536-1.268-3.583-7.161-1.967-17.182c4.658-15.024,17.94-16.105,17.94-16.105 h13.282V16.875l11.306,0.171V77.158z M34.302,40.448c0,0-21.926-16.91-34.728-35.186 C-17.772-21.686-42.421-10.72-50.663,2.983c-8.206,13.704-20.998,22.372-22.822,24.666 c-1.837,2.262-26.477,15.519-21.008,39.742c5.469,24.21,24.679,23.741,24.679,23.741s14.159,1.391,30.589-2.275 c16.424-3.631,30.577,0.906,30.577,0.906s38.38,12.814,48.877-11.856C50.723,53.242,34.302,40.448,34.302,40.448 L34.302,40.448z"/></g></svg>',
sogou: '<svg width="18" height="18" viewBox="0 0 192 192" xmlns="http://www.w3.org/2000/svg"><g fill="#F63D13"><path d="M168.269,161.622l-8.79-8.153c-7.591,8.18-16.743,14.89-26.983,19.657L137.55,184 C149.208,178.573,159.627,170.935,168.269,161.622z"/><path d="M127.443,162.251c-9.556,4.448-20.208,6.937-31.443,6.937c-41.2,0-74.599-33.399-74.599-74.599 S54.8,19.989,96,19.989s74.599,33.399,74.599,74.599c0,19.592-7.556,37.417-19.909,50.728l8.789,8.153 c14.338-15.451,23.109-36.14,23.109-58.88C182.589,46.767,143.822,8,96,8S9.411,46.767,9.411,94.589S48.178,181.177,96,181.177 c13.041,0,25.405-2.888,36.497-8.052L127.443,162.251z"/><path d="M144.921,55.468l0,18.816c-16.901-7.937-62.609-18.222-64.747-6.05 c-2.886,16.43,73.858,15.615,67.994,52.508c-3.996,25.144-51.835,31.96-102.289,10.979l0-21.303 c18.067,12.405,63.11,22.469,66.655,9.325c4.367-16.19-70.936-17.901-68.605-50.455C45.967,40.829,98.962,37.484,144.921,55.468z"/></g></svg>',
tineye: '<svg viewBox="1 1 1068.602 1130.289" xmlns="http://www.w3.org/2000/svg" width="18" height="18"><path d="M1 146.465c1.012-3.903 1.838-7.409 3.07-10.766 5.624-15.345 16.325-25.676 31.703-30.943 17.155-5.875 33.28-3.237 47.818 7.437 16.318 11.982 22.46 28.84 20.238 48.376-2.052 18.038-12.097 31.13-28.646 39.863 0-1.39-.118-2.196.038-2.945.121-.585.582-1.099 1.068-1.954-7.978-4.868-15.508-9.882-25.418-9.679-5.159.106-7.615 2.867-8.59 6.88-.82 3.38-.169 7.119-.169 10.678-15.082.424-38.897-18.662-40.722-43.27C1 155.642 1 151.285 1 146.464zM697.563 1c3.152.66 5.846 1.434 8.586 1.962 21.387 4.124 36.727 21.703 39.678 42.526 2.322 16.39-2.362 31.39-13.7 43.634-3.924 4.238-9.373 7.064-14.794 11.024V86.514c-8.367-2.075-16.536-6.866-26.074-4.537-6.647 1.623-8.387 4.166-7.21 10.652.674 3.714 1.697 7.365 2.568 11.069-23.52-2.48-45.548-23.77-43.578-54.88 1.495-23.6 20.856-45.936 47.813-47.423C693.042 1 695.083 1 697.562 1z" fill="#ff8e4d"/><path d="M833.776 655.58c-10.198 10.224-20.302 20.53-27.821 33.009-.845 1.402-1.502 2.918-1.834 4.622 19.7-22.734 40.135-44.277 69.395-55.173-3.002 7.006-6.19 13.825-8.871 20.84-4.69 12.265-8.02 24.904-8.616 38.099-.485 10.743-1.676 21.576-.832 32.232 1.972 24.88 8.432 48.532 22.772 69.482 9.841 14.377 22.553 24.875 40.261 27.128 12.076 1.536 22.903-3.039 32.61-10.162 11.464-8.413 18.832-20.01 25.134-32.428 1.015-1.999 1.977-4.024 3.16-6.435 3.462 1.316 6.734 2.41 9.853 3.84.898.41 1.98 1.83 1.917 2.71-.816 11.438-1.7 22.875-2.824 34.286-.83 8.425-1.606 16.893-3.166 25.2-3.51 18.704-7.07 37.418-11.386 55.947-5.88 25.242-16.105 49.031-26.748 72.517-7.348 16.217-15.96 31.923-24.895 47.343-8.305 14.334-19.022 26.979-31.267 38.22-12.997 11.93-27.803 20.952-44.338 27.097-12.342 4.587-25.07 6.994-38.231 8.246-15.726 1.496-31.241.584-46.78-1.242-12.261-1.441-24.662-2.456-36.66-5.171-13.244-2.998-26.222-7.358-39.091-11.78-15.205-5.225-28.167-14.694-41.412-23.493-9.622-6.391-20.643-8.736-31.506-11.436-21.082-5.238-42.684-6.441-64.165-4.817-19.712 1.491-38.637 6.86-55.184 18.671-9.74 6.952-17.283 15.785-24.144 25.464-13.112 18.498-28.924 34.11-49.937 43.535-13.625 6.11-28.204 9.358-42.883 6.8-20.243-3.526-39.004-11.365-55.833-23.652-16.86-12.308-30.797-26.983-41.591-44.967-8.502-14.164-14.824-29.127-20.083-44.668-6.874-20.315-13.436-40.75-20.89-60.853-8.184-22.07-16.908-43.955-26.017-65.66-5.701-13.584-11.68-27.197-19.108-39.874-8.543-14.576-18.478-28.385-28.435-42.072-13.246-18.208-30.907-31.683-49.654-43.726-13.449-8.64-28.179-14.483-43.703-18.219-7.177-1.728-14.458-3.024-22.076-4.595.232-14.352 4.716-27.508 11.967-39.735 10.145-17.104 24.47-29.948 42.045-39.022 12.592-6.501 25.934-10.992 39.912-13.76 21.243-4.205 42.73-6.09 64.225-4.73 32.393 2.051 64.226 7.228 93.188 23.455 19.679 11.026 35.886 25.733 48.805 44.249 13.232 18.965 29.348 34.85 50.806 44.414 10.33 4.604 21.108 8 32.504 8.64 9.738.547 19.514 1.23 29.243.922 14.455-.456 28.58-3.25 42.498-7.357 18.897-5.576 35.259-15.42 48.973-29.285 12.7-12.84 22.52-28.006 32.437-43.073a1466.113 1466.113 0 0 1 35.434-51.417c6.192-8.588 12.99-16.884 20.458-24.371 9.269-9.293 18.948-18.377 29.472-26.17 15.528-11.499 31.456-22.645 48.152-32.32 15.104-8.754 31.1-16.27 47.368-22.63 18.478-7.223 37.565-13 56.638-18.546 11.712-3.405 23.842-5.473 35.873-7.651 23.644-4.28 47.586-4.891 71.484-3.91 23.363.959 46.105 5.144 67.855 14.681 17.212 7.548 31.471 18.688 43.382 32.658 7.468 8.759 12.993 19.172 19.418 28.824 2.862 4.3 5.794 8.553 8.568 12.64l-27.055 14.844c-8.802-7.399-17.266-15.134-26.382-22.002-9.389-7.073-20.492-10.987-31.998-12.606-10.873-1.53-22.022-2.578-32.941-1.947-17.924 1.035-35.542 4.802-52.31 11.431-11.769 4.653-23.328 9.9-34.717 15.423-6.627 3.214-13.073 7.052-18.941 11.481-3.194 2.41-4.626 7.023-7.528 9.979-5.936 6.045-12.084 11.936-18.588 17.357-10.634 8.86-22.608 16.338-32.174 26.188-8.913 9.178-15.89 20.388-22.893 31.238-13.673 21.186-23.306 44.306-30.348 68.458-3.638 12.476-6.514 25.175-9.703 37.78-.157.621-.02 1.317-.02 3.079 1.318-1.914 2.148-2.964 2.813-4.11 13.397-23.077 26.412-46.387 40.267-69.187 12.027-19.79 25.918-38.324 42.665-54.45 6.49-6.248 13.345-12.349 23-14.775.733.24.88.344 1.027.448" fill="#2c71a1"/><path d="M111.274 531.919c-1.425-2.304-2.883-4.587-4.267-6.914-6.663-11.196-14.614-21.852-19.626-33.745-6.375-15.128-11.098-31.076-15.144-47.022-3.174-12.51-4.482-25.522-6.163-38.37-1.374-10.505-3.456-21.193-2.74-31.629.992-14.457 3.509-28.946 6.886-43.06 2.776-11.599 6.764-23.155 12-33.857 7.262-14.839 17.008-28.15 28.216-40.56 16.136-17.864 34.4-32.98 54.856-45.321 15.683-9.462 32.147-17.63 48.289-26.329.5-.27 1.274-.034 2.357-.034-6.557 12.2-10.399 24.806-9.872 39.006 10.55-1.929 20.784-3.912 31.06-5.645 9.599-1.618 19.24-2.979 28.866-4.437 10.91-1.652 21.804-3.434 32.742-4.883 9.383-1.242 18.819-2.075 28.227-3.124 11.671-1.302 23.335-2.676 35.01-3.945 4.238-.46 8.496-.76 12.751-1.04 15.587-1.025 31.178-1.987 46.763-3.032 2.756-.185 5.616-.286 8.19-1.141 1.363-.453 2.604-2.279 3.239-3.767 8.277-19.404 20.902-35.287 39.157-45.93 13.107-7.642 27.702-8.734 42.6-6.323 2.597.42 5.346-.13 7.96.23 10.593 1.464 21.227 2.76 31.72 4.777 12.325 2.37 24.687 4.843 36.723 8.336a336.134 336.134 0 0 1 36.653 12.97c12.702 5.346 25.388 11.062 37.208 18.086 13.702 8.143 26.668 17.6 39.413 27.204 2.245 1.69 2.33 6.872 2.567 10.497 1.183 18.076 2.13 36.168 3.006 54.262.077 1.599-.49 3.719-1.56 4.807-9.856 10.019-16.62 21.46-17.384 35.853-.952 17.956 1.755 34.995 15.008 48.278 3.72 3.729 9.444 6.317 14.682 7.482a53.559 53.559 0 0 0 27.013-.97c9.915-2.969 16.342-10.268 19.165-19.798 7.535-25.441 3.02-48.47-15.62-68.054-1.33-1.397-2.909-2.674-4.598-3.59-8.758-4.752-10.2-13.713-12.5-21.998-2.093-7.535-3.397-15.29-4.296-23.5 3.045 3.265 6.42 6.284 9.074 9.84 8.51 11.401 17.147 22.74 25.01 34.584 12.224 18.418 20.751 38.61 27.103 59.774 4.034 13.439 7.075 26.985 6.993 41.104-.058 10.003.715 20.072-.18 29.996-1.367 15.159-6.268 29.186-16.355 41.103-9.711 11.474-21.865 19.756-34.937 26.61-16.19 8.488-32.696 16.389-49.227 24.2-12.315 5.82-24.892 11.085-37.337 16.63-1.019.453-1.928 1.153-3.437 2.06-11.006 5.07-21.508 9.721-31.899 14.61-4.036 1.9-7.82 4.335-11.72 6.526-5.516 2.17-11.126 4.13-16.53 6.551-13.01 5.83-25.846 12.054-38.9 17.783-13.787 6.05-27.527 12.32-41.684 17.39a854.019 854.019 0 0 1-55.83 17.861c-10.218 2.886-20.923 4.317-31.507 5.57-12.69 1.504-25.478 2.227-38.238 3.082-8.07.54-16.17.638-24.25 1.055-11.674.603-23.37 2.176-35.006 1.801-23.602-.76-46.949-3.724-70.058-9.165-20.113-4.736-38.798-13.253-58.266-19.643-10.038-3.294-20.61-5.183-30.314-9.218-15.067-6.264-29.406-14.109-41.517-25.423-2.854-2.665-6.02-4.995-9.414-7.896-3.625-3.797-6.878-7.176-10.131-10.555m73.558-223.68c-1.957.918-3.883 1.906-5.873 2.743-20.59 8.662-39.373 20.002-54.226 37.019-2.474 2.835-4.878 6.043-6.214 9.504-4.8 12.437-7.296 25.488-7.29 38.777.006 11.572.882 23.173 1.934 34.71 1.411 15.463 5.677 30.27 12.6 44.154 12.145 24.355 32.196 40.286 56.833 50.359 29.439 12.036 60.666 16.402 92.158 17.14 26.376.618 52.813-.85 79.207-1.824a483.46 483.46 0 0 0 39.068-3.048c18.999-2.253 38.009-4.661 56.847-7.958 24.862-4.352 49.655-9.203 74.307-14.616a567.756 567.756 0 0 0 83.14-25.058c15.603-6.037 30.865-12.955 46.237-19.576 1.24-.534 2.146-1.845 3.207-2.795-.88-.849-1.666-1.831-2.655-2.525-5.937-4.168-12.375-7.749-17.806-12.487-18.845-16.442-28.918-38.217-35.25-61.762-4.044-15.042-8.05-30.257-7.175-46.145.045-.809-.316-1.635-.317-2.454-.02-13.269-.305-26.546.087-39.804.288-9.74 1.627-19.445 2.076-29.184.064-1.37-2.163-3.982-3.514-4.112-23.36-2.246-46.715-4.981-70.141-5.964-19.903-.834-39.896.37-59.846.795-6.79.144-13.588.486-20.357 1.037-14.823 1.207-29.63 2.597-44.443 3.928-11.357 1.021-22.737 1.855-34.064 3.154-15.241 1.75-30.458 3.746-45.654 5.856-16.343 2.27-32.75 4.263-48.95 7.326-28.293 5.348-56.174 12.428-83.926 22.81z" fill="#2c71a1"/><path d="M185.21 308.158c27.374-10.3 55.255-17.38 83.548-22.73 16.2-3.062 32.607-5.055 48.95-7.325 15.196-2.11 30.413-4.107 45.654-5.856 11.327-1.299 22.707-2.133 34.064-3.154 14.813-1.331 29.62-2.721 44.443-3.928 6.77-.55 13.566-.893 20.357-1.037 19.95-.424 39.943-1.63 59.846-.795 23.426.983 46.781 3.718 70.141 5.964 1.35.13 3.578 2.742 3.514 4.112-.45 9.74-1.788 19.445-2.076 29.184-.392 13.258-.107 26.535-.087 39.804 0 .819.362 1.645.317 2.454-.876 15.888 3.131 31.103 7.176 46.145 6.33 23.545 16.404 45.32 35.249 61.762 5.431 4.738 11.869 8.319 17.806 12.487.989.694 1.775 1.676 2.655 2.525-1.061.95-1.967 2.26-3.207 2.795-15.372 6.621-30.634 13.54-46.236 19.576a567.756 567.756 0 0 1-83.14 25.058c-24.653 5.413-49.446 10.264-74.308 14.616-18.838 3.297-37.848 5.705-56.847 7.958a483.46 483.46 0 0 1-39.068 3.048c-26.394.975-52.831 2.442-79.207 1.824-31.492-.738-62.72-5.104-92.158-17.14-24.637-10.073-44.688-26.004-56.833-50.359-6.923-13.884-11.189-28.69-12.6-44.154-1.052-11.537-1.928-23.138-1.934-34.71-.006-13.29 2.49-26.34 7.29-38.777 1.336-3.46 3.74-6.67 6.214-9.504 14.853-17.017 33.635-28.357 54.226-37.019 1.99-.837 3.916-1.825 6.251-2.824m201.146 114.733c3.146 6.947 5.851 14.138 9.519 20.798 11.592 21.054 26.994 38.551 49.189 48.882 24.235 11.28 46.022 5.832 61.441-13.842 16.128-20.578 19.654-45.064 17.3-70.257-1.75-18.72-7.447-36.601-16.597-53.217-11.632-21.12-27.003-38.54-49.269-48.838-17.506-8.097-34.753-7.824-50.904 3.538-9.657 6.795-15.44 16.686-20.256 27.253-8.104 17.78-9.529 36.447-6.972 55.437 1.337 9.936 4.121 19.677 6.549 30.246m-205.288 6.26c.279.95.58 1.896.834 2.855 8.37 31.684 24.064 58.327 52.575 76.068 10.332 6.429 21.605 10.803 33.816 9.782 15.072-1.262 26.844-9.179 34.787-21.995 12.524-20.21 15.326-42.372 11.611-65.506-2.51-15.637-7.657-30.41-15.519-44.222-11.426-20.073-26.468-36.252-47.802-46.146-21.335-9.894-40.216-5.203-53.795 9.063-12.745 13.39-17.955 30.418-18.49 48.578-.301 10.198 1.181 20.449 1.983 31.522z" fill="#fff"/><path d="M386.208 422.521c-2.28-10.199-5.064-19.94-6.401-29.876-2.557-18.99-1.132-37.658 6.972-55.437 4.817-10.567 10.599-20.458 20.256-27.253 16.15-11.362 33.398-11.635 50.904-3.538 22.266 10.298 37.637 27.718 49.269 48.838 9.15 16.616 14.848 34.497 16.597 53.217 2.354 25.193-1.172 49.679-17.3 70.257-15.419 19.674-37.206 25.123-61.441 13.842-22.195-10.33-37.597-27.828-49.19-48.882-3.667-6.66-6.372-13.85-9.666-21.168m25.884-3.891c-.513 8.802.736 17.129 6.055 24.535 9.544 13.288 26.966 12.323 35.396.758 8.54-11.714 9.476-24.526 4.363-37.58-5.39-13.761-18.67-20.01-30.185-14.433-10.514 5.093-14.972 14.421-15.629 26.72zM181.007 428.727c-.74-10.65-2.223-20.901-1.923-31.1.536-18.16 5.746-35.187 18.491-48.577 13.579-14.266 32.46-18.957 53.795-9.063 21.334 9.894 36.376 26.073 47.802 46.146 7.862 13.811 13.009 28.585 15.52 44.222 3.714 23.134.912 45.296-11.612 65.506-7.943 12.816-19.715 20.733-34.787 21.995-12.21 1.021-23.484-3.353-33.816-9.782-28.511-17.741-44.204-44.384-52.575-76.068-.253-.959-.555-1.904-.895-3.28m22.423 22.124c.91 3.328 1.434 6.827 2.808 9.951 3.527 8.018 9.159 13.987 18.316 15.025 9.436 1.07 16.428-2.542 21.25-11.198 8.09-14.52 8.726-28.544-.864-42.536-7.955-11.606-26.807-11.4-35 .093-6.043 8.476-7.465 17.831-6.51 28.665z" fill="#fff"/><path d="M412.092 418.16c.657-11.829 5.115-21.157 15.63-26.25 11.515-5.577 24.794.672 30.184 14.433 5.113 13.054 4.178 25.866-4.363 37.58-8.43 11.565-25.852 12.53-35.396-.758-5.319-7.406-6.568-15.733-6.055-25.006zM203.28 450.427c-.805-10.41.617-19.766 6.66-28.242 8.193-11.492 27.045-11.699 35-.093 9.59 13.992 8.954 28.016.865 42.536-4.823 8.656-11.815 12.268-21.25 11.198-9.158-1.038-14.79-7.007-18.317-15.025-1.374-3.124-1.897-6.623-2.958-10.374z"/></svg>',
shutterstock: '<svg width="18" height="18" viewBox="0 0 192 192" xmlns="http://www.w3.org/2000/svg"><g fill="#f54335"><path d="M111.843 46.411H72.9c-6.193 0-11.223 5.03-11.223 11.197v42.247H23.279V57.608C23.279 30.197 45.482 8 72.907 8h38.943v38.411h-.007z"/><path d="M80.15 145.589h38.956c6.167 0 11.21-5.024 11.21-11.21V92.145h38.405v42.233c0 27.398-22.217 49.621-49.615 49.621H80.15v-38.41z"/></g></svg>',
// Official Social Logos
whatsapp: '<svg width="18" height="18" viewBox="0 0 24 24" fill="#25D366"><path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L0 24l6.335-1.662c1.72.94 3.659 1.437 5.634 1.437h.005c6.558 0 11.897-5.335 11.903-11.893a11.83 11.83 0 00-3.48-8.413Z"/></svg>',
twitter: '<svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231 5.451-6.231zm-1.161 17.52h1.833L7.084 4.126H5.117l11.966 15.644z"/></svg>',
facebook: '<svg width="18" height="18" viewBox="0 0 24 24" fill="#1877F2"><path d="M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"/></svg>',
telegram: '<svg width="18" height="18" viewBox="0 0 24 24" fill="#0088cc"><path d="M12 0C5.373 0 0 5.373 0 12s5.373 12 12 12 12-5.373 12-12S18.627 0 12 0zm5.894 8.221l-1.97 9.28c-.145.658-.537.818-1.084.508l-3-2.21-1.446 1.394c-.14.18-.357.295-.6.295-.002 0-.003 0-.005 0l.213-3.054 5.56-5.022c.24-.213-.054-.334-.373-.121l-6.869 4.326-2.96-.924c-.64-.203-.658-.64.135-.954l11.566-4.458c.538-.196 1.006.128.832.94z"/></svg>',
reddit: '<svg width="18" height="18" viewBox="0 0 24 24" fill="#FF4500"><path d="M24 11.5c0-1.65-1.35-3-3-3-.96 0-1.86.48-2.42 1.24-1.64-1-3.75-1.64-6.07-1.72.08-1.1.4-3.05 1.52-3.7.72-.4 1.73-.24 3 .5C17.2 6.3 18.46 7.5 20 7.5c1.65 0 3-1.35 3-3s-1.35-3-3-3c-1.38 0-2.54.94-2.88 2.22-1.43-.72-2.64-.8-3.6-.25-1.64.94-1.95 3.47-2 4.55-2.33.08-4.45.7-6.1 1.72C4.86 8.98 3.96 8.5 3 8.5c-1.65 0-3 1.35-3 3 0 1.32.84 2.44 2.05 2.84-.03.22-.05.44-.05.66 0 3.86 4.5 7 10 7s10-3.14 10-7c0-.22-.02-.44-.05-.66 1.2-.4 2.05-1.54 2.05-2.84zM2.3 13.37C1.5 13.07 1 12.35 1 11.5c0-1.1.9-2 2-2 .64 0 1.22.32 1.6.82-1.1.85-1.92 1.9-2.3 3.05zm3.7.13c0-1.1.9-2 2-2s2 .9 2 2-.9 2-2 2-2-.9-2-2zm9.8 4.8c-1.08.63-2.42.96-3.8.96-1.4 0-2.74-.34-3.8-.95-.24-.13-.32-.44-.2-.68.15-.24.46-.32.7-.18 1.83 1.06 4.76 1.06 6.6 0 .23-.13.53-.05.67.2.14.23.06.54-.18.68zm-3.8-3.6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm7.7-1.33c-.38-1.15-1.2-2.2-2.3-3.05.38-.5.96-.82 1.6-.82 1.1 0 2 .9 2 2 0 .84-.53 1.57-1.3 1.87z"/></svg>',
signal: '<svg width="18" height="18" viewBox="0 0 24 24" fill="#3A76F0" xmlns="http://www.w3.org/2000/svg"><path d="M12 0q-.934 0-1.83.139l.17 1.111a11 11 0 0 1 3.32 0l.172-1.111A12 12 0 0 0 12 0M9.152.34A12 12 0 0 0 5.77 1.742l.584.961a10.8 10.8 0 0 1 3.066-1.27zm5.696 0-.268 1.094a10.8 10.8 0 0 1 3.066 1.27l.584-.962A12 12 0 0 0 14.848.34M12 2.25a9.75 9.75 0 0 0-8.539 14.459c.074.134.1.292.064.441l-1.013 4.338 4.338-1.013a.62.62 0 0 1 .441.064A9.7 9.7 0 0 0 12 21.75c5.385 0 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25m-7.092.068a12 12 0 0 0-2.59 2.59l.909.664a11 11 0 0 1 2.345-2.345zm14.184 0-.664.909a11 11 0 0 1 2.345 2.345l.909-.664a12 12 0 0 0-2.59-2.59M1.742 5.77A12 12 0 0 0 .34 9.152l1.094.268a10.8 10.8 0 0 1 1.269-3.066zm20.516 0-.961.584a10.8 10.8 0 0 1 1.27 3.066l1.093-.268a12 12 0 0 0-1.402-3.383M.138 10.168A12 12 0 0 0 0 12q0 .934.139 1.83l1.111-.17A11 11 0 0 1 1.125 12q0-.848.125-1.66zm23.723.002-1.111.17q.125.812.125 1.66c0 .848-.042 1.12-.125 1.66l1.111.172a12.1 12.1 0 0 0 0-3.662M1.434 14.58l-1.094.268a12 12 0 0 0 .96 2.591l-.265 1.14 1.096.255.36-1.539-.188-.365a10.8 10.8 0 0 1-.87-2.35m21.133 0a10.8 10.8 0 0 1-1.27 3.067l.962.584a12 12 0 0 0 1.402-3.383zm-1.793 3.848a11 11 0 0 1-2.345 2.345l.664.909a12 12 0 0 0 2.59-2.59zm-19.959 1.1L.357 21.48a1.8 1.8 0 0 0 2.162 2.161l1.954-.455-.256-1.095-1.953.455a.675.675 0 0 1-.81-.81l.454-1.954zm16.832 1.769a10.8 10.8 0 0 1-3.066 1.27l.268 1.093a12 12 0 0 0 3.382-1.402zm-10.94.213-1.54.36.256 1.095 1.139-.266c.814.415 1.683.74 2.591.961l.268-1.094a10.8 10.8 0 0 1-2.35-.869zm3.634 1.24-.172 1.111a12.1 12.1 0 0 0 3.662 0l-.17-1.111q-.812.125-1.66.125a11 11 0 0 1-1.66-.125"/></svg>',
share: '<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="var(--primary)" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8"/><polyline points="16 6 12 2 8 6"/><line x1="12" y1="2" x2="12" y2="15"/></svg>'
};
const ALL_ITEMS = [
{ id: 'png', title: 'PNG', icon: 'image' },
{ id: 'jpeg', title: 'JPEG', icon: 'image' },
{ id: 'pdf', title: 'PDF', icon: 'image' },
{ id: 'avif', title: 'AVIF', icon: 'image' },
{ id: 'bmp', title: 'BMP', icon: 'image' },
{ id: 'gif', title: 'GIF', icon: 'image' },
{ id: 'tiff', title: 'TIFF', icon: 'image' },
{ id: 'ico', title: 'ICO', icon: 'image' },
{ id: 'webp', title: 'WebP', icon: 'image' },
{ id: 'searchGoogle', title: 'Google Lens', icon: 'google' },
{ id: 'searchLenso', title: 'Lenso.ai', icon: 'lenso' },
{ id: 'searchBing', title: 'Bing Visual Search', icon: 'bing' },
{ id: 'searchYandex', title: 'Yandex Images', icon: 'yandex' },
{ id: 'searchBaidu', title: 'Baidu Image', icon: 'baidu' },
{ id: 'searchSogou', title: 'Sogou Search', icon: 'sogou' },
{ id: 'searchTinEye', title: 'TinEye Reverse Search', icon: 'tineye' },
{ id: 'searchShutterstock', title: 'Shutterstock Search', icon: 'shutterstock' },
{ id: 'shareWhatsApp', title: 'WhatsApp', icon: 'whatsapp' },
{ id: 'shareTwitter', title: 'X (Twitter)', icon: 'twitter' },
{ id: 'shareNative', title: 'Windows Share', icon: 'share' },
{ id: 'shareTelegram', title: 'Telegram', icon: 'telegram' },
{ id: 'shareReddit', title: 'Reddit', icon: 'reddit' },
{ id: 'shareSignal', title: 'Signal', icon: 'signal' },
{ id: 'shareFacebook', title: 'Facebook', icon: 'facebook' },
{ id: 'shareBase64', title: 'Copy as Base64', icon: 'share' }
];
let currentOrder = [];
let currentEnabled = {};
let draggingItem = null;
// Navbar Theme toggle element listeners
const themeToggle = document.getElementById('theme-toggle');
themeToggle.onchange = (e) => {
const isDark = e.target.checked;
document.body.classList.toggle('dark', isDark);
elements.themeStatus.innerText = isDark ? 'Dark Mode Active' : 'Light Mode Active';
chrome.storage.sync.set({ theme: isDark ? 'dark' : 'light' });
};
// Load initial settings
chrome.storage.sync.get({
quality: 92,
prefix: '',
groupMenu: false,
subfolder: '',
theme: 'light',
menuOrder: ALL_ITEMS.map(i => i.id),
png: true, jpeg: true, webp: true, avif: true, bmp: true, gif: true, tiff: false, ico: false, pdf: true,
shareWhatsApp: true, shareTwitter: false, shareFacebook: false, shareTelegram: false, shareReddit: false, shareSignal: false, shareNative: true, shareBase64: true,
searchGoogle: true, searchLenso: true, searchBing: false, searchYandex: false,
searchBaidu: false, searchSogou: false, searchTinEye: false, searchShutterstock: false
}, (prefs) => {
elements.quality.value = prefs.quality;
elements.qualityVal.innerText = prefs.quality + '%';
elements.prefix.value = prefs.prefix;
elements.groupMenu.checked = prefs.groupMenu;
elements.subfolder.value = prefs.subfolder;
currentOrder = prefs.menuOrder;
// Ensure newly added items are included in the order
ALL_ITEMS.forEach(i => {
if (!currentOrder.includes(i.id)) {
currentOrder.push(i.id);
}
currentEnabled[i.id] = prefs[i.id];
});
const isDark = prefs.theme === 'dark';
document.body.classList.toggle('dark', isDark);
elements.themeStatus.innerText = isDark ? 'Dark Mode Active' : 'Light Mode Active';
themeToggle.checked = isDark;
renderOrderList();
});
function renderOrderList() {
elements.orderList.innerHTML = '';
currentOrder.forEach((id, index) => {
const item = ALL_ITEMS.find(i => i.id === id);
if (!item) return;
const div = document.createElement('div');
div.className = 'order-item';
div.draggable = true;
div.dataset.id = id;
div.innerHTML = `
<div class="drag-handle">
<svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="9" cy="12" r="1"/><circle cx="9" cy="5" r="1"/><circle cx="9" cy="19" r="1"/><circle cx="15" cy="12" r="1"/><circle cx="15" cy="5" r="1"/><circle cx="15" cy="19" r="1"/></svg>
</div>
<div class="icon">${icons[item.icon] || icons.image}</div>
<div style="flex: 1; font-weight: 600; opacity: ${currentEnabled[id] ? '1' : '0.5'};">${item.title}</div>
<div>
<label class="toggle" style="transform: scale(0.85); transform-origin: right center; margin-bottom: -4px;">
<input type="checkbox" class="item-toggle" data-id="${id}" ${currentEnabled[id] ? 'checked' : ''}>
<span class="slider"></span>
</label>
</div>
`;
const toggleInput = div.querySelector('.item-toggle');
toggleInput.addEventListener('change', (e) => {
currentEnabled[id] = e.target.checked;
autoSave();
// Update visual opacity immediately without full re-render
div.querySelector('div[style*="flex: 1"]').style.opacity = e.target.checked ? '1' : '0.5';
});
// Drag-and-drop event mechanics
div.addEventListener('dragstart', (e) => {
draggingItem = div;
// Small timeout so the native drag ghost doesn't become invisible
setTimeout(() => div.classList.add('dragging'), 0);
e.dataTransfer.effectAllowed = 'move';
});
div.addEventListener('dragend', () => {
div.classList.remove('dragging');
draggingItem = null;
// Update order and save
currentOrder = Array.from(elements.orderList.children).map(el => el.dataset.id);
autoSave();
});
elements.orderList.appendChild(div);
});
}
elements.orderList.addEventListener('dragover', (e) => {
e.preventDefault(); // Necessary to allow dropping
if (!draggingItem) return;
const afterElement = getDragAfterElement(elements.orderList, e.clientY);
// Check if position actually needs to change to avoid flickering
if (afterElement === draggingItem) return;
if (afterElement == null && elements.orderList.lastElementChild === draggingItem) return;
if (afterElement && draggingItem.nextElementSibling === afterElement) return;
// Record positions for FLIP animation
const children = Array.from(elements.orderList.children);
const firstRects = new Map(children.map(child => [child, child.getBoundingClientRect()]));
// Make DOM changes
if (afterElement == null) {
elements.orderList.appendChild(draggingItem);
} else {
elements.orderList.insertBefore(draggingItem, afterElement);
}
// Play FLIP animation to create the "magnetic" effect
children.forEach(child => {
if (child === draggingItem) return;
const first = firstRects.get(child);
const last = child.getBoundingClientRect();
const invertY = first.top - last.top;
if (invertY !== 0) {
child.style.transform = `translateY(${invertY}px)`;
child.style.transition = 'none';
requestAnimationFrame(() => {
child.style.transform = '';
child.style.transition = 'transform 0.3s cubic-bezier(0.2, 1, 0.2, 1)';
});
}
});
});
function getDragAfterElement(container, y) {
const draggableElements = [...container.querySelectorAll('.order-item:not(.dragging)')];
return draggableElements.reduce((closest, child) => {
const box = child.getBoundingClientRect();
const offset = y - box.top - box.height / 2;
if (offset < 0 && offset > closest.offset) {
return { offset: offset, element: child };
} else {
return closest;
}
}, { offset: Number.NEGATIVE_INFINITY }).element;
}
elements.quality.oninput = (e) => {
elements.qualityVal.innerText = e.target.value + '%';
autoSave();
};
// Listen for theme changes from other contexts
chrome.storage.onChanged.addListener((changes) => {
if (changes.theme) {
const isDark = changes.theme.newValue === 'dark';
document.body.classList.toggle('dark', isDark);
elements.themeStatus.innerText = isDark ? 'Dark Mode Active' : 'Light Mode Active';
themeToggle.checked = isDark;
}
});