|
31 | 31 | #splash { |
32 | 32 | display: none; |
33 | 33 | position: fixed; |
| 34 | + top: 0; |
| 35 | + right: 0; |
| 36 | + bottom: 0; |
| 37 | + left: 0; |
34 | 38 | inset: 0; |
35 | 39 | z-index: 999999; |
36 | 40 |
|
|
74 | 78 | <!-- Set theme color BEFORE UI renders --> |
75 | 79 | <script> |
76 | 80 | (function () { |
| 81 | + var MIN_WEBVIEW_MAJOR = 84; |
77 | 82 | var color = localStorage.getItem("__primary_color"); |
78 | 83 | var bg = color || "#20202c"; |
79 | 84 |
|
80 | 85 | document.documentElement.style.setProperty("--bg-color", bg); |
81 | 86 | document.documentElement.style.backgroundColor = bg; |
82 | 87 | document.body && (document.body.style.backgroundColor = bg); |
| 88 | + |
| 89 | + function getWebViewMajor() { |
| 90 | + var match = navigator.userAgent.match(/(?:Chrome|CriOS)\/(\d+)/); |
| 91 | + return match ? Number(match[1]) : 0; |
| 92 | + } |
| 93 | + |
| 94 | + function setStartupMessage(message) { |
| 95 | + var applyMessage = function () { |
| 96 | + document.body.setAttribute("data-small-msg", message); |
| 97 | + }; |
| 98 | + |
| 99 | + if (document.body) { |
| 100 | + applyMessage(); |
| 101 | + } else { |
| 102 | + document.addEventListener("DOMContentLoaded", applyMessage); |
| 103 | + } |
| 104 | + } |
| 105 | + |
| 106 | + window.__ACODE_WEBVIEW_MAJOR__ = getWebViewMajor(); |
| 107 | + window.__ACODE_MIN_WEBVIEW_MAJOR__ = MIN_WEBVIEW_MAJOR; |
| 108 | + |
| 109 | + if ( |
| 110 | + window.__ACODE_WEBVIEW_MAJOR__ && |
| 111 | + window.__ACODE_WEBVIEW_MAJOR__ < MIN_WEBVIEW_MAJOR |
| 112 | + ) { |
| 113 | + setStartupMessage( |
| 114 | + "Your Android System WebView is old. Update Android System WebView or Chrome if Acode stays on this screen.", |
| 115 | + ); |
| 116 | + } |
| 117 | + |
| 118 | + window.addEventListener("error", function (event) { |
| 119 | + var message = event && event.message ? event.message : "Startup error"; |
| 120 | + setStartupMessage( |
| 121 | + "Acode failed to start. Update Android System WebView or Chrome. " + |
| 122 | + message, |
| 123 | + ); |
| 124 | + }); |
| 125 | + |
| 126 | + window.addEventListener("unhandledrejection", function (event) { |
| 127 | + var reason = event && event.reason; |
| 128 | + var message = |
| 129 | + reason && reason.message ? reason.message : "Startup promise failed"; |
| 130 | + setStartupMessage( |
| 131 | + "Acode failed to start. Update Android System WebView or Chrome. " + |
| 132 | + message, |
| 133 | + ); |
| 134 | + }); |
83 | 135 | })(); |
84 | 136 | </script> |
85 | 137 |
|
|
0 commit comments