feat: forget last played time when <10 seconds left

This commit is contained in:
Chen Asraf
2023-03-30 09:32:44 +03:00
parent a64b26bf04
commit 1d9550c85f
4 changed files with 14 additions and 1 deletions

3
.markdownlint.json Normal file
View File

@@ -0,0 +1,3 @@
{
"MD024": false
}

View File

@@ -1,5 +1,11 @@
# CHANGELOG
## v0.2.3
### Features
- Reset last played for videos when there are <10 seconds left to watch
## v0.2.2
### Features

View File

@@ -1,7 +1,7 @@
{
"name": "fp-max-extension",
"private": true,
"version": "0.2.2",
"version": "0.2.3",
"repository": "https://github.com/chenasraf/fp-max-extension",
"type": "module",
"license": "MIT",

View File

@@ -66,6 +66,10 @@ function lastPlayedUpdateCallback(vid: HTMLVideoElement, vidId: string): () => v
const key = `lastPlayed-${vidId}`
chrome.storage.sync.get([key], (result) => {
if (Math.floor(result[key]) === Math.floor(vid.currentTime)) return
if (vid.currentTime >= vid.duration - 10) {
chrome.storage.sync.remove([key])
return
}
chrome.storage.sync.set({
[`lastPlayed-${vidId}`]: vid.currentTime,
})