From c4f18e84a40e3f8a6d42bedd46410c96d33c6b63 Mon Sep 17 00:00:00 2001 From: Dean Oemcke Date: Sat, 26 Mar 2016 15:52:31 -0400 Subject: [PATCH 1/4] Changing theme or donating now updates all affected tabs. --- src/js/background.js | 26 +++++++++++++++++++++----- src/js/options.js | 35 ++++++++++++++++++++++++++++------- src/js/suspended.js | 1 + 3 files changed, 50 insertions(+), 12 deletions(-) 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/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'; } From ed7068b37b334220d1e2b75cde3c27970478d231 Mon Sep 17 00:00:00 2001 From: deanoemcke Date: Thu, 1 Jun 2017 10:56:28 -0400 Subject: [PATCH 2/4] Clean up js on button presses --- src/history.html | 2 +- src/options.html | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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/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 From 57747b0f517790a5d52e0e1e4124b0e7d0fc0016 Mon Sep 17 00:00:00 2001 From: deanoemcke Date: Thu, 1 Jun 2017 10:57:01 -0400 Subject: [PATCH 3/4] Fix bug when trying to capture very long page --- src/js/contentscript.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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, From b118dbad2eb3d47b1a63bfe9116102020f500f2f Mon Sep 17 00:00:00 2001 From: deanoemcke Date: Sat, 10 Jun 2017 01:29:58 -0400 Subject: [PATCH 4/4] Remove contents of update page --- .gitignore | 5 +++-- src/update.html | 18 ------------------ 2 files changed, 3 insertions(+), 20 deletions(-) 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/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!