Просмотр исходного кода

Warn when a screenshot fails to be taken

This usually happens when the window gets unfocused before
the screenshot is done. The promise is now handled properly.
Unhandled promise errors will now cause a popup. The popup
can only appear once now.
master
Fen Dweller 4 лет назад
Родитель
Сommit
a8449109c7
2 измененных файлов: 17 добавлений и 3 удалений
  1. +10
    -1
      macrovision.html
  2. +7
    -2
      macrovision.js

+ 10
- 1
macrovision.html Просмотреть файл

@@ -39,7 +39,16 @@
<body class="toggle-bottom-name toggle-top-name"> <body class="toggle-bottom-name toggle-top-name">
<script type="text/javascript"> <script type="text/javascript">
window.onerror = function(msg, url, line, col, error) { window.onerror = function(msg, url, line, col, error) {
alert("An error occured. If you're on a computer, hit F12 to open the developer tools, click the Console tab, and send the red text to chemicalcrux. If you're on mobile, screenshot this instead:\n\n" + msg + "\n" + url + "\n" + "line: " + line + "\n" + "col: " + col + "\nerror: " + error);
if (firsterror) {
firsterror = false;
alert("An error occured. If you're on a computer, hit F12 to open the developer tools, click the Console tab, and send the red text to chemicalcrux. If you're on mobile, screenshot this instead:\n\n" + msg + "\n" + url + "\n" + "line: " + line + "\n" + "col: " + col + "\nerror: " + error);
}
}
window.onunhandledrejection = function(e) {
if (firsterror) {
firsterror = false;
alert("An error occured. If you're on a computer, hit F12 to open the developer tools, click the Console tab, and send the red text to chemicalcrux. If you're on mobile, screenshot this instead:\n\n" + e.reason);
}
} }
</script> </script>
<input hidden id="file-upload-picker" type='file' multiple> <input hidden id="file-upload-picker" type='file' multiple>


+ 7
- 2
macrovision.js Просмотреть файл

@@ -5,6 +5,8 @@ let prevSelectedEntity = null;


let entityIndex = 0; let entityIndex = 0;


let firsterror = true;

let clicked = null; let clicked = null;
let movingInBounds = false; let movingInBounds = false;
let dragging = false; let dragging = false;
@@ -3179,7 +3181,6 @@ document.addEventListener("DOMContentLoaded", () => {


document.querySelector("#copy-screenshot").addEventListener("click", e => { document.querySelector("#copy-screenshot").addEventListener("click", e => {
copyScreenshot(); copyScreenshot();
toast("Copied to clipboard!");
}); });


document.querySelector("#save-screenshot").addEventListener("click", e => { document.querySelector("#save-screenshot").addEventListener("click", e => {
@@ -5095,7 +5096,11 @@ function copyScreenshot() {
new ClipboardItem({ new ClipboardItem({
"image/png": blob "image/png": blob
}) })
]);
]).then(e =>
toast("Copied to clipboard!"))
.catch(e => {
toast("Couldn't write to the clipboard. Make sure the screenshot completes before switching tabs.")
})
}); });
drawScales(false); drawScales(false);
} }


Загрузка…
Отмена
Сохранить