Paramount+ Links

Adds an "Episode Links" button to Paramount+ shows pages to quickly obtain links for each season. These links can be used for downloading the episodes or other purposes.

As of 30/09/2021. See the latest version.

// ==UserScript==
// @name        Paramount+ Links
// @include     https://www.paramountplus.com/shows/*
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @version     1.0.1
// @grant       GM_addStyle
// @description Adds an "Episode Links" button to Paramount+ shows pages to quickly obtain links for each season. These links can be used for downloading the episodes or other purposes.
// @namespace https://greasyfork.org/users/700756
// ==/UserScript==

GM_addStyle(
    ".modal {" +
    "display: none;" +
    "position: fixed;" +
    "z-index: 1;" +
    "left: 0;" +
    "top: 0;" +
    "width: 100%;" +
    "height: 100%;" +
    "overflow: auto;" +
    "background-color: rgb(0,0,0);" +
    "background-color: rgba(0,0,0,0.4);" +
    "}" +

    ".modal-content {" +
    "background-color: #fefefe;" +
    "margin: 15% auto;" +
    "padding: 20px;" +
    "border: 1px solid #888;" +
    "width: 80%;" +
    "}" +

    ".linksBox {"+
    "width: 100%;" +
    "height: 300px" +
    "}" +

    ".close {" +
    "color: #aaa;" +
    "float: right;" +
    "font-size: 28px;" +
    "font-weight: bold;" +
    "}" +

    ".close:hover," +
    ".close:focus {" +
    "color: black;" +
    "text-decoration: none;" +
    "cursor: pointer;" +
    "}" +

    ".links-button {" +
    "top: 5px;" +
    "display: none;" +
    "}"
);

function modifyUI(){
    $(document.body).append('<div id="myModal" class="modal">' +
                            '<div class="modal-content">' +
                            '<span class="close">&times;</span>' +
                            '<textarea id="linksTxt" class="linksBox" readonly="readonly"></textarea>' +
                            '</div>' +
                            '</div>');
    $(".cta-box").append('<a id="linksBtn" class="links-button button">' +
                         '<div class="button__text">Episode Links</div>' +
                         '</a>');
    $(document).on('keyup', e => {
        if (e.key == "Escape"){
            $("#myModal").css("display", "none");
        }
    });
    $("#linksBtn").click(() => {
        let $videos = $(".link.vilynx-redirect");
        let links = "";
        $videos.each( (index,element) => {
            let $element = $(element);
            links += $element.prop("href");
            links += "\n";
        });
        $("#linksTxt").val(links);
        $("#myModal").css("display", "block");
    });

    $(".close").click(() => {
        $("#myModal").css("display", "none");
    });

    window.onclick = function(event) {
        if (event.target == $("#myModal")) {
            $("#myModal").css("display", "none");
        };
    }
}

$(document).ready(() => {
    let mutationObserver = new MutationObserver( (mutations, me) => {
        let $showMoreButton = $(".load-more-container-show > .load-more-button");
        if ($showMoreButton.length){
            $showMoreButton.get(0).click();
        }
        else {
            $("#linksBtn").css("display", "block");
            me.disconnect();
        }
    });
    mutationObserver.observe(document, {
        childList : true,
        subtree : true
    });
    modifyUI();
});