diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 7bbc6480..c4e9fcdb 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -3,7 +3,7 @@ "ext_extension_name": { "message": "The Great Suspender" }, "ext_extension_description": { "message": "Automatically suspends unused tabs to free up system resources" }, "ext_default_title": { "message": "The Great Suspender" }, - "ext_cmd_suspend_tab_description": { "message": "Suspend active tab" }, + "ext_cmd_suspend_tab_description": { "message": "Suspend/Unsuspend active tab" }, "ext_cmd_unsuspend_tab_description": { "message": "Unsuspend active tab" }, "ext_cmd_suspend_active_window_description": { "message": "Suspend all other tabs in active window" }, "ext_cmd_unsuspend_active_window_description": { "message": "Unsuspend all tabs in active window" }, @@ -144,7 +144,8 @@ "html_suspended_tab_suspended": { "message": "Tab suspended" }, "html_suspended_tab_reload": { "message": "Reload tab" }, "html_suspended_tab_whitelist": { "message": "Whitelist site" }, - "html_suspended_click_to_reload": { "message": "Refresh or click to reload" }, + "html_suspended_click_to_reload": { "message": "Click to reload" }, + "html_suspended_hotkey_to_reload": { "message": "keyboard shortcut: " }, "html_suspended_toast_not_connected": { "message": "You are not connected to the internet" }, "html_suspended_toast_reload_disabled": { "message": "Automatic tab reloading is temporarily disabled." }, "html_suspended_modal_header": { "message": "What would you like to whitelist?" }, @@ -244,5 +245,5 @@ "js_update_button_reload": { "message": "Update extension now" }, // Keyboard shortcuts page (Javascript code) - "js_shortcuts_not_set": { "message": "(not set)" } + "js_shortcuts_not_set": { "message": "not set" } } diff --git a/src/_locales/zh/messages.json b/src/_locales/zh/messages.json index 11da79fd..b0317b02 100644 --- a/src/_locales/zh/messages.json +++ b/src/_locales/zh/messages.json @@ -3,7 +3,7 @@ "ext_extension_name": { "message": "The Great Suspender" }, "ext_extension_description": { "message": "凍結暫時用不到的分頁,達到系統資源釋放。" }, "ext_default_title": { "message": "The Great Suspender" }, - "ext_cmd_suspend_tab_description": { "message": "凍結目前的分頁" }, + "ext_cmd_suspend_tab_description": { "message": "冻结/恢复当前页面" }, "ext_cmd_unsuspend_tab_description": { "message": "恢復目前的分頁" }, "ext_cmd_suspend_active_window_description": { "message": "凍結目前視窗中所有的分頁" }, "ext_cmd_unsuspend_active_window_description": { "message": "恢復目前視窗中所有的分頁" }, @@ -144,7 +144,8 @@ "html_suspended_tab_suspended": { "message": "分頁已經被凍結" }, "html_suspended_tab_reload": { "message": "重新載入" }, //TODO: Used google translate. important!!1 "html_suspended_tab_whitelist": { "message": "添加到例外列表" }, //TODO: Used google translate. important!!1 - "html_suspended_click_to_reload": { "message": "刷新或點擊此處重新加載" }, //TODO: Used google translate. important!!1 + "html_suspended_click_to_reload": { "message": "点击这里重新载入" }, //TODO: Used google translate. important!!1 + "html_suspended_hotkey_to_reload": { "message": "鍵盤快速鍵: " }, //TODO: Used google translate. important!!1 "html_suspended_toast_not_connected": { "message": "您沒有連接到網絡" }, //TODO: Used google translate. important!!1 "html_suspended_toast_reload_disabled": { "message": "禁用自動重新加載。" }, //TODO: Used google translate. important!!1 "html_suspended_modal_header": { "message": "你想要什麼白名單?" }, //TODO: Used google translate. important!!1 diff --git a/src/css/style.css b/src/css/style.css index cc636870..ccb6c3c0 100755 --- a/src/css/style.css +++ b/src/css/style.css @@ -413,15 +413,21 @@ a.historyLink:hover { .suspendedMsg, .gsPreview { cursor: pointer; } -.suspendedMsg h1, .suspendedMsg h2 { - font-size: 60px; +.suspendedMsg h1, .suspendedMsg h2, .suspendedMsg h3 { color: #134960; margin: 30px 0 0; font-weight: 300; } +.suspendedMsg h1 { + font-size: 60px; +} .suspendedMsg h2 { font-size: 40px; } +.suspendedMsg h3 { + font-size: 20px; + font-style: italic; +} @media all and (max-width: 600px) { .suspendedMsg h1 { font-size: 45px; diff --git a/src/js/background.js b/src/js/background.js index f8bd9d93..fca7f23d 100755 --- a/src/js/background.js +++ b/src/js/background.js @@ -150,6 +150,8 @@ var tgs = (function () { // eslint-disable-line no-unused-vars callback(tabs[0]); } else { + //TODO: Possibly fallback on globalCurrentTabId here? + //see https://github.com/deanoemcke/thegreatsuspender/issues/574 callback(null); } }); @@ -214,6 +216,18 @@ var tgs = (function () { // eslint-disable-line no-unused-vars }); } + function toggleSuspendedStateOfHighlightedTab() { + getCurrentlyActiveTab(function (activeTab) { + if (activeTab) { + if (gsUtils.isSuspendedTab(activeTab)) { + unsuspendTab(activeTab); + } else { + requestTabSuspension(activeTab, 1); + } + } + }); + } + function suspendHighlightedTab() { getCurrentlyActiveTab(function (activeTab) { if (activeTab) { @@ -684,7 +698,7 @@ var tgs = (function () { // eslint-disable-line no-unused-vars chrome.commands.onCommand.addListener(function (command) { if (command === '1-suspend-tab') { - suspendHighlightedTab(); + toggleSuspendedStateOfHighlightedTab(); } else if (command === '2-unsuspend-tab') { unsuspendHighlightedTab(); diff --git a/src/js/shortcuts.js b/src/js/shortcuts.js index 1c63e67f..61a8a6e3 100644 --- a/src/js/shortcuts.js +++ b/src/js/shortcuts.js @@ -14,9 +14,9 @@ chrome.commands.getAll(function (commands) { commands.forEach(function (command) { - if (command.name !== '_execute_browser_action') { - var shortcut = command.shortcut !== '' ? command.shortcut : chrome.i18n.getMessage('js_shortcuts_not_set'), - style = count % 2 === 0 ? '"margin: 0 0 2px;"' : ''; + if (command.name !== '_execute_browser_action' && command.name !== '2-unsuspend-tab') { + var shortcut = command.shortcut !== '' ? command.shortcut : '(' + chrome.i18n.getMessage('js_shortcuts_not_set') + ')'; + var style = count % 2 === 1 ? '"margin: 0 0 2px;"' : ''; shortcutsEl.innerHTML += '

