Skip to content

Instantly share code, notes, and snippets.

@MisterGlass
Last active August 29, 2015 14:18
Show Gist options
  • Save MisterGlass/09f7d677b769eaf7f33f to your computer and use it in GitHub Desktop.
Save MisterGlass/09f7d677b769eaf7f33f to your computer and use it in GitHub Desktop.
User script that adds a download link to Tested.com premium videos
// ==UserScript==
// @name Tested Premium add downlaod link
// @namespace http://mrglass.org
// @version 0.1
// @description Adds a download link to tested premium video pages
// @author MrGlass
// @match http://www.tested.com/premium/*
// @grant none
// ==/UserScript==
var player = document.getElementsByClassName('oo-player')[0]; // Find player div
var video_id = player.getAttribute('data-content-id'); // Pull video ID from player div
// Create download link
var link = document.createElement('a');
link.setAttribute('href', 'http://ak.c.ooyala.com/'+video_id+'/DOcJ-FxaFrRg4gtDEwOjEzYzowazumG4'); // This URL formula was based on looking at the source for the mobile player. Liable to break at any time, your mileage may vary
link.setAttribute('download', document.title.replace(/[^a-zA-Z\d ]/g, "")+'.mkv'); // Make the link download instead of opening
link.innerText = "Download MKV";
// Add link to page
var description = document.getElementsByClassName('description')[0];
description.appendChild(document.createElement('br')); // Add a link break before link
description.appendChild(link); // Add it to the description instead of the player div because the player JS modifies its div
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment