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.

As of 03.10.2023. See ბოლო ვერსია.

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 or Violentmonkey 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         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;
    }

})();