' + command.description + ': ' + shortcut + '

'; count++; } diff --git a/src/js/suspended.js b/src/js/suspended.js index d435962b..abc2700e 100644 --- a/src/js/suspended.js +++ b/src/js/suspended.js @@ -140,6 +140,26 @@ document.getElementById('gsTopBarTitle').setAttribute('href', url); document.getElementById('gsTopBarImg').setAttribute('src', favicon); + //update hotkey + chrome.commands.getAll(function (commands) { + var hotkeyEl = document.getElementById('hotkeyCommand'); + if (!hotkeyEl) { return; } + var toggleCommand = commands.find(function (command) { + return (command.name === '1-suspend-tab'); + }); + if (hotkeyEl && toggleCommand && toggleCommand.shortcut !== '') { + hotkeyEl.innerHTML = toggleCommand.shortcut; + } + else { + var shortcutNotSetEl = document.createElement('a'); + shortcutNotSetEl.innerHTML = chrome.i18n.getMessage('js_shortcuts_not_set'); + hotkeyEl.appendChild(shortcutNotSetEl); + hotkeyEl.onclick = function () { + chrome.tabs.create({url: 'chrome://extensions/configureCommands'}); + }; + } + }); + //update whitelist text var isWhitelisted = gsUtils.checkWhiteList(url); if (isWhitelisted) { diff --git a/src/suspended.html b/src/suspended.html index 0dd667ec..3083719d 100644 --- a/src/suspended.html +++ b/src/suspended.html @@ -21,6 +21,7 @@

+

()