Skip to content

Commit 7038e0a

Browse files
committed
Merge branch 'develop'
2 parents fa678cb + b118dba commit 7038e0a

8 files changed

+61
-36
lines changed

.gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
**/Thumbs.db
22
**/*.pem
33
/node_modules
4-
/build/crx/*.crx
5-
/build/zip/*.zip
4+
/build/*
5+
/.idea/*
6+
build/zip/thegreatsuspender-6.30-dev/welcome.html

src/history.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ <h2>Saved sessions:</h2>
3434

3535
<br />
3636
<br />
37-
<a href="javascript:void(0);" id="clearHistory" class="btn">Clear tab history</a>
37+
<a href="#" id="clearHistory" class="btn">Clear tab history</a>
3838
</div>
3939

4040
</div>

src/js/background.js

+21-5
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,17 @@ var tgs = (function () {
328328
});
329329
}
330330

331+
function resuspendAllSuspendedTabs() {
332+
chrome.tabs.query({}, function (tabs) {
333+
tabs.forEach(function (currentTab) {
334+
if (isSuspended(currentTab)) {
335+
unsuspendRequestList[currentTab.id] = 'ignore';
336+
chrome.tabs.reload(currentTab.id);
337+
}
338+
});
339+
});
340+
}
341+
331342
function queueSessionTimer() {
332343
clearTimeout(sessionSaveTimer);
333344
sessionSaveTimer = setTimeout(function() {
@@ -833,7 +844,7 @@ var tgs = (function () {
833844

834845
//Suspend present tab
835846
contextMenuItems.push(chrome.contextMenus.create({
836-
title: "Suspend Tab",
847+
title: "Suspend tab",
837848
contexts: allContexts,
838849
onclick: suspendHighlightedTab
839850
}));
@@ -854,14 +865,14 @@ var tgs = (function () {
854865

855866
//Suspend all the tabs
856867
contextMenuItems.push(chrome.contextMenus.create({
857-
title: "Suspend All Tabs",
868+
title: "Suspend other tabs",
858869
contexts: allContexts,
859870
onclick: suspendAllTabs
860871
}));
861872

862873
//Unsuspend all the tabs
863874
contextMenuItems.push(chrome.contextMenus.create({
864-
title: "Unsuspend All Tabs",
875+
title: "Unsuspend all tabs",
865876
contexts: allContexts,
866877
onclick: unsuspendAllTabs
867878
}));
@@ -945,7 +956,11 @@ var tgs = (function () {
945956

946957
case 'requestUnsuspendTab':
947958
if (sender.tab && isSuspended(sender.tab)) {
948-
unsuspendRequestList[sender.tab.id] = true;
959+
if (unsuspendRequestList[sender.tab.id] === 'ignore') {
960+
delete unsuspendRequestList[sender.tab.id];
961+
} else {
962+
unsuspendRequestList[sender.tab.id] = true;
963+
}
949964
}
950965
break;
951966

@@ -1136,7 +1151,8 @@ var tgs = (function () {
11361151
runStartupChecks: runStartupChecks,
11371152
resetAllTabTimers: resetAllTabTimers,
11381153
requestNotice: requestNotice,
1139-
buildContextMenu: buildContextMenu
1154+
buildContextMenu: buildContextMenu,
1155+
resuspendAllSuspendedTabs: resuspendAllSuspendedTabs
11401156
};
11411157

11421158
}());

src/js/contentscript.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,15 @@
125125
}
126126
}, 30000);
127127

128-
//if preview quality is high then capture the whole screen
128+
//check where we need to capture the whole screen
129129
if (screenCapture === '2') {
130130
height = Math.max(document.body.scrollHeight,
131131
document.body.offsetHeight,
132132
document.documentElement.clientHeight,
133133
document.documentElement.scrollHeight,
134134
document.documentElement.offsetHeight);
135+
// cap the max height otherwise it fails to convert to a data url
136+
height = Math.min(height, 10000);
135137
} else {
136138
height = Math.min(document.body.offsetHeight, window.innerHeight);
137139
}
@@ -144,7 +146,9 @@
144146
if (processing) {
145147
processing = false;
146148
timer = (new Date() - timer) / 1000;
149+
console.log('canvas: ' + canvas);
147150
var dataUrl = canvas.toDataURL('image/webp', 0.8);
151+
console.log('dataUrl: ' + dataUrl);
148152
chrome.runtime.sendMessage({
149153
action: 'savePreviewData',
150154
previewUrl: dataUrl,

src/js/options.js

+28-7
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147
};
148148
}
149149

150-
function saveChange(element) {
150+
function saveChange(element, updatedPreferences) {
151151

152152
var pref = elementPrefMap[element.id],
153153
oldValue = gsUtils.getOption(pref),
@@ -161,26 +161,45 @@
161161
//save option
162162
gsUtils.setOption(elementPrefMap[element.id], newValue);
163163

164+
if (oldValue !== newValue) {
165+
updatedPreferences.push(pref);
166+
}
167+
}
168+
169+
function performPostSaveUpdates(updatedPreferences) {
164170

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

170176
//if context menu has been disabled then remove from chrome
171-
if (pref === gsUtils.ADD_CONTEXT) {
177+
if (contains(updatedPreferences, gsUtils.ADD_CONTEXT)) {
172178
chrome.extension.getBackgroundPage().tgs.buildContextMenu(newValue);
173179
}
180+
181+
//if theme or preview settings have changed then refresh all suspended pages
182+
if (contains(updatedPreferences, gsUtils.THEME) ||
183+
contains(updatedPreferences, gsUtils.SCREEN_CAPTURE)) {
184+
chrome.extension.getBackgroundPage().tgs.resuspendAllSuspendedTabs();
185+
}
186+
}
187+
188+
function contains(array, value) {
189+
for (var i = 0; i < array.length; i++) {
190+
if (array[i] == value) return true;
191+
}
192+
return false;
174193
}
175194

176195
function closeSettings() {
177196
//only close the window if we were opened in a new tab.
178197
//else, go back to the page we were on.
179198
//this is to fix closing tabs if they were opened from the context menu.
180-
if (document.referrer === "") {
181-
window.close();
182-
} else {
199+
if (window.history.length > 1) {
183200
history.back();
201+
} else {
202+
window.close();
184203
}
185204
}
186205

@@ -204,9 +223,11 @@
204223
element.onchange = handleChange(element);
205224
}
206225
saveEl.onclick = function (e) {
226+
var updatedPreferences = [];
207227
for (i = 0; i < optionEls.length; i++) {
208-
saveChange(optionEls[i]);
228+
saveChange(optionEls[i], updatedPreferences);
209229
}
230+
performPostSaveUpdates(updatedPreferences);
210231
closeSettings();
211232
};
212233
cancelEl.onclick = function (e) {

src/js/suspended.js

+1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ chrome.tabs.getCurrent(function(tab) {
150150

151151
function hideNagForever() {
152152
gsUtils.setOption(gsUtils.NO_NAG, true);
153+
chrome.extension.getBackgroundPage().tgs.resuspendAllSuspendedTabs();
153154
document.getElementById('dudePopup').style.display = 'none';
154155
document.getElementById('donateBubble').style.display = 'none';
155156
}

src/options.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ <h2>Whitelist&nbsp;
122122

123123
<hr />
124124

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

128128
</div>
129129

src/update.html

-18
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,6 @@ <h1>The Great Suspender has been updated</h1>
1717

1818
<hr class="splashRule" />
1919

20-
<h2>Bugs squashed</h2>
21-
<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.
22-
Sorry for such a terrible bug and that the fix was a long time coming.</p>
23-
<p>The 'suspend other tabs' option will now NOT suspend the currently active tab.</p>
24-
<p>Browsing in incognito mode will no longer bring up the welcome tab every time.</p>
25-
26-
<h2>What's new?</h2>
27-
<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>
28-
<p>The extension now supports actions on multiple selected tabs. If you select multiple tabs in chrome, you will have some new options appear
29-
in the pop-up menu to allow you to suspend / unsuspend all selected tabs</p>
30-
<p>The new improved whitelist now supports regular expressions. For the programming-minded only!</p>
31-
<p>You can check it all out in the <a href='/options.html' target='_blank'>settings</a> page.</p>
32-
33-
<h2>Problems with the update?</h2>
34-
<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>
35-
36-
<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>
37-
3820
<p>Thanks for using <strong>The Great Suspender!</strong></p>
3921

4022
</div>

0 commit comments

Comments
 (0)