diff --git a/src/js/background.js b/src/js/background.js index fef3ca2c..fc22df0a 100644 --- a/src/js/background.js +++ b/src/js/background.js @@ -333,21 +333,28 @@ var tgs = (function () { } function unsuspendTab(tab) { - var url = gsUtils.getSuspendedUrl(tab.url); - chrome.tabs.update(tab.id, {url: url}, function() { - if (chrome.runtime.lastError) { - console.log(chrome.runtime.lastError.message); - } - }); + var url = gsUtils.getSuspendedUrl(tab.url), + views, + result; //bit of a hack here as using the chrome.tabs.update method will not allow //me to 'replace' the url - leaving a suspended tab in the history - /*tabs = chrome.extension.getViews({type: 'tab'}); - for (i = 0; i < tabs.length; i++) { - if (tabs[i].location.href === tab.url) { - tabs[i].location.replace(url); + views = chrome.extension.getViews({type: 'tab', "windowId": tab.windowId}); + result = views.some(function (view) { + if (view.tabId === tab.id) { + view.location.replace(url); + return true; } - }*/ + }); + + //if we failed to find the tab with the above method then try to update it directly + if (!result) { + chrome.tabs.update(tab.id, {url: url}, function() { + if (chrome.runtime.lastError) { + console.log(chrome.runtime.lastError.message); + } + }); + } } function handleWindowFocusChanged(windowId) { diff --git a/src/js/suspended.js b/src/js/suspended.js index 2e18818e..78d2841e 100644 --- a/src/js/suspended.js +++ b/src/js/suspended.js @@ -1,11 +1,13 @@ /*global window, document, chrome, console */ +var tabId; -var gsUtils = chrome.extension.getBackgroundPage().gsUtils; -document.getElementById('gsTitle').innerHTML = gsUtils.getSuspendedTitle(window.location.href); +document.getElementById('gsTitle').innerHTML = chrome.extension.getBackgroundPage().gsUtils.getSuspendedTitle(window.location.href); +chrome.tabs.getCurrent(function(tab) { + tabId = tab.id; +}); (function () { - //removed strict mode for compatibility with older versions of chrome - //'use strict'; + var gsUtils = chrome.extension.getBackgroundPage().gsUtils; function generateFaviconUri(url, callback) {