Skip to content

Commit

Permalink
added cookie support for volume
Browse files Browse the repository at this point in the history
  • Loading branch information
Desnoo committed Aug 23, 2015
1 parent ccd0a3e commit 2631919
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions proxerhdvideocontrols.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
// @run-at document-end
// ==/UserScript==

var volumeCookieName = "hd-vol";

var volumeStep = 0.01;
var durationProgressStep = 5;
var skipDurationOpening = 70;
Expand All @@ -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;
Expand Down Expand Up @@ -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<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)===' ') c = c.substring(1);
if (c.indexOf(name) === 0) return c.substring(name.length,c.length);
}
return "";
}
});

0 comments on commit 2631919

Please sign in to comment.