Attach last error message when using the Report Issue link.

This commit is contained in:
FelisCatus 2014-12-19 21:27:17 +08:00
parent 4fa13c686d
commit b3fada8fac
4 changed files with 11 additions and 1 deletions

View File

@ -10,6 +10,7 @@ Log.log = (args...) ->
Log.error = (args...) ->
console.error(args...)
content = args.map(Log.str.bind(Log)).join(' ')
localStorage['logLastError'] = content
localStorage['log'] += 'ERROR: ' + content + '\n'
unhandledPromises = []

View File

@ -1,6 +1,8 @@
window.OmegaTargetWebBasics =
getLog: (callback) ->
callback(localStorage['log'] || '')
getError: (callback) ->
callback(localStorage['logLastError'] || '')
getEnv: (callback) ->
extensionVersion = chrome.runtime.getManifest().version
callback({

View File

@ -1,2 +1,3 @@
window.UglifyJS_NoUnsafeEval = true
localStorage['log'] = ''
localStorage['logLastError'] = ''

View File

@ -15,4 +15,10 @@ window.OmegaTargetWebBasics.getEnv (env) ->
SwitchyOmega #{env.projectVersion}
#{env.userAgent}
"""
document.querySelector('.report-issue').href = url + encodeURIComponent(body)
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.