Skip to content

Commit

Permalink
edit repeated tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
rohanb10 committed Oct 5, 2021
1 parent 195345e commit c1171b3
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 20 deletions.
3 changes: 2 additions & 1 deletion html/nap-room.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
</div>
<div tabindex="0" data-hover="Settings" class="settings"><img src="../icons/settings.png"></div>
<div class="changelog-overlay">
<div id="changelog"><!-- <div id="changelog" class="disabled"> -->
<div id="changelog">
<!-- <div id="changelog" class="disabled"> -->
<div class="changelog-container">
<h2 class="center">Snoozz has been updated <span id="v"></span>&nbsp;🎉</h2>
<p>This version is a huge update that brings in one of the most requested features.</p>
Expand Down
1 change: 1 addition & 0 deletions html/rise-and-shine.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<div class="tab-list"></div>
</div>

<script type="text/javascript" src="../scripts/gradient.min.js"></script>
<script type="text/javascript" src="../scripts/dayjs.min.js"></script>
<script type="text/javascript" src="../scripts/common.js"></script>
<script type="text/javascript" src="../scripts/rise.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion html/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ <h4>Custom Keyboard Shortcuts</h4>
<div tabindex="0" class="btn"><div></div></div>
<div class="mini firefox-info">
<strong>Instructions</strong>
<div>Firefox shortcuts can only be configured on a different page, outside of this extension. To configure your custom shortcuts:</div>
<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>
<ol>
<li>Open the Firefox Add-Ons page in a new tab: <u><code>about:addons</code></u> (Click URL to copy).</li>
<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>
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Snoozz - Snooze Tabs & Windows for later",
"short_name": "Snoozz",
"description": "Declutter your browser by snoozing tabs and windows until you actually need them.",
"version": "2.4.4.3",
"version": "2.5.0",

"icons": {
"128": "icons/ext-icon-128.png",
Expand Down
6 changes: 4 additions & 2 deletions scripts/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ async function wakeUpTask(cachedTabs) {

var debounce;
async function setNextAlarm(tabs) {
var next = sleeping(tabs).filter(t => t.wakeUpTime && !t.paused).reduce((t1,t2) => t1.wakeUpTime < t2.wakeUpTime ? t1 : t2);
if (next && next.wakeUpTime <= dayjs().valueOf()) {
var next = sleeping(tabs).filter(t => t.wakeUpTime && !t.paused);
next = next.length ? next.reduce((t1,t2) => t1.wakeUpTime < t2.wakeUpTime ? t1 : t2) : undefined;
if (!next) return;
if (next.wakeUpTime <= dayjs().valueOf()) {
clearTimeout(debounce)
debounce = setTimeout(_ => wakeMeUp(tabs), 3000)
} else {
Expand Down
9 changes: 4 additions & 5 deletions scripts/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ async function snoozeTab(snoozeTime, overrideTab) {
if (!activeTab || !activeTab.url) return {};
var sleepyTab = {
id: getRandomId(),
title: activeTab.title ?? getBetterUrl(activeTab.url),
title: activeTab.title || getBetterUrl(activeTab.url),
url: activeTab.url,
...activeTab.pinned ? {pinned: true} : {},
wakeUpTime: snoozeTime === 'startup' ? dayjs().add(20, 'y').valueOf() : dayjs(snoozeTime).valueOf(),
Expand Down Expand Up @@ -297,7 +297,7 @@ async function snoozeRecurring(target, data) {
var activeTab = validTabs && validTabs.length ? validTabs[0] : await getTabsInWindow(true);
if (!activeTab || !activeTab.url) return {};
Object.assign(sleepyObj, {
title: activeTab.title ?? getBetterUrl(activeTab.url),
title: activeTab.title || getBetterUrl(activeTab.url),
url: activeTab.url,
...activeTab.pinned ? {pinned: true} : {},
});
Expand Down Expand Up @@ -325,7 +325,7 @@ async function getTimeWithModifier(choice) {
var options = await getOptions(['morning', 'evening', 'popup']);
var modifier = options.popup ? options.popup[choice] : '';
options = upgradeSettings(options);
var m = options[modifier] ?? [dayjs().hour(), dayjs().minute()];
var m = options[modifier] || [dayjs().hour(), dayjs().minute()];
return dayjs(c.time).add(m[0], 'h').add(m[1], 'm');
}

Expand Down Expand Up @@ -445,7 +445,6 @@ async function getChoices(which) {
}

async function calculateNextSnoozeTime(data) {
console.log(data);
var NOW = dayjs(), TYPE = data.type, [HOUR, MINUTE] = data.time;
if (TYPE === 'hourly') {
var isNextHour = NOW.minute() >= MINUTE ? 1 : 0;
Expand Down Expand Up @@ -650,7 +649,7 @@ var bgLog = (logs, colors, timestampColor = 'grey') => {
colors.unshift(timestampColor);
colors = colors.flatMap((v,i,a)=>i !== a.length ? [v, ''] : v).map(c => {
var colors = {green:'limegreen', red:'crimson', blue:'dodgerblue', yellow:'gold', pink:'violet', grey:'slategrey', white: 'navajowhite'}
return 'color:' + (colors[c] ?? 'unset')
return 'color:' + (colors[c] || 'unset')
})
console.log(timestamp + logs, ...colors)
}
Expand Down
20 changes: 10 additions & 10 deletions scripts/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,6 @@ async function modify(time, choice) {

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

Expand All @@ -502,16 +501,17 @@ async function snooze(time, choice) {
data.monthly = document.getElementById('monthly')._flatpickr.selectedDates.map(d => dayjs(d).date()).sort(desc);
}
}
response = await snoozeRecurring(target.id, data);
return response = await snoozeRecurring(target.id, data);
// response = await snoozeRecurring(target.id, time, repeat, data);
} else {
if (target.id === 'tab') {
response = await snoozeTab(time);
} else if (target.id === 'window') {
response = await snoozeWindow(time);
} else if (target.id === 'selection') {
response = await snoozeWindow(time, true);
}
}
if (isInEditMode || isInDupeMode) {
return modify(time, choice);
} else if (target.id === 'tab') {
response = await snoozeTab(time);
} else if (target.id === 'window') {
response = await snoozeWindow(time);
} else if (target.id === 'selection') {
response = await snoozeWindow(time, true);
}
if (!response || (!response.tabId && !response.windowId)) return;
await chrome.runtime.sendMessage(Object.assign(response, {close: true, delay: closeDelay}));
Expand Down

0 comments on commit c1171b3

Please sign in to comment.