Skip to content

Instantly share code, notes, and snippets.

@jonasjancarik
Last active December 16, 2019 15:18
Show Gist options
  • Save jonasjancarik/d4b4c24dcbebfad34e38ebd3241439e8 to your computer and use it in GitHub Desktop.
Save jonasjancarik/d4b4c24dcbebfad34e38ebd3241439e8 to your computer and use it in GitHub Desktop.
DVTV Playback Speed Controls (userscript)
// ==UserScript==
// @name DVTV Playback Speed Controls
// @namespace http://tampermonkey.net/
// @version 0.3
// @description Adds playback speed controls to the DVTV video player
// @author You
// @match https://video.aktualne.cz/dvtv/*
// @grant none
// ==/UserScript==
// the guts of this userscript
(function () {
var videoId = $('.video-social__btn--audio').attr('href').split('/').pop().split('.')[0]
var cdnBaseUrl = $('.video-social__btn--audio').attr('href').replace('.mp3', '')
var videoIdAnalytics = $('video').attr('id').replace('embed', '').split('_')[0]
console.log(cdnBaseUrl)
var videoPoster = $('video').attr('poster')
$('.article').prepend(`<video
id="videoWithSpeedControl"
class="embed-player video-js vjs-ott-skin vjs-16-9"
controls
playsinline
poster="${videoPoster}"
width="782"
height="440"
></video>`)
BBXPlayer.id = "videoWithSpeedControl";
var newVideoConfig = {
"autoplay": false,
playbackRates: [0.5, 1, 1.25, 1.5, 2],
"preferredLang": ["cze", "en"],
"language": "cs",
"duration": 680,
"title": "",
"tracks": {
"HLS": [{ "src": cdnBaseUrl.replace('/vod/', '/hls/') + "_,180,360,480,720,1080,.mp4.urlset\/master.m3u8", "type": "application\/vnd.apple.mpegurl", "label": "adaptive" }],
"DASH": [{ "src": cdnBaseUrl.replace('/vod/', '/dash/') + "_,180,360,480,720,1080,.mp4.urlset\/manifest.mpd", "type": "application\/dash+xml", "label": "adaptive" }],
"MP4": [
{ "src": cdnBaseUrl + "_1080.mp4", "type": "video\/mp4", "label": "1080p" },
{ "src": cdnBaseUrl + "_720.mp4", "type": "video\/mp4", "label": "720p" },
{ "src": cdnBaseUrl + "_480.mp4", "type": "video\/mp4", "label": "480p" },
{ "src": cdnBaseUrl + "_360.mp4", "type": "video\/mp4", "label": "360p" },
{ "src": cdnBaseUrl + "_180.mp4", "type": "video\/mp4", "label": "180p" }
]
}, "adverttime": -1,
"mediaid": videoIdAnalytics,
"ads": true,
"single": true,
"startTime": 0,
"debug": true,
"plugins": {
"playedTicks": {},
"tracking": {},
"settings": { "qualities": {} },
"measuring": {
"streamInfo":
{
"programID": videoIdAnalytics,
"programName": "",
"programType": "video",
"series": "DVTV",
"programDuration": 680,
"videoID": videoIdAnalytics,
"premiereDate": "20191208"
},
"services": {
"gemius": {
"playerID": "embed" + videoIdAnalytics, "accountID": "zU2aoeepfyJK4blK4Y4azGZUDmyNkcMAjJOP1xqs2rD.r7"
}
}
}, "OnTheIoTracking": {}
}
}
BBXPlayer.setup(newVideoConfig);
BBXPlayer.runSetup();
$('.vjs-playback-rate').css('right', '155px')
$('.vjs-vpaid--fixer').remove()
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment