Raw Source
vanarok / hj5ftug4

// ==UserScript==
// @name        hj5ftug4
// @namespace   hj5ftug4
// @description hj5ftug4
// @include     https://wasd.tv/*
// @version     1
// @grant       GM_xmlhttpRequest
// @run-at      document-start
// @updateURL https://openuserjs.org/meta/vanarok/Test.meta.js
// @downloadURL https://openuserjs.org/install/vanarok/Test.user.js
// @license MIT
// ==/UserScript==

var a1 = /pause\(\){this\.videoPlayer\.nativeElement\.pause\(\),this\.isLive&&\(this\.stopChunks=!0,this\.playerHls&&this\.playerHls\.stopLoad\(\)\),this\.playing=h\.a\.PAUSING,this\.onStopStream\(\)}/g;
var a2 = /onViewStream\(\){this\.streamViewsInterval\|\|\(this\.streamViewsInterval=setInterval\(\(\)=>{this\.streamsService\.streamViews\(this\.stream\.streamId,this\.viewTime\)\.pipe\(Object\(a\.a\)\(\(\)=>this\.playing===h\.a\.RUNNING\)\)\.subscribe\(\),this\.viewTime=0,this\.dataLayerEventHasBeenSent\|\|this\.pushDataLayer\(\)},this\.viewTimeInterval\)\)}/g
var a3 = /play\(\){if\(this\.isPlaying\|\|this\.adsService.ads\)return!1;this.stopChunks&&this.isLive\?\(this.playerHls.detachMedia\(\),this\.playerHls.attachMedia\(this\.videoPlayer.nativeElement\),this.stopChunks=!1\):this.videoPlayer.nativeElement.play\(\).then\(\(\)=>{setTimeout\(\(\)=>{this\.playing=h\.a.RUNNING},500\),this.info=null,this.playError=0,this.onStartStream\(\)}\)\.catch\(e=>{this\.playing=h\.a\.PAUSING,this\.stream.muted=!0,this.playError=this\.playError\+1,this\.playError<5\?setTimeout\(\(\)=>this\.play\(\),500\):this\.info=".*0442"}\)}/g
var b = "main-es2015.(.*).js"


function addScript(text) {
    text = text.replace(a1, "pause(){this.videoPlayer.nativeElement.pause()}");
    text = text.replace(a2, "onViewStream\(\){this\.streamViewsInterval\|\|\(this\.streamViewsInterval=setInterval\(\(\)=>{this\.streamsService\.streamViews\(this\.stream\.streamId,this\.viewTime=60\)\.pipe\(Object\(a\.a\)\(\(\)=>this\.playing===h\.a\.RUNNING\)\)\.subscribe\(\),this\.viewTime=0,this\.dataLayerEventHasBeenSent\|\|this\.pushDataLayer\(\)},this\.viewTimeInterval\)\)}");
    text = text.replace(a3, "play(){setTimeout(()=>{this.playing=h.a.RUNNING},500),this.info=null,this.playError=0,this.onStartStream()}");
    var newScript = document.createElement('script');
    newScript.type = "text/javascript";
    newScript.textContent = text;
    var head = document.getElementsByTagName('head')[0];
    head.appendChild(newScript);
    console.log('МРАЗЬ РАБОТАЮ')
}

window.addEventListener('beforescriptexecute', function(e) {
    var src = e.target.src;
    if (src.search(b) != -1) {
        console.log('succes')
        e.preventDefault();
        e.stopPropagation();
        GM_xmlhttpRequest({
            method: "GET",
            url: e.target.src,
            onload: function(response) {
                addScript(response.responseText);
            }
        });

    }
});