Greasy Fork is available in English.

Show Saved Video's Position | Invidious

show position where you stopped watching video at thumbnails. (Don't forget to turn on that function!)

// ==UserScript==
// @name Show Saved Video's Position | Invidious
// @description show position where you stopped watching video at thumbnails. (Don't forget to turn on that function!)
// @namespace -
// @version 1.0.2
// @author NotYou
// @include *://invidious.snopyta.org/*
// @include *://yewtu.be/*
// @include *://invidious.kavin.rocks/*
// @include *://vid.puffyan.us/*
// @include *://invidious.namazso.eu/*
// @include *://inv.riverside.rocks/*
// @include *://youtube.076.ne.jp/*
// @include *://yt.artemislena.eu/*
// @include *://invidious.flokinet.to/*
// @include *://invidious.esmailelbob.xyz/*
// @include *://invidious.projectsegfau.lt/*
// @include *://inv.bp.projectsegfau.lt/*
// @include *://y.com.sb/*
// @include *://invidious.sethforprivacy.com/*
// @include *://invidious.tiekoetter.com/*
// @include *://invidious.nerdvpn.de/*
// @include *://inv.vern.cc/*
// @include *://invidious.slipfox.xyz/*
// @include *://inv.privacy.com.de/*
// @include *://invidious.rhyshl.live/*
// @include *://invidio.xamh.de/*
// @include *://invidious.dhusch.de/*
// @include *://inv.odyssey346.dev/*
// @include *://c7hqkpkpemu6e7emz5b4vyz7idjgdvgaaa3dyimmeojqbgpea3xqjoid.onion/*
// @include *://w6ijuptxiku4xpnnaetxvnkc5vqcdu7mgns2u77qefoixi63vbvnpnqd.onion/*
// @include *://kbjggqkzv65ivcqj6bumvp337z6264huv5kpkwuv6gu5yjiskvan7fad.onion/*
// @include *://grwp24hodrefzvjjuccrkw3mjq4tzhaaq32amf33dzpmuxe7ilepcmad.onion/*
// @include *://osbivz6guyeahrwp2lnwyjk2xos342h4ocsxyqrlaopqjuhwn2djiiyd.onion/*
// @include *://u2cvlit75owumwpy4dj2hsmvkq7nvrclkpht7xgyye2pyoxhpmclkrad.onion/*
// @include *://euxxcnhsynwmfidvhjf6uzptsmh4dipkmgdmcmxxuo7tunp3ad2jrwyd.onion/*
// @include *://invidious.esmail5pdn24shtvieloeedh7ehz3nrwcdivnfhfcedl7gf4kwddhkqd.onion/*
// @include *://inv.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion/*
// @include *://am74vkcrjp2d5v36lcdqgsj2m6x36tbrkhsruoegwfcizzabnfgf5zyd.onion/*
// @include *://ng27owmagn5amdm7l5s3rsqxwscl5ynppnis5dqcasogkyxcfqn7psid.onion/*
// @include *://verni6dr4qxjgjumnvesxerh5rvhv6oy5ddeibaqy5d7tgbiiyfa.b32.i2p/*
// @license GPL-3.0-or-later
// @grant none
// @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAKaElEQVRo3r1aSWwb5xX+/n/ImeFiStZCLRTlRaIoUYutOHbs2LJTJwUKI20kk0KDJDaQQ3vJoTkk3Y8p0LTopT0VQVAgQOwspNXWByOHprYWO0ZtRQ7pkWHYsSSSokRS1EJRIjXD/+/Blmpbiy1x0ncZgPP+9973vjf/8n4S6CidnZ0CACvnvOjBU3rwKkcImSeEzBFC5nt6ejS9fJJCBnu9XprP5+0AWimlzxqNxhZJknZIklQmSZJFEAQjAOTzeXVpaWkhm81O5XK5UVVVQ4yxawC+EQRhMhAIsP8rAK/Xa2aMPScIQte2bdu+V1lZWed0Ok01NTUoKyuDzWaDLMsQBAGEEGiahlwuh7m5OSSTSUSjUYyNjWUnJibupdPpi5qm9VBKrwQCgfnvFIDP5zPl8/mXJEn6aXV19dHW1lZbS0sLHA4HzGYzKKUrupzzRx0RsvJkjGFhYQHj4+MIhUIIBoPz0Wi0P5vNfiAIwhd+vz+jK4DTp0+T+fn5PQaD4edOp/NHhw8ftrS3t6OkpASEEHDOVwX8RMeErIydmZnB0NAQBgYGFkZHRy+oqvq+yWS69vHHHz/R6BMBdHd3y/l8/vT27dt/ffjw4R0vvPACysrKth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2+0mZrN5XRAmkwlFRUWwWq2wWCybmgAopbBarbDZbJAkaU2d5br/5JNPeCgU+hsh5L1PP/106WGdVQAURdGam5uvxuPxmmQy2VpfX78hiEL3UBuVzezsLD777DNcu3btHOf8Hb/fP/243pq9Y0VRFj0ez0AsFquIxWItTqeT6tkzepJQSjExMYGzZ8+ywcHBzxljb/v9/om1dNdtfiuKkvF4PBfj8bjh7t27e202m2i323U7/K8ly5d+oVAIZ86cWRweHv4r5/wXfr9/cr0xG3bvFUXJtrS09KZSqbFbt261pNPpkuXzrp4nK0IIKKVIJpO4cOECzp8/PzI+Pv5bSumf/H7/3IZjn9bJyZMnmwVBeMfhcJw8dOiQbd++fSgrKwOltOBr1qmpKQwODuLKlSvz4XD4n5qm/dFqtd746KOPCr9mfVh8Pp+Uz+ePiaL4k8rKypeam5uLW1tb4XQ6YbFYIAj/I3S9i27g/sYuk8kgEokgFAohFArNxmKxi7lc7gNBEL70+/2LT52ITaXtgXi9Xpkxto9S+orVan2poqLC5XA4rDU1NSgvL0dRURFkWV5Z1DRNQzabxdzcHBKJBKLRKCKRSGZycvLu/Pz8v/L5/N8ppdcCgcDCZmMpqJC7u7uJpmmlnHMPIeQZo9HYJoriTkmSykVRND/0Zw9NVdWFXC6XzOVyI6qqfsM5HySEKIIgJPx+/5anN117HJ2dnRSAmXO+jXNuBrC8r9AIIYuEkDQhJNPT06Pbne1/Acmz+r5w/zPmAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE5LTA0LTE0VDEzOjEwOjM5LTA0OjAwzYrzKwAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxOS0wNC0xNFQxMzoxMDozOS0wNDowMLzXS5cAAAAASUVORK5CYII=
// ==/UserScript==

let thumbs = document.querySelectorAll('div.thumbnail')
let style = `.progress-bar {
  width: var(--percentage);
  display: block;
  height: 4.5px;
  pointer-events: none;
  position: absolute;
  left: 0;
  bottom: 0;
  background: rgb(0, 182, 240);
}`
let styleNode = document.createElement('style')
styleNode.textContent = style
document.querySelector('head').appendChild(styleNode)

for (let i = 0; i < thumbs.length; i++) {
    let thumb = thumbs[i]
    let id = thumb.children[0].src.match(/\/vi\/(.*?)\//)[1]
    let total = thumb.children[1]?.textContent.split(':').map((e, i, a) => multiply(e, a.length - (i + 1))).reduce((a, e) => a + +e, 0)
    let percentage = getPositions()[id] / total * 100
    let progress = document.createElement('div')

    if(percentage) {
        thumb.setAttribute('style', '--percentage:' + percentage + '%')
        progress.className = 'progress-bar'
        thumb.appendChild(progress)
    }
}

function getPositions() {
    return JSON.parse(decodeURIComponent(localStorage.getItem('save_player_pos')))
}

function multiply(x, y) {
	for (let i = 0; i < y; i++) {
        x *= 60
    }

    return x
}