diff --git a/omega-locales/ach/LC_MESSAGES/omega-web.po b/omega-locales/ach/LC_MESSAGES/omega-web.po index e3bcb6a..919de86 100644 --- a/omega-locales/ach/LC_MESSAGES/omega-web.po +++ b/omega-locales/ach/LC_MESSAGES/omega-web.po @@ -1012,7 +1012,7 @@ msgid "popup_reportIssues" msgstr "Report issues" msgid "popup_errorLog" -msgstr "Error log" +msgstr "Save error log" msgid "popup_requestErrorCount" msgstr "$COUNT$ failed resources" @@ -1114,3 +1114,6 @@ msgstr "Inspect proxy to be used if this Link is opened" msgid "contextMenu_inspectElement" msgstr "Inspect proxy used for this Element" + +msgid "contextMenu_enableQuickSwitch" +msgstr "Enable Quick Switch" diff --git a/omega-locales/cs/LC_MESSAGES/omega-web.po b/omega-locales/cs/LC_MESSAGES/omega-web.po index 4c7e164..6082bf8 100644 --- a/omega-locales/cs/LC_MESSAGES/omega-web.po +++ b/omega-locales/cs/LC_MESSAGES/omega-web.po @@ -1005,7 +1005,7 @@ msgid "popup_reportIssues" msgstr "Report problémů" msgid "popup_errorLog" -msgstr "Protokol chyb" +msgstr "Exportovat Protokol chyb" msgid "popup_requestErrorCount" msgstr "$COUNT$ chybových požadavků" @@ -1110,3 +1110,6 @@ msgstr "Zkontrolujte, zda server proxy používaná tento prvek" msgid "contextMenu_inspectElement" msgstr "Zkontrolujte, zda server proxy používaná tento prvek" + +msgid "contextMenu_enableQuickSwitch" +msgstr "Povolit Rychlé přepínání" diff --git a/omega-locales/en_US/LC_MESSAGES/omega-web.po b/omega-locales/en_US/LC_MESSAGES/omega-web.po index 5aba12d..42bcb81 100644 --- a/omega-locales/en_US/LC_MESSAGES/omega-web.po +++ b/omega-locales/en_US/LC_MESSAGES/omega-web.po @@ -1000,7 +1000,7 @@ msgid "popup_reportIssues" msgstr "Report issues" msgid "popup_errorLog" -msgstr "Error log" +msgstr "Save error log" msgid "popup_requestErrorCount" msgstr "$COUNT$ failed resources" @@ -1096,3 +1096,6 @@ msgstr "Inspect proxy to be used if this Link is opened" msgid "contextMenu_inspectElement" msgstr "Inspect proxy used for this Element" + +msgid "contextMenu_enableQuickSwitch" +msgstr "Enable Quick Switch" diff --git a/omega-locales/es_AR/LC_MESSAGES/omega-web.po b/omega-locales/es_AR/LC_MESSAGES/omega-web.po index 5a3969a..bd591c4 100644 --- a/omega-locales/es_AR/LC_MESSAGES/omega-web.po +++ b/omega-locales/es_AR/LC_MESSAGES/omega-web.po @@ -1015,7 +1015,7 @@ msgid "popup_reportIssues" msgstr "Report issues" msgid "popup_errorLog" -msgstr "Error log" +msgstr "Save error log" msgid "popup_requestErrorCount" msgstr "$COUNT$ failed resources" @@ -1117,3 +1117,6 @@ msgstr "Inspect proxy to be used if this Link is opened" msgid "contextMenu_inspectElement" msgstr "Inspeccionar proxy utilizado para este Elemento." + +msgid "contextMenu_enableQuickSwitch" +msgstr "Enable Quick Switch" diff --git a/omega-locales/fa/LC_MESSAGES/omega-web.po b/omega-locales/fa/LC_MESSAGES/omega-web.po index 5260202..dc86021 100644 --- a/omega-locales/fa/LC_MESSAGES/omega-web.po +++ b/omega-locales/fa/LC_MESSAGES/omega-web.po @@ -1013,7 +1013,7 @@ msgid "popup_reportIssues" msgstr "Report issues" msgid "popup_errorLog" -msgstr "Error log" +msgstr "Save error log" msgid "popup_requestErrorCount" msgstr "$COUNT$ failed resources" @@ -1115,3 +1115,6 @@ msgstr "Inspect proxy to be used if this Link is opened" msgid "contextMenu_inspectElement" msgstr "Inspect proxy used for this Element" + +msgid "contextMenu_enableQuickSwitch" +msgstr "Enable Quick Switch" diff --git a/omega-locales/ja/LC_MESSAGES/omega-web.po b/omega-locales/ja/LC_MESSAGES/omega-web.po index af64d7d..44eceaa 100644 --- a/omega-locales/ja/LC_MESSAGES/omega-web.po +++ b/omega-locales/ja/LC_MESSAGES/omega-web.po @@ -1008,7 +1008,7 @@ msgid "popup_reportIssues" msgstr "Report issues" msgid "popup_errorLog" -msgstr "Error log" +msgstr "Save error log" msgid "popup_requestErrorCount" msgstr "$COUNT$ failed resources" @@ -1105,3 +1105,6 @@ msgstr "Inspect proxy to be used if this Link is opened" msgid "contextMenu_inspectElement" msgstr "Inspect proxy used for this Element" + +msgid "contextMenu_enableQuickSwitch" +msgstr "Enable Quick Switch" diff --git a/omega-locales/ru/LC_MESSAGES/omega-web.po b/omega-locales/ru/LC_MESSAGES/omega-web.po index 6f580d8..862c7d2 100644 --- a/omega-locales/ru/LC_MESSAGES/omega-web.po +++ b/omega-locales/ru/LC_MESSAGES/omega-web.po @@ -1017,7 +1017,7 @@ msgid "popup_reportIssues" msgstr "Report issues" msgid "popup_errorLog" -msgstr "Error log" +msgstr "Save error log" msgid "popup_requestErrorCount" msgstr "$COUNT$ failed resources" @@ -1119,3 +1119,6 @@ msgstr "Inspect proxy to be used if this Link is opened" msgid "contextMenu_inspectElement" msgstr "Inspect proxy used for this Element" + +msgid "contextMenu_enableQuickSwitch" +msgstr "Enable Quick Switch" diff --git a/omega-locales/tr/LC_MESSAGES/omega-web.po b/omega-locales/tr/LC_MESSAGES/omega-web.po index f18fa6a..63f0fcf 100644 --- a/omega-locales/tr/LC_MESSAGES/omega-web.po +++ b/omega-locales/tr/LC_MESSAGES/omega-web.po @@ -1014,7 +1014,7 @@ msgid "popup_reportIssues" msgstr "Report issues" msgid "popup_errorLog" -msgstr "Error log" +msgstr "Save error log" msgid "popup_requestErrorCount" msgstr "$COUNT$ failed resources" @@ -1111,3 +1111,6 @@ msgstr "Inspect proxy to be used if this Link is opened" msgid "contextMenu_inspectElement" msgstr "Inspect proxy used for this Element" + +msgid "contextMenu_enableQuickSwitch" +msgstr "Enable Quick Switch" diff --git a/omega-locales/zh_CN/LC_MESSAGES/omega-web.po b/omega-locales/zh_CN/LC_MESSAGES/omega-web.po index ef8c28b..d9b1825 100644 --- a/omega-locales/zh_CN/LC_MESSAGES/omega-web.po +++ b/omega-locales/zh_CN/LC_MESSAGES/omega-web.po @@ -879,7 +879,7 @@ msgid "popup_reportIssues" msgstr "反馈问题" msgid "popup_errorLog" -msgstr "错误日志" +msgstr "保存错误日志" msgid "popup_requestErrorCount" msgstr "$COUNT$个资源未加载" @@ -975,3 +975,6 @@ msgstr "检查此[链接目标]将会使用的代理" msgid "contextMenu_inspectElement" msgstr "检查此[元素]使用的代理" + +msgid "contextMenu_enableQuickSwitch" +msgstr "启用快速切换" diff --git a/omega-locales/zh_TW/LC_MESSAGES/omega-web.po b/omega-locales/zh_TW/LC_MESSAGES/omega-web.po index a657eb9..74da593 100644 --- a/omega-locales/zh_TW/LC_MESSAGES/omega-web.po +++ b/omega-locales/zh_TW/LC_MESSAGES/omega-web.po @@ -879,7 +879,7 @@ msgid "popup_reportIssues" msgstr "反饋問題" msgid "popup_errorLog" -msgstr "錯誤日誌" +msgstr "儲存错误日志" msgid "popup_requestErrorCount" msgstr "$COUNT$個資源未載入" @@ -975,3 +975,6 @@ msgstr "檢查此[連結目標]將會使用的代理" msgid "contextMenu_inspectElement" msgstr "檢查此[元素]使用的代理" + +msgid "contextMenu_enableQuickSwitch" +msgstr "啟用快速切換" diff --git a/omega-target-chromium-extension/background_preload.coffee b/omega-target-chromium-extension/background_preload.coffee new file mode 100644 index 0000000..1ac2350 --- /dev/null +++ b/omega-target-chromium-extension/background_preload.coffee @@ -0,0 +1,56 @@ +window.UglifyJS_NoUnsafeEval = true +localStorage['log'] = '' +localStorage['logLastError'] = '' + +window.OmegaContextMenuQuickSwitchHandler = -> null +# We don't need this API. However its presence indicates that Chrome >= 35 +# which provides info.checked we need in contextMenu callback. +# https://developer.chrome.com/extensions/contextMenus +if chrome.i18n.getUILanguage? + # We must create the menu item here before others to make it first in menu. + chrome.contextMenus.create({ + id: 'enableQuickSwitch' + title: chrome.i18n.getMessage('contextMenu_enableQuickSwitch') + type: 'checkbox' + checked: false + contexts: ["browser_action"] + onclick: (info) -> window.OmegaContextMenuQuickSwitchHandler(info) + }) + +chrome.contextMenus.create({ + title: chrome.i18n.getMessage('popup_reportIssues') + contexts: ["browser_action"] + onclick: -> + url = 'https://github.com/FelisCatus/SwitchyOmega/issues/new?title=&body=' + finalUrl = url + try + extensionVersion = chrome.runtime.getManifest().version + env = + extensionVersion: extensionVersion + projectVersion: extensionVersion + userAgent: navigator.userAgent + body = chrome.i18n.getMessage('popup_issueTemplate', [ + env.projectVersion, env.userAgent + ]) + body ||= """ + \n\n + + SwitchyOmega #{env.projectVersion} + #{env.userAgent} + """ + finalUrl = url + encodeURIComponent(body) + err = localStorage['logLastError'] + if err + body += "\n```\n#{err}\n```" + finalUrl = (url + encodeURIComponent(body)).substr(0, 2000) + + chrome.tabs.create(url: finalUrl) +}) + +chrome.contextMenus.create({ + title: chrome.i18n.getMessage('popup_errorLog') + contexts: ["browser_action"] + onclick: -> + blob = new Blob [localStorage['log']], {type: "text/plain;charset=utf-8"} + saveAs(blob, "OmegaLog_#{Date.now()}.txt") +}) diff --git a/omega-target-chromium-extension/grunt/coffee.coffee b/omega-target-chromium-extension/grunt/coffee.coffee index 80ffbd5..d442b7d 100644 --- a/omega-target-chromium-extension/grunt/coffee.coffee +++ b/omega-target-chromium-extension/grunt/coffee.coffee @@ -2,9 +2,9 @@ module.exports = target_web: files: 'build/js/omega_target_web.js': 'omega_target_web.coffee' - target_web_log: - files: - 'build/js/omega_target_web_basics.js': 'omega_target_web_basics.coffee' background: files: 'build/js/background.js': 'background.coffee' + background_preload: + files: + 'build/js/background_preload.js': 'background_preload.coffee' diff --git a/omega-target-chromium-extension/omega_target_web_basics.coffee b/omega-target-chromium-extension/omega_target_web_basics.coffee deleted file mode 100644 index cb4b397..0000000 --- a/omega-target-chromium-extension/omega_target_web_basics.coffee +++ /dev/null @@ -1,13 +0,0 @@ -window.OmegaTargetWebBasics = - getLog: (callback) -> - callback(localStorage['log'] || '') - getError: (callback) -> - callback(localStorage['logLastError'] || '') - getEnv: (callback) -> - extensionVersion = chrome.runtime.getManifest().version - callback({ - extensionVersion: extensionVersion - projectVersion: extensionVersion - userAgent: navigator.userAgent - }) - getMessage: chrome.i18n.getMessage.bind(chrome.i18n) diff --git a/omega-target-chromium-extension/overlay/background.html b/omega-target-chromium-extension/overlay/background.html index 0c8703d..7979008 100644 --- a/omega-target-chromium-extension/overlay/background.html +++ b/omega-target-chromium-extension/overlay/background.html @@ -8,6 +8,7 @@ + diff --git a/omega-target-chromium-extension/overlay/js/background_preload.js b/omega-target-chromium-extension/overlay/js/background_preload.js deleted file mode 100644 index d9b27c2..0000000 --- a/omega-target-chromium-extension/overlay/js/background_preload.js +++ /dev/null @@ -1,3 +0,0 @@ -window.UglifyJS_NoUnsafeEval = true -localStorage['log'] = '' -localStorage['logLastError'] = '' diff --git a/omega-target-chromium-extension/src/options.coffee b/omega-target-chromium-extension/src/options.coffee index 7377f1c..7687735 100644 --- a/omega-target-chromium-extension/src/options.coffee +++ b/omega-target-chromium-extension/src/options.coffee @@ -1,4 +1,4 @@ -OmegaTarget = require('omega-target') +OcontextMenu_inspectElementmegaTarget = require('omega-target') OmegaPac = OmegaTarget.OmegaPac Promise = OmegaTarget.Promise xhr = Promise.promisify(require('xhr')) @@ -165,7 +165,24 @@ class ChromeOptions extends OmegaTarget.Options return _quickSwitchInit: false - setQuickSwitch: (quickSwitch) -> + _quickSwitchContextMenuCreated: false + _quickSwitchCanEnable: false + setQuickSwitch: (quickSwitch, canEnable) -> + @_quickSwitchCanEnable = canEnable + if not @_quickSwitchContextMenuCreated + @_quickSwitchContextMenuCreated = true + if quickSwitch + chrome.contextMenus.update('enableQuickSwitch', {checked: true}) + window.OmegaContextMenuQuickSwitchHandler = (info) => + changes = {} + changes['-enableQuickSwitch'] = info.checked + setOptions = @_setOptions(changes) + if info.checked and not @_quickSwitchCanEnable + setOptions.then -> + chrome.tabs.create( + url: chrome.extension.getURL('options.html#/ui') + ) + if quickSwitch chrome.browserAction.setPopup({popup: ''}) if not @_quickSwitchInit diff --git a/omega-target/src/options.coffee b/omega-target/src/options.coffee index ad90573..d0bbbe5 100644 --- a/omega-target/src/options.coffee +++ b/omega-target/src/options.coffee @@ -391,14 +391,12 @@ class Options # @returns {Promise} A promise which is fulfilled when the quick switch is set ### reloadQuickSwitch: -> + profiles = @_options['-quickSwitchProfiles'] + profiles = null if profiles.length < 2 if @_options['-enableQuickSwitch'] - profiles = @_options['-quickSwitchProfiles'] - if profiles.length >= 2 - @setQuickSwitch(profiles) - else - @setQuickSwitch(null) + @setQuickSwitch(profiles, !!profiles) else - @setQuickSwitch(null) + @setQuickSwitch(null, !!profiles) ###* # Apply the settings related to element proxy inspection. @@ -594,9 +592,10 @@ class Options # Set or disable the quick switch profiles. # In base class, this method is not implemented and will not do anything. # @param {string[]|null} quickSwitch The profile names, or null to disable + # @param {boolean} canEnable Whether user can enable quick switch or not. # @returns {Promise} A promise which is fulfilled when the quick switch is set ### - setQuickSwitch: (quickSwitch) -> + setQuickSwitch: (quickSwitch, canEnable) -> Promise.resolve() ###* diff --git a/omega-web/src/coffee/popup.coffee b/omega-web/src/coffee/popup.coffee index 2ebcacb..40ec0e3 100644 --- a/omega-web/src/coffee/popup.coffee +++ b/omega-web/src/coffee/popup.coffee @@ -28,8 +28,6 @@ shortcutKeys = 61: 'addRule' # = 84: 'tempRule' # t 79: 'option' # o - 73: 'issue' # i - 76: 'log' # l 82: 'requestInfo' # r for i in [1..9] @@ -63,8 +61,6 @@ jQuery(document).on 'keydown', (e) -> 'addRule': 'A' 'tempRule': 'T' 'option': 'O' - 'issue': 'I' - 'log': 'L' 'requestInfo': 'R' for shortcut, key of keys showHelp(shortcut, key) diff --git a/omega-web/src/coffee/popup_basics.coffee b/omega-web/src/coffee/popup_basics.coffee deleted file mode 100644 index 53a22d0..0000000 --- a/omega-web/src/coffee/popup_basics.coffee +++ /dev/null @@ -1,26 +0,0 @@ -# Use events to ensure that the log can be downloaded even if everything else -# fails to load. -document.querySelector('.error-log').addEventListener 'click', (-> - window.OmegaTargetWebBasics.getLog (log) -> - blob = new Blob [log], {type: "text/plain;charset=utf-8"} - saveAs(blob, "OmegaLog_#{Date.now()}.txt") -), false - -window.OmegaTargetWebBasics.getEnv (env) -> - url = 'https://github.com/FelisCatus/SwitchyOmega/issues/new?title=&body=' - body = window.OmegaTargetWebBasics.getMessage('popup_issueTemplate', [ - env.projectVersion, env.userAgent - ]) - body ||= """ - \n\n - - SwitchyOmega #{env.projectVersion} - #{env.userAgent} - """ - link = document.querySelector('.report-issue') - link.href = url + encodeURIComponent(body) - window.OmegaTargetWebBasics.getError (err) -> - return unless err - body += "\n```\n#{err}\n```" - final_url = url + encodeURIComponent(body) - link.href = final_url.substr(0, 2000) # Limit URL up to 2000 chars. diff --git a/omega-web/src/popup.jade b/omega-web/src/popup.jade index 2c18c12..c85f999 100644 --- a/omega-web/src/popup.jade +++ b/omega-web/src/popup.jade @@ -80,17 +80,6 @@ html(lang='en' ng-app='omegaPopup' ng-controller='PopupCtrl' ng-csp) span.glyphicon.glyphicon-wrench = ' ' span {{'popup_showOptions' | tr}} - li - a.report-issue(href='https://github.com/FelisCatus/SwitchyOmega/issues' - target='_blank' data-shortcut='issue') - span.glyphicon.glyphicon-comment - = ' ' - span {{'popup_reportIssues' | tr}} - li - a.error-log(href='#' role='button' data-shortcut='log') - span.glyphicon.glyphicon-download - = ' ' - span {{'popup_errorLog' | tr}} form.condition-form(name='conditionForm' style='display: none;' ng-style='{display: showConditionForm ? "block" : "none"}' ng-submit='addCondition(rule.condition, rule.profileName)') @@ -165,9 +154,6 @@ html(lang='en' ng-app='omegaPopup' ng-controller='PopupCtrl' ng-csp) ng-click='openOptions("#/general")') {{'popup_configureMonitorWebRequests' | tr}} script(src='js/log_error.js') - script(src='lib/FileSaver/FileSaver.js') - script(src='js/omega_target_web_basics.js') - script(src='js/popup_basics.js') script(src='lib/jquery/jquery.min.js') script(src='lib/angular/angular.min.js') script(src='lib/angular-bootstrap/ui-bootstrap-tpls.min.js')