Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
deanoemcke committed Jun 10, 2017
2 parents fa678cb + b118dba commit 7038e0a
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 36 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
**/Thumbs.db
**/*.pem
/node_modules
/build/crx/*.crx
/build/zip/*.zip
/build/*
/.idea/*
build/zip/thegreatsuspender-6.30-dev/welcome.html
2 changes: 1 addition & 1 deletion src/history.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h2>Saved sessions:</h2>

<br />
<br />
<a href="javascript:void(0);" id="clearHistory" class="btn">Clear tab history</a>
<a href="#" id="clearHistory" class="btn">Clear tab history</a>
</div>

</div>
Expand Down
26 changes: 21 additions & 5 deletions src/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,17 @@ var tgs = (function () {
});
}

function resuspendAllSuspendedTabs() {
chrome.tabs.query({}, function (tabs) {
tabs.forEach(function (currentTab) {
if (isSuspended(currentTab)) {
unsuspendRequestList[currentTab.id] = 'ignore';
chrome.tabs.reload(currentTab.id);
}
});
});
}

function queueSessionTimer() {
clearTimeout(sessionSaveTimer);
sessionSaveTimer = setTimeout(function() {
Expand Down Expand Up @@ -833,7 +844,7 @@ var tgs = (function () {

//Suspend present tab
contextMenuItems.push(chrome.contextMenus.create({
title: "Suspend Tab",
title: "Suspend tab",
contexts: allContexts,
onclick: suspendHighlightedTab
}));
Expand All @@ -854,14 +865,14 @@ var tgs = (function () {

//Suspend all the tabs
contextMenuItems.push(chrome.contextMenus.create({
title: "Suspend All Tabs",
title: "Suspend other tabs",
contexts: allContexts,
onclick: suspendAllTabs
}));

//Unsuspend all the tabs
contextMenuItems.push(chrome.contextMenus.create({
title: "Unsuspend All Tabs",
title: "Unsuspend all tabs",
contexts: allContexts,
onclick: unsuspendAllTabs
}));
Expand Down Expand Up @@ -945,7 +956,11 @@ var tgs = (function () {

case 'requestUnsuspendTab':
if (sender.tab && isSuspended(sender.tab)) {
unsuspendRequestList[sender.tab.id] = true;
if (unsuspendRequestList[sender.tab.id] === 'ignore') {
delete unsuspendRequestList[sender.tab.id];
} else {
unsuspendRequestList[sender.tab.id] = true;
}
}
break;

Expand Down Expand Up @@ -1136,7 +1151,8 @@ var tgs = (function () {
runStartupChecks: runStartupChecks,
resetAllTabTimers: resetAllTabTimers,
requestNotice: requestNotice,
buildContextMenu: buildContextMenu
buildContextMenu: buildContextMenu,
resuspendAllSuspendedTabs: resuspendAllSuspendedTabs
};

}());
Expand Down
6 changes: 5 additions & 1 deletion src/js/contentscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,15 @@
}
}, 30000);

//if preview quality is high then capture the whole screen
//check where we need to capture the whole screen
if (screenCapture === '2') {
height = Math.max(document.body.scrollHeight,
document.body.offsetHeight,
document.documentElement.clientHeight,
document.documentElement.scrollHeight,
document.documentElement.offsetHeight);
// cap the max height otherwise it fails to convert to a data url
height = Math.min(height, 10000);
} else {
height = Math.min(document.body.offsetHeight, window.innerHeight);
}
Expand All @@ -144,7 +146,9 @@
if (processing) {
processing = false;
timer = (new Date() - timer) / 1000;
console.log('canvas: ' + canvas);
var dataUrl = canvas.toDataURL('image/webp', 0.8);
console.log('dataUrl: ' + dataUrl);
chrome.runtime.sendMessage({
action: 'savePreviewData',
previewUrl: dataUrl,
Expand Down
35 changes: 28 additions & 7 deletions src/js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
};
}

function saveChange(element) {
function saveChange(element, updatedPreferences) {

var pref = elementPrefMap[element.id],
oldValue = gsUtils.getOption(pref),
Expand All @@ -161,26 +161,45 @@
//save option
gsUtils.setOption(elementPrefMap[element.id], newValue);

if (oldValue !== newValue) {
updatedPreferences.push(pref);
}
}

function performPostSaveUpdates(updatedPreferences) {

//if interval has changed then reset the tab timers
if (pref === gsUtils.SUSPEND_TIME && oldValue !== newValue) {
if (contains(updatedPreferences, gsUtils.SUSPEND_TIME)) {
chrome.extension.getBackgroundPage().tgs.resetAllTabTimers();
}

//if context menu has been disabled then remove from chrome
if (pref === gsUtils.ADD_CONTEXT) {
if (contains(updatedPreferences, gsUtils.ADD_CONTEXT)) {
chrome.extension.getBackgroundPage().tgs.buildContextMenu(newValue);
}

//if theme or preview settings have changed then refresh all suspended pages
if (contains(updatedPreferences, gsUtils.THEME) ||
contains(updatedPreferences, gsUtils.SCREEN_CAPTURE)) {
chrome.extension.getBackgroundPage().tgs.resuspendAllSuspendedTabs();
}
}

function contains(array, value) {
for (var i = 0; i < array.length; i++) {
if (array[i] == value) return true;
}
return false;
}

function closeSettings() {
//only close the window if we were opened in a new tab.
//else, go back to the page we were on.
//this is to fix closing tabs if they were opened from the context menu.
if (document.referrer === "") {
window.close();
} else {
if (window.history.length > 1) {
history.back();
} else {
window.close();
}
}

Expand All @@ -204,9 +223,11 @@
element.onchange = handleChange(element);
}
saveEl.onclick = function (e) {
var updatedPreferences = [];
for (i = 0; i < optionEls.length; i++) {
saveChange(optionEls[i]);
saveChange(optionEls[i], updatedPreferences);
}
performPostSaveUpdates(updatedPreferences);
closeSettings();
};
cancelEl.onclick = function (e) {
Expand Down
1 change: 1 addition & 0 deletions src/js/suspended.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ chrome.tabs.getCurrent(function(tab) {

function hideNagForever() {
gsUtils.setOption(gsUtils.NO_NAG, true);
chrome.extension.getBackgroundPage().tgs.resuspendAllSuspendedTabs();
document.getElementById('dudePopup').style.display = 'none';
document.getElementById('donateBubble').style.display = 'none';
}
Expand Down
4 changes: 2 additions & 2 deletions src/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ <h2>Whitelist&nbsp;

<hr />

<a href="javascript:void(0)" id="cancelBtn" class="fl btn btnNeg">Cancel</a>
<a href="javascript:void(0)" id="saveBtn" class="fr btn">Save settings</a>
<a href="#" id="cancelBtn" class="fl btn btnNeg">Cancel</a>
<a href="#" id="saveBtn" class="fr btn">Save settings</a>

</div>

Expand Down
18 changes: 0 additions & 18 deletions src/update.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,6 @@ <h1>The Great Suspender has been updated</h1>

<hr class="splashRule" />

<h2>Bugs squashed</h2>
<p>This new version fixes the bug caused by the new chrome release that caused tabs to change the the wrong url when they were suspended.
Sorry for such a terrible bug and that the fix was a long time coming.</p>
<p>The 'suspend other tabs' option will now NOT suspend the currently active tab.</p>
<p>Browsing in incognito mode will no longer bring up the welcome tab every time.</p>

<h2>What's new?</h2>
<p>This version includes light and dark themes. Try switching to the dark theme when using chrome at night to go easy on your eyes.</p>
<p>The extension now supports actions on multiple selected tabs. If you select multiple tabs in chrome, you will have some new options appear
in the pop-up menu to allow you to suspend / unsuspend all selected tabs</p>
<p>The new improved whitelist now supports regular expressions. For the programming-minded only!</p>
<p>You can check it all out in the <a href='/options.html' target='_blank'>settings</a> page.</p>

<h2>Problems with the update?</h2>
<p>If you are experiencing a loss of tabs due to this update, try going to the <a href='/history.html' target='_blank'>session management</a> page. You will find a list of all your recently suspended tabs and should be able to recover them from here.</p>

<p>If losing your tabs has made you extremely upset and you want to uninstall this extension: fair enough - but before you do, please go through the session recovery process first and make sure all your tabs are recovered and unsuspended before you uninstall.</p>

<p>Thanks for using <strong>The Great Suspender!</strong></p>

</div>
Expand Down

0 comments on commit 7038e0a

Please sign in to comment.