Skip to content

Commit

Permalink
✨ 如果有截圖在相簿區,離開頁面前會跳警告提醒
Browse files Browse the repository at this point in the history
避免忘記儲存截圖就離開

由於 HTML 標準和瀏覽器設計的關係,現在無法自訂跳出的訊息內容
  • Loading branch information
hms5232 committed Apr 5, 2023
1 parent 53c11a9 commit 2714b0c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/butterKnife.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,19 @@
setFilenamePrefix();
});

consolog("區域初始化完成");

// 離開頁面時觸發
addEventListener("beforeunload", (event) => {
consolog("★before unload★");
// 如果相簿區有截圖存在,就跳出訊息確認
if (document.getElementsByClassName("butter-knife-shot-a").length > 0) {
event.preventDefault();
return "【奶油刀】離開頁面將會清除現存頁面上暫存的截圖,請確定已經儲存想要保留的截圖";
}
});
consolog("開始監聽 beforeunload");

consolog("init OK.");
}

Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "巴哈動畫瘋奶油刀",
"version": "0.3.4",
"version": "0.3.5",
"author": "hms5232",

"description": "A screenshot tool for ani.gamer.com.tw",
Expand Down

0 comments on commit 2714b0c

Please sign in to comment.