瀏覽代碼

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 年之前
父節點
當前提交
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">
<script type="text/javascript">
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>
<input hidden id="file-upload-picker" type='file' multiple>


+ 7
- 2
macrovision.js 查看文件

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

let entityIndex = 0;

let firsterror = true;

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

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

document.querySelector("#save-screenshot").addEventListener("click", e => {
@@ -5095,7 +5096,11 @@ function copyScreenshot() {
new ClipboardItem({
"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);
}


Loading…
取消
儲存