diff options
author | Dainius Daukševičius <[email protected]> | 2020-10-15 20:15:11 +0300 |
---|---|---|
committer | Dainius Daukševičius <[email protected]> | 2020-10-15 20:15:11 +0300 |
commit | 5bc12e52f3ceddb817400724bd3ddd78d3f51f78 (patch) | |
tree | f1ec5d5f824b48e9bced468dd0ee154bbf89efcb /src/content.ts | |
parent | 4dc4160215b14040c879adbca27365000953d2f9 (diff) | |
download | SponsorBlock-5bc12e52f3ceddb817400724bd3ddd78d3f51f78.tar.gz SponsorBlock-5bc12e52f3ceddb817400724bd3ddd78d3f51f78.zip |
remove js-sha256 dependency, use native hashing function
Diffstat (limited to 'src/content.ts')
-rw-r--r-- | src/content.ts | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/content.ts b/src/content.ts index a2911f9a..fe149d90 100644 --- a/src/content.ts +++ b/src/content.ts @@ -544,7 +544,7 @@ function incorrectVideoCheck(videoID?: string, sponsorTime?: SponsorTime): boole } } -function sponsorsLookup(id: string) { +async function sponsorsLookup(id: string) { video = document.querySelector('video') // Youtube video player //there is no video here if (video == null) { @@ -569,7 +569,7 @@ function sponsorsLookup(id: string) { updateAdFlag(); // Make sure it doesn't get double called with the playing event - if (Math.abs(lastCheckVideoTime - video.currentTime) > 0.3 + if (Math.abs(lastCheckVideoTime - video.currentTime) > 0.3 || (lastCheckVideoTime !== video.currentTime && Date.now() - lastCheckTime > 2000)) { lastCheckTime = Date.now(); lastCheckVideoTime = video.currentTime; @@ -580,7 +580,7 @@ function sponsorsLookup(id: string) { }); video.addEventListener('playing', () => { // Make sure it doesn't get double called with the play event - if (Math.abs(lastCheckVideoTime - video.currentTime) > 0.3 + if (Math.abs(lastCheckVideoTime - video.currentTime) > 0.3 || (lastCheckVideoTime !== video.currentTime && Date.now() - lastCheckTime > 2000)) { lastCheckTime = Date.now(); lastCheckVideoTime = video.currentTime; @@ -592,7 +592,7 @@ function sponsorsLookup(id: string) { if (!video.paused){ // Reset lastCheckVideoTime lastCheckTime = Date.now(); - lastCheckVideoTime = video.currentTime; + lastCheckVideoTime = video.currentTime; startSponsorSchedule(); } @@ -621,7 +621,8 @@ function sponsorsLookup(id: string) { // Check for hashPrefix setting let getRequest; if (Config.config.hashPrefix) { - getRequest = utils.asyncRequestToServer('GET', "/api/skipSegments/" + utils.getHash(id, 1).substr(0,4), { + const hashPrefix = (await utils.getHash(id, 1)).substr(0, 4); + getRequest = utils.asyncRequestToServer('GET', "/api/skipSegments/" + hashPrefix, { categories }); } else { |