diff --git a/aria2xspf.toml b/aria2xspf.toml new file mode 100644 index 0000000..663dab7 --- /dev/null +++ b/aria2xspf.toml @@ -0,0 +1,3 @@ +[include] +js = ["https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.0/jquery.min.js", "https://raw.githubusercontent.com/shimunn/aria2xspf/include/js/resume.js"] +css = [] diff --git a/js/resume.js b/js/resume.js new file mode 100644 index 0000000..e998151 --- /dev/null +++ b/js/resume.js @@ -0,0 +1,22 @@ +(function($, window) { + $(window).on('load', function() { + $("video").each(function(e) { + var src = this.currentSrc; + console.log(src); + var start = window.localStorage[btoa(src)]; + if (start) { + this.currentTime = parseFloat(start); + } + }); + }); + setInterval(function() { + $("video").each(function(e) { + var src = this.currentSrc; + var time = this.currentTime; + if (time) { + window.localStorage[btoa(src)] = time; + console.log("Persisted video progress at: " + time); + } + }); + }, 5000); +}($, window));