diff --git a/.gitignore b/.gitignore index 10598af6..af1a56fb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ **/Thumbs.db **/*.pem /node_modules -/build/crx/*.crx -/build/zip/*.zip \ No newline at end of file +/build/* +/.idea/* +build/zip/thegreatsuspender-6.30-dev/welcome.html diff --git a/src/history.html b/src/history.html index 135d5e37..657409d7 100644 --- a/src/history.html +++ b/src/history.html @@ -34,7 +34,7 @@

Saved sessions:



- Clear tab history + Clear tab history diff --git a/src/js/background.js b/src/js/background.js index 3e3f3d34..18efcb01 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -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() { @@ -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 })); @@ -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 })); @@ -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; @@ -1136,7 +1151,8 @@ var tgs = (function () { runStartupChecks: runStartupChecks, resetAllTabTimers: resetAllTabTimers, requestNotice: requestNotice, - buildContextMenu: buildContextMenu + buildContextMenu: buildContextMenu, + resuspendAllSuspendedTabs: resuspendAllSuspendedTabs }; }()); diff --git a/src/js/contentscript.js b/src/js/contentscript.js index 3c6b7a63..d4878ada 100644 --- a/src/js/contentscript.js +++ b/src/js/contentscript.js @@ -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); } @@ -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, diff --git a/src/js/options.js b/src/js/options.js index 6ee54729..4db13383 100644 --- a/src/js/options.js +++ b/src/js/options.js @@ -147,7 +147,7 @@ }; } - function saveChange(element) { + function saveChange(element, updatedPreferences) { var pref = elementPrefMap[element.id], oldValue = gsUtils.getOption(pref), @@ -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(); } } @@ -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) { diff --git a/src/js/suspended.js b/src/js/suspended.js index 1bf2036d..03352c1f 100644 --- a/src/js/suspended.js +++ b/src/js/suspended.js @@ -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'; } diff --git a/src/options.html b/src/options.html index c6293eb9..970f1e27 100644 --- a/src/options.html +++ b/src/options.html @@ -122,8 +122,8 @@

Whitelist 
- Cancel - Save settings + Cancel + Save settings diff --git a/src/update.html b/src/update.html index e0a12ad3..7901ea3b 100644 --- a/src/update.html +++ b/src/update.html @@ -17,24 +17,6 @@

The Great Suspender has been updated


-

Bugs squashed

-

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.

-

The 'suspend other tabs' option will now NOT suspend the currently active tab.

-

Browsing in incognito mode will no longer bring up the welcome tab every time.

- -

What's new?

-

This version includes light and dark themes. Try switching to the dark theme when using chrome at night to go easy on your eyes.

-

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

-

The new improved whitelist now supports regular expressions. For the programming-minded only!

-

You can check it all out in the settings page.

- -

Problems with the update?

-

If you are experiencing a loss of tabs due to this update, try going to the session management page. You will find a list of all your recently suspended tabs and should be able to recover them from here.

- -

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.

-

Thanks for using The Great Suspender!