unlock lpsg videos

unlock lpsg video access. may need to manually switch video format since I can't figure out a way to find it.

Stan na 03-10-2023. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         unlock lpsg videos
// @namespace    MBing
// @version      1.2
// @description  unlock lpsg video access. may need to manually switch video format since I can't figure out a way to find it.
// @author       MBing
// @match        https://www.lpsg.com/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @license            MIT
// ==/UserScript==

(function() {
    'use strict';

var easterEggBlocker = document.getElementsByClassName("video-easter-egg-blocker");
var easterEggOverlay = document.getElementsByClassName("video-easter-egg-overlay");
var easterEggPoster = document.getElementsByClassName("video-easter-egg-poster");
var easterEggPosterReplacement=[];
var imageUrl;
var videoUrl;
for (var i=easterEggPoster.length-1;i>-1;i--){
	void(imageUrl =easterEggPoster[i].children[0].src);
	void(videoUrl=imageUrl.replace("attachments/posters","video").replace("/lsvideo/thumbnails","lsvideo/videos").replace(".jpg",".mp4"));
	void(easterEggPosterReplacement[i]=`<video controls=\"\" data-xf-init=\"video-init\" data-poster=\"${imageUrl}\" class=\"\" style=\"\" poster=\"${imageUrl}\"><source data-src=\"${videoUrl}\" src=\"${videoUrl}\"><div class=\"bbMediaWrapper-fallback\">Your browser is not able to display this video.</div></video>`);
	void(easterEggPoster[i].innerHTML=easterEggPosterReplacement[i]);

    easterEggPoster[i].parentElement.parentElement.append(createButton("mov",i));
    easterEggPoster[i].parentElement.parentElement.append(createButton("m4v",i));
    easterEggPoster[i].parentElement.parentElement.append(createButton("mp4",i));
}

for (i=easterEggOverlay.length-1;i>-1;i--){
	void(easterEggOverlay[i].parentElement.removeChild(easterEggOverlay[i]));

}

for (i=easterEggBlocker.length-1;i>-1;i--){
	void(easterEggBlocker[i].parentElement.removeChild(easterEggBlocker[i]));

}

function createButton(format,entryId){
        var inp;
        inp = document.createElement("input");
        inp.type = "button";
        inp.value = format;
        inp.id = entryId;
        inp.addEventListener('click', function () {
            var oldUrl = document.getElementsByClassName("video-easter-egg-poster")[this.id].innerHTML;
            document.getElementsByClassName("video-easter-egg-poster")[this.id].innerHTML=oldUrl.replaceAll("mp4",format).replaceAll("m4v",format).replaceAll("mov",format);
        });
        return inp;
    }

})();