From 26319192f388b279e8665277f7a86d87b5bb4a37 Mon Sep 17 00:00:00 2001 From: Desnoo Date: Sun, 23 Aug 2015 23:33:45 +0200 Subject: [PATCH] added cookie support for volume --- proxerhdvideocontrols.user.js | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/proxerhdvideocontrols.user.js b/proxerhdvideocontrols.user.js index 82ee381..4426c5f 100644 --- a/proxerhdvideocontrols.user.js +++ b/proxerhdvideocontrols.user.js @@ -9,6 +9,8 @@ // @run-at document-end // ==/UserScript== +var volumeCookieName = "hd-vol"; + var volumeStep = 0.01; var durationProgressStep = 5; var skipDurationOpening = 70; @@ -20,16 +22,24 @@ var arrowRight = 39; var k = 75; var l = 76; + document.domain = 'proxer.me'; $(document).ready(function (e) { var isFullScreen = false; var $video = $('video'); - if ($video[0] == undefined) { + if ($video[0] === undefined) { console.log('Video reference not found.'); return; } + var videoReference = $video[0]; + setVolumeByCookie(videoReference); + + $video.on('volumechange', function(e){ + document.cookie = volumeCookieName + "=" + videoReference.volume; + }); + $video.on('canplay', function () { $video.on('SkipTime', function (e, timeToSkip) { videoReference.currentTime += timeToSkip; @@ -127,4 +137,20 @@ $(document).ready(function (e) { } } } -}); + // checks and evaluates volume cookie + function setVolumeByCookie(_VideoRef){ + var volume = getCookie(volumeCookieName); + videoReference.volume = volume !== "" ? volume : videoReference.volume; + } + + function getCookie(cname) { + var name = cname + "="; + var ca = document.cookie.split(';'); + for(var i=0; i