Skip to content

Commit c1171b3

Browse files
committed
edit repeated tabs
1 parent 195345e commit c1171b3

File tree

7 files changed

+23
-20
lines changed

7 files changed

+23
-20
lines changed

html/nap-room.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
</div>
1818
<div tabindex="0" data-hover="Settings" class="settings"><img src="../icons/settings.png"></div>
1919
<div class="changelog-overlay">
20-
<div id="changelog"><!-- <div id="changelog" class="disabled"> -->
20+
<div id="changelog">
21+
<!-- <div id="changelog" class="disabled"> -->
2122
<div class="changelog-container">
2223
<h2 class="center">Snoozz has been updated <span id="v"></span>&nbsp;🎉</h2>
2324
<p>This version is a huge update that brings in one of the most requested features.</p>

html/rise-and-shine.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<div class="tab-list"></div>
3333
</div>
3434

35+
<script type="text/javascript" src="../scripts/gradient.min.js"></script>
3536
<script type="text/javascript" src="../scripts/dayjs.min.js"></script>
3637
<script type="text/javascript" src="../scripts/common.js"></script>
3738
<script type="text/javascript" src="../scripts/rise.js"></script>

html/settings.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ <h4>Custom Keyboard Shortcuts</h4>
233233
<div tabindex="0" class="btn"><div></div></div>
234234
<div class="mini firefox-info">
235235
<strong>Instructions</strong>
236-
<div>Firefox shortcuts can only be configured on a different page, outside of this extension. To configure your custom shortcuts:</div>
236+
<div>Firefox shortcuts can only be <a target="_blank" href="https://support.mozilla.org/en-US/kb/manage-extension-shortcuts-firefox">configured</a> on a different page, outside of this extension. To configure your custom shortcuts:</div>
237237
<ol>
238238
<li>Open the Firefox Add-Ons page in a new tab: <u><code>about:addons</code></u> (Click URL to copy).</li>
239239
<li>Click on the <a tabindex="0" target="_blank" href="https://bug1303384.bmoattachments.org/attachment.cgi?id=9051647">gear icon</a> in the top right and select <strong>Manage Extension Shortcuts</strong>.</li>

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "Snoozz - Snooze Tabs & Windows for later",
33
"short_name": "Snoozz",
44
"description": "Declutter your browser by snoozing tabs and windows until you actually need them.",
5-
"version": "2.4.4.3",
5+
"version": "2.5.0",
66

77
"icons": {
88
"128": "icons/ext-icon-128.png",

scripts/background.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ async function wakeUpTask(cachedTabs) {
5858

5959
var debounce;
6060
async function setNextAlarm(tabs) {
61-
var next = sleeping(tabs).filter(t => t.wakeUpTime && !t.paused).reduce((t1,t2) => t1.wakeUpTime < t2.wakeUpTime ? t1 : t2);
62-
if (next && next.wakeUpTime <= dayjs().valueOf()) {
61+
var next = sleeping(tabs).filter(t => t.wakeUpTime && !t.paused);
62+
next = next.length ? next.reduce((t1,t2) => t1.wakeUpTime < t2.wakeUpTime ? t1 : t2) : undefined;
63+
if (!next) return;
64+
if (next.wakeUpTime <= dayjs().valueOf()) {
6365
clearTimeout(debounce)
6466
debounce = setTimeout(_ => wakeMeUp(tabs), 3000)
6567
} else {

scripts/common.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ async function snoozeTab(snoozeTime, overrideTab) {
224224
if (!activeTab || !activeTab.url) return {};
225225
var sleepyTab = {
226226
id: getRandomId(),
227-
title: activeTab.title ?? getBetterUrl(activeTab.url),
227+
title: activeTab.title || getBetterUrl(activeTab.url),
228228
url: activeTab.url,
229229
...activeTab.pinned ? {pinned: true} : {},
230230
wakeUpTime: snoozeTime === 'startup' ? dayjs().add(20, 'y').valueOf() : dayjs(snoozeTime).valueOf(),
@@ -297,7 +297,7 @@ async function snoozeRecurring(target, data) {
297297
var activeTab = validTabs && validTabs.length ? validTabs[0] : await getTabsInWindow(true);
298298
if (!activeTab || !activeTab.url) return {};
299299
Object.assign(sleepyObj, {
300-
title: activeTab.title ?? getBetterUrl(activeTab.url),
300+
title: activeTab.title || getBetterUrl(activeTab.url),
301301
url: activeTab.url,
302302
...activeTab.pinned ? {pinned: true} : {},
303303
});
@@ -325,7 +325,7 @@ async function getTimeWithModifier(choice) {
325325
var options = await getOptions(['morning', 'evening', 'popup']);
326326
var modifier = options.popup ? options.popup[choice] : '';
327327
options = upgradeSettings(options);
328-
var m = options[modifier] ?? [dayjs().hour(), dayjs().minute()];
328+
var m = options[modifier] || [dayjs().hour(), dayjs().minute()];
329329
return dayjs(c.time).add(m[0], 'h').add(m[1], 'm');
330330
}
331331

@@ -445,7 +445,6 @@ async function getChoices(which) {
445445
}
446446

447447
async function calculateNextSnoozeTime(data) {
448-
console.log(data);
449448
var NOW = dayjs(), TYPE = data.type, [HOUR, MINUTE] = data.time;
450449
if (TYPE === 'hourly') {
451450
var isNextHour = NOW.minute() >= MINUTE ? 1 : 0;
@@ -650,7 +649,7 @@ var bgLog = (logs, colors, timestampColor = 'grey') => {
650649
colors.unshift(timestampColor);
651650
colors = colors.flatMap((v,i,a)=>i !== a.length ? [v, ''] : v).map(c => {
652651
var colors = {green:'limegreen', red:'crimson', blue:'dodgerblue', yellow:'gold', pink:'violet', grey:'slategrey', white: 'navajowhite'}
653-
return 'color:' + (colors[c] ?? 'unset')
652+
return 'color:' + (colors[c] || 'unset')
654653
})
655654
console.log(timestamp + logs, ...colors)
656655
}

scripts/popup.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,6 @@ async function modify(time, choice) {
480480

481481
async function snooze(time, choice) {
482482
time = ['weekend', 'monday', 'week', 'month'].includes(choice.id) ? await getTimeWithModifier(choice.id) : time;
483-
if (isInEditMode || isInDupeMode) return modify(time, choice);
484483
var response, target = document.querySelector('.target.active');
485484
if (!['tab', 'window', 'selection', 'group'].includes(target.id)) return;
486485

@@ -502,16 +501,17 @@ async function snooze(time, choice) {
502501
data.monthly = document.getElementById('monthly')._flatpickr.selectedDates.map(d => dayjs(d).date()).sort(desc);
503502
}
504503
}
505-
response = await snoozeRecurring(target.id, data);
504+
return response = await snoozeRecurring(target.id, data);
506505
// response = await snoozeRecurring(target.id, time, repeat, data);
507-
} else {
508-
if (target.id === 'tab') {
509-
response = await snoozeTab(time);
510-
} else if (target.id === 'window') {
511-
response = await snoozeWindow(time);
512-
} else if (target.id === 'selection') {
513-
response = await snoozeWindow(time, true);
514-
}
506+
}
507+
if (isInEditMode || isInDupeMode) {
508+
return modify(time, choice);
509+
} else if (target.id === 'tab') {
510+
response = await snoozeTab(time);
511+
} else if (target.id === 'window') {
512+
response = await snoozeWindow(time);
513+
} else if (target.id === 'selection') {
514+
response = await snoozeWindow(time, true);
515515
}
516516
if (!response || (!response.tabId && !response.windowId)) return;
517517
await chrome.runtime.sendMessage(Object.assign(response, {close: true, delay: closeDelay}));

0 commit comments

Comments
 (0)