Planet Romeo - Poor Men's Plus

Restores blur out tiles on the Planet Romeo visitors tab for non-plus users

当前为 2021-03-30 提交的版本,查看 最新版本

// ==UserScript==
// @name         Planet Romeo - Poor Men's Plus
// @namespace    https://greasyfork.org/de/users/7597-djamana
// @version      1.0
// @description  Restores blur out tiles on the Planet Romeo visitors tab for non-plus users
// @author       Djamana
// @match        *://*.planetromeo.com/*
// @grant        none

// ==/UserScript==


(function() {


    let oldXHROpen = window.XMLHttpRequest.prototype.open;

    window.XMLHttpRequest.prototype.open = function(method, url, async, user, password) {

 // do something with the method, url and etc.
    this.addEventListener('load', function() {

 // do something with the response text
    //  console.log('load: ' + this.responseText);


     isResponseAString = (typeof this.response === "string")
     try {
         this.xhr =  this.response

         if ( isResponseAString )
            this.xhr = JSON.parse( this.xhr )

         // remove displaylimit in visitors tab       <- that's the core patch !
         if  ( this.xhr.items_limited ) {
             delete  this.xhr.items_limited;
         }


         try {
             // cosmetic patch #1 (not really needed)
             if  ( this.xhr.is_plus == false ) {
                 debugger
                 this.xhr.is_plus  = true
                 this.is_free_plus = true // maybe not needed
                 this.xhr.payment_group="PLUS"
             }

             // cosmetic patch #2 (not really needed)
             if  ( this.xhr.inferface ) {
                 debugger
                 this.xhr.show_plus_badge = true // maybe not needed
                 this.xhr.show_ads = false  // maybe not needed
             }

             // cosmetic patch #3 (not really needed)
             if  ( this.xhr.show_plus_badge ) {
                 debugger
                 this.xhr.show_plus_badge = true // maybe not needed
             }
         }  catch (e) {
         debugger
         console.log("Userscript_PoorMansPlus (cosmetic patches) - ERROR: " + e)
     }



         // make responseText writeable
         Object.defineProperty(this, 'responseText', {
            writable: true
         });


         // set responseText
         if ( isResponseAString )
             this.responseText = JSON.stringify( this.xhr )
         else
             this.responseText =  this.xhr

     }  catch (e) {
         debugger
         console.log("Userscript_PoorMansPlus ERROR: " + e)
     }


 });

 return oldXHROpen.apply(this, arguments);
}


})();






// Older stuff XHR-Proxy
/*
    (function(window) {
debugger
    var OriginalXHR = XMLHttpRequest;

    var XHRProxy = function() {
        this.xhr = new OriginalXHR();

        function delegate(prop) {
            Object.defineProperty(this, prop, {
                get: function() {
                    return this.xhr[prop];
                },
                set: function(value) {
                    this.xhr.timeout = value;
                }
            });
        }
        delegate.call(this, 'timeout');
        delegate.call(this, 'responseType');
        delegate.call(this, 'withCredentials');
        delegate.call(this, 'onerror');
        delegate.call(this, 'onabort');
        delegate.call(this, 'onloadstart');
        delegate.call(this, 'onloadend');
        delegate.call(this, 'onprogress');
    };
    XHRProxy.prototype.open = function(method, url, async, username, password) {
        var ctx = this;

        function applyInterceptors(src) {
            ctx.responseText = ctx.xhr.responseText;
            for (var i=0; i < XHRProxy.interceptors.length; i++) {
                var applied = XHRProxy.interceptors[i](method, url, ctx.responseText, ctx.xhr.status);
                if (applied !== undefined) {
                    ctx.responseText = applied;
                }
            }
        }
        function setProps() {
            ctx.readyState = ctx.xhr.readyState;
            ctx.responseText = ctx.xhr.responseText;
            ctx.responseURL = ctx.xhr.responseURL;
            ctx.responseXML = ctx.xhr.responseXML;
            ctx.status = ctx.xhr.status;
            ctx.statusText = ctx.xhr.statusText;
        }

        this.xhr.open(method, url, async, username, password);

        this.xhr.onload = function(evt) {
            if (ctx.onload) {
                setProps();

                if (ctx.xhr.readyState === 4) {
                     applyInterceptors();
                }
                return ctx.onload(evt);
            }
        };
        this.xhr.onreadystatechange = function (evt) {
            if (ctx.onreadystatechange) {
                setProps();

                if (ctx.xhr.readyState === 4) {
                     applyInterceptors();
                }
                return ctx.onreadystatechange(evt);
            }
        };
    };
    XHRProxy.prototype.addEventListener = function(event, fn) {
        return this.xhr.addEventListener(event, fn);
    };
    XHRProxy.prototype.send = function(data) {
        return this.xhr.send(data);
    };
    XHRProxy.prototype.abort = function() {
        return this.xhr.abort();
    };
    XHRProxy.prototype.getAllResponseHeaders = function() {
        return this.xhr.getAllResponseHeaders();
    };
    XHRProxy.prototype.getResponseHeader = function(header) {
        return this.xhr.getResponseHeader(header);
    };
    XHRProxy.prototype.setRequestHeader = function(header, value) {
        return this.xhr.setRequestHeader(header, value);
    };
    XHRProxy.prototype.overrideMimeType = function(mimetype) {
        return this.xhr.overrideMimeType(mimetype);
    };

    XHRProxy.interceptors = [];
    XHRProxy.addInterceptor = function(fn) {
        this.interceptors.push(fn);
    };

    window.XMLHttpRequest = XHRProxy;




          XHRProxy.addInterceptor(function(method, url, responseText, status) {
           console.log( url );
        debugger

        if (url.endsWith('.html') || url.endsWith('.htm')) {
            return "<!-- HTML! -->" + responseText;
        } else {
            return responseText;
        }

    });


})(window);
*/



/*
(function(open) {

    XMLHttpRequest.prototype.open = function() {
        this.addEventListener("readystatechange", function() {
            console.log(this.readyState);
            if (this.readyState==4) {

               try {
                   this.xhr = JSON.parse( this.response )

                   this.xhr.is_plus = true
                   this.xhr.items_limited = 0
debugger



                   this.responseText = JSON.stringify( this.xhr )
               }  catch (e) {
               }
            }
        }, false);
        open.apply(this, arguments);

    };
})( XMLHttpRequest.prototype.open );
*/