From 87a0d502a3247bd89094b65cd4bb87794dc29681 Mon Sep 17 00:00:00 2001 From: ed Date: Wed, 1 Sep 2021 23:32:27 +0200 Subject: [PATCH] crashpage: add useragent --- copyparty/web/util.js | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/copyparty/web/util.js b/copyparty/web/util.js index 18f4539e..a1d7d1a2 100644 --- a/copyparty/web/util.js +++ b/copyparty/web/util.js @@ -40,16 +40,36 @@ function vis_exh(msg, url, lineNo, columnNo, error) { crashed = true; window.onerror = undefined; var con = is_touch ? '' : '
  (and if you can, press F12 and include the "Console" tab in the screenshot too)', - html = ['

you hit a bug!

try to reset copyparty settings if you are stuck here, or ignore this / ignore all

please send me a screenshot arigathanks gozaimuch: ed/irc.rizon.net or ed#2644' + con + '

', - esc(url + ' @' + lineNo + ':' + columnNo), '
' + esc(String(msg)) + '

']; + html = [ + '

you hit a bug!

', + '

try to reset copyparty settings if you are stuck here, or ignore this / ignore all

', + '

please send me a screenshot arigathanks gozaimuch: ed/irc.rizon.net or ed#2644' + con + '

', + '

' + esc(url + ' @' + lineNo + ':' + columnNo), '
' + esc(String(msg)) + '

', + '

UA: ' + esc(navigator.userAgent + '') + ]; + + try { + var ua = '', + ad = navigator.userAgentData, + adb = ad.brands; + + for (var a = 0; a < adb.length; a++) + if (adb[a].brand.indexOf('Not;A') < 0) + ua += adb[a].brand + '/' + adb[a].version + ', '; + ua += ad.platform; + + html.push('
UAD: ' + esc(ua.slice(0, 100))); + } + catch (e) { } + html.push('

'); try { if (error) { var find = ['desc', 'stack', 'trace']; for (var a = 0; a < find.length; a++) if (String(error[find[a]]) !== 'undefined') - html.push('

' + find[a] + '

' + - esc(String(error[find[a]])).replace(/\n/g, '
\n')); + html.push('

' + find[a] + ':
' + + esc(String(error[find[a]])).replace(/\n/g, '
\n') + '

'); } ignexd[ekey] = true; @@ -59,9 +79,10 @@ function vis_exh(msg, url, lineNo, columnNo, error) { var lsk = Object.keys(ls); lsk.sort(); - html.push('

localstore

'); + html.push('

'); for (var a = 0; a < lsk.length; a++) html.push(' ' + esc(lsk[a]) + ' ' + esc(ls[lsk[a]]) + ' '); + html.push('

'); } catch (e) { } @@ -79,7 +100,7 @@ function vis_exh(msg, url, lineNo, columnNo, error) { '#exbox code{color:#bf7;background:#222;padding:.1em;margin:.2em;font-size:1.1em;font-family:monospace,monospace} ' + '#exbox a{text-decoration:underline;color:#fc0} ' + '#exbox h1{margin:.5em 1em 0 0;padding:0} ' + - '#exbox h3{border-top:1px solid #999;margin:1em 0 0 0} ' + + '#exbox p.b{border-top:1px solid #999;margin:1em 0 0 0;font-size:1em} ' + '#exbox b{color:#fff}' ); document.head.appendChild(s);