Skip to content

Commit 1921029

Browse files
committed
tab preview frame working
1 parent fbd8e27 commit 1921029

File tree

12 files changed

+479
-31
lines changed

12 files changed

+479
-31
lines changed

package-lock.json

Lines changed: 87 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
"@hot-loader/react-dom": "^17.0.1",
1818
"classnames": "^2.3.1",
1919
"clipboard-copy": "^4.0.1",
20+
"detect-browser": "^5.2.1",
2021
"glamor": "^2.20.40",
22+
"image-to-base64": "^2.2.0",
2123
"immutability-helper": "^3.1.1",
2224
"jquery": "^3.6.0",
2325
"lodash": "^4.17.21",

src/components/Logo/Logo.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const logo = (props) => {
1313
let src = AppLogo;
1414

1515
if (window.chrome !== undefined && chrome.extension !== undefined) {
16-
src = chrome.extension.getURL('icon-128.png');
16+
src = chrome.runtime.getURL('icon-128.png');
1717
}
1818

1919
return (

src/pages/Background/index.js

Lines changed: 57 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ chrome.storage.local.get(['sidebarOpen'], (result) => {
2020
const changeBrowserIconBadgeWithSidebarOpenStatus = (status) => {
2121
if (status) {
2222
chrome.browserAction.setIcon({
23-
path: chrome.extension.getURL('icon-128-eye.png'),
23+
path: chrome.runtime.getURL('icon-128-eye.png'),
2424
});
2525
} else {
2626
chrome.browserAction.setIcon({
27-
path: chrome.extension.getURL('icon-128.png'),
27+
path: chrome.runtime.getURL('icon-128.png'),
2828
});
2929
}
3030
};
@@ -92,6 +92,25 @@ const persistdisplayTabInFullStatus = (status) => {
9292
});
9393
};
9494

95+
/**
96+
* Display Tab Preview Frame
97+
*/
98+
let displayTabPreviewFrame = true;
99+
100+
chrome.storage.sync.get(['displayTabPreviewFrame'], (result) => {
101+
if (result.displayTabPreviewFrame !== undefined) {
102+
displayTabPreviewFrame = result.displayTabPreviewFrame === true;
103+
} else {
104+
persistdisplayTabPreviewFrameStatus(true); // default to display tab in full
105+
}
106+
});
107+
108+
const persistdisplayTabPreviewFrameStatus = (status) => {
109+
chrome.storage.sync.set({
110+
displayTabPreviewFrame: status,
111+
});
112+
};
113+
95114
/**
96115
* Auto Show Hide
97116
*/
@@ -159,7 +178,7 @@ const toggleSidebar = (toStatus = null) => {
159178
{
160179
currentWindow: true,
161180
},
162-
function(tabs) {
181+
function (tabs) {
163182
tabs.forEach((tab) => {
164183
chrome.tabs.sendMessage(tab.id, {
165184
from: 'background',
@@ -176,7 +195,7 @@ const updateSidebarWidth = (width) => {
176195
{
177196
currentWindow: true,
178197
},
179-
function(tabs) {
198+
function (tabs) {
180199
tabs.forEach((tab) => {
181200
chrome.tabs.sendMessage(tab.id, {
182201
from: 'background',
@@ -193,7 +212,7 @@ const updateSidebarScrollPosition = () => {
193212
{
194213
currentWindow: true,
195214
},
196-
function(tabs) {
215+
function (tabs) {
197216
tabs.forEach((tab) => {
198217
chrome.tabs.sendMessage(tab.id, {
199218
from: 'background',
@@ -211,7 +230,7 @@ const updateSidebarOnLeftStatus = (toStatus) => {
211230
{
212231
currentWindow: true,
213232
},
214-
function(tabs) {
233+
function (tabs) {
215234
tabs.forEach((tab) => {
216235
chrome.tabs.sendMessage(tab.id, {
217236
from: 'background',
@@ -228,7 +247,7 @@ const updateShouldShrinkBodyStatus = (toStatus) => {
228247
{
229248
currentWindow: true,
230249
},
231-
function(tabs) {
250+
function (tabs) {
232251
tabs.forEach((tab) => {
233252
chrome.tabs.sendMessage(tab.id, {
234253
from: 'background',
@@ -245,7 +264,7 @@ const updateDisplayTabInFullStatus = (toStatus) => {
245264
{
246265
currentWindow: true,
247266
},
248-
function(tabs) {
267+
function (tabs) {
249268
tabs.forEach((tab) => {
250269
chrome.tabs.sendMessage(tab.id, {
251270
from: 'background',
@@ -257,12 +276,29 @@ const updateDisplayTabInFullStatus = (toStatus) => {
257276
);
258277
};
259278

279+
const updateDisplayTabPreviewFrameStatus = (toStatus) => {
280+
chrome.tabs.query(
281+
{
282+
currentWindow: true,
283+
},
284+
function (tabs) {
285+
tabs.forEach((tab) => {
286+
chrome.tabs.sendMessage(tab.id, {
287+
from: 'background',
288+
msg: 'UPDATE_DISPLAY_TAB_PREVIEW_FRAME_STATUS',
289+
toStatus,
290+
});
291+
});
292+
}
293+
);
294+
};
295+
260296
const updateAutoShowHideStatus = (toStatus) => {
261297
chrome.tabs.query(
262298
{
263299
currentWindow: true,
264300
},
265-
function(tabs) {
301+
function (tabs) {
266302
tabs.forEach((tab) => {
267303
chrome.tabs.sendMessage(tab.id, {
268304
from: 'background',
@@ -279,7 +315,7 @@ const updateAutoShowHideDelayStatus = (toStatus) => {
279315
{
280316
currentWindow: true,
281317
},
282-
function(tabs) {
318+
function (tabs) {
283319
tabs.forEach((tab) => {
284320
chrome.tabs.sendMessage(tab.id, {
285321
from: 'background',
@@ -296,7 +332,7 @@ const updateDarkModeStatus = (toStatus) => {
296332
{
297333
currentWindow: true,
298334
},
299-
function(tabs) {
335+
function (tabs) {
300336
tabs.forEach((tab) => {
301337
chrome.tabs.sendMessage(tab.id, {
302338
from: 'background',
@@ -309,7 +345,7 @@ const updateDarkModeStatus = (toStatus) => {
309345
};
310346

311347
// chrome.browserAction.setPopup({
312-
// popup: chrome.extension.getURL('sidebar.html'),
348+
// popup: chrome.runtime.getURL('sidebar.html'),
313349
// });
314350

315351
// setTimeout(() => {
@@ -324,7 +360,7 @@ chrome.browserAction.onClicked.addListener((senderTab) => {
324360
toggleSidebar();
325361
});
326362

327-
chrome.commands.onCommand.addListener(function(command) {
363+
chrome.commands.onCommand.addListener(function (command) {
328364
if (command === '_execute_browser_action') {
329365
toggleSidebar();
330366
}
@@ -386,6 +422,14 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
386422
displayTabInFull = toStatus;
387423
persistdisplayTabInFullStatus(displayTabInFull);
388424
updateDisplayTabInFullStatus(displayTabInFull);
425+
} else if (
426+
request.from === 'settings' &&
427+
request.msg === 'USER_CHANGE_DISPLAY_TAB_PREVIEW_FRAME'
428+
) {
429+
const { toStatus } = request;
430+
displayTabPreviewFrame = toStatus;
431+
persistdisplayTabPreviewFrameStatus(displayTabPreviewFrame);
432+
updateDisplayTabPreviewFrameStatus(displayTabPreviewFrame);
389433
} else if (
390434
request.from === 'settings' &&
391435
request.msg === 'USER_CHANGE_AUTO_SHOW_HIDE'

0 commit comments

Comments
 (0)