PlaysTV Download Helper

helps the user download plays tv videos easier

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         PlaysTV Download Helper
// @namespace    localhost
// @version      1.2
// @description  helps the user download plays tv videos easier
// @author       mydadcutstrees
// @include      *https://web.archive.org*
// @grant        none
// @require      http://code.jquery.com/jquery-3.4.0.min.js
// @license      MIT
// ==/UserScript==

'use strict';

function NavigateToVideo() {
    //guard clause
    if(!$('#searchHome > form > button:nth-child(2)').length) return;

    //navigate to video
    var rawURL = window.location.href; //get url
    var rawURL_trimmed = rawURL.split('?from=user')[0]; //trim url
    window.location.href = rawURL_trimmed; //navigate to url
}

function GetVideoSource() {
    //get video source
    var baseURL = window.location.href.split('/https://plays.tv/video')[0];
    var videoURL = ($("#A > div:nth-child(1) > div > div.bd > ul > li > div:nth-child(2) > div.video > div > video > source:nth-child(1)").prop('src'));
    var VideoSource = baseURL + 'im_/' + videoURL;
    return VideoSource;
}

function GetVideoTitle() {
    //get video title
    var videoTitle = $('#A > div:nth-child(1) > div > div.bd > ul > li > div:nth-child(2) > div.lower-wrap > div.video-info > div > p > span').html().trim();
    return videoTitle;
}

function SaveVideo(VideoSource, videoTitle) {
    //guard clause
    if(!$('#A > div:nth-child(1) > div > div.bd > ul > li > div:nth-child(2) > div.lower-wrap > div:nth-child(2) > div > div.social-line > div.social > div.social-btn-wrapper.reactions > button.social-btn.react-text.text.icn-before > span').length) return;

    //download video
    var a = document.createElement("a");
    a.href = VideoSource;
    a.setAttribute("download", videoTitle + ".mp4");
    a.click();
}

//run it
NavigateToVideo();
SaveVideo(GetVideoSource(), GetVideoTitle());