Last active
August 29, 2015 14:18
-
-
Save MisterGlass/09f7d677b769eaf7f33f to your computer and use it in GitHub Desktop.
User script that adds a download link to Tested.com premium videos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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