Songsterr Premium - Fix for Logged In Users

Modified version to enable premium features also when the user is logged in.

// ==UserScript==
// @name         Songsterr Premium - Fix for Logged In Users
// @namespace    https://github.com/Thibb1
// @match        https://songsterr.com/*
// @match        https://www.songsterr.com/*
// @grant        none
// @run-at       document-start
// @version      1.4.1
// @author       Thibb1 (modified by vmtias_)
// @description  Modified version to enable premium features also when the user is logged in.
// @license      GPL
// ==/UserScript==

/*
  Original script created by Thibb1:
  https://greasyfork.runtimutd.eu.org/scripts/469079-songsterr-premium-songsterrcom

  This version was modified by vmtias_ to extend functionality and allow premium features
  to be unlocked even when the user is logged in.

  Full credit to the original author for the base implementation.

  ⚠️ Note: If you try to export the tab to Guitar Pro, the download will not start immediately.
  It may take a few seconds, so please be patient.⚠️
*/



(function() {
    'use strict';

    
    const originalFetch = window.fetch;
    window.fetch = async function(input, init) {
        const response = await originalFetch(input, init);

        // Intercept profile JSON response
        if (typeof input === 'string' && input.includes('/auth/profile')) {
            const cloned = response.clone();
            const originalJson = response.json.bind(response);
            response.json = async function() {
                const data = await originalJson();
                data.plan = 'plus';
                data.hasPlus = true;
                return data;
            };
            return response;
        }

        return response;
    };

    
    const open = XMLHttpRequest.prototype.open;
    XMLHttpRequest.prototype.open = function(method, url) {
        this._url = url;
        return open.apply(this, arguments);
    };

    const send = XMLHttpRequest.prototype.send;
    XMLHttpRequest.prototype.send = function() {
        this.addEventListener('readystatechange', function() {
            if (this.readyState === 4 && this._url?.includes('/auth/profile') && this.responseType === 'json') {
                try {
                    const data = JSON.parse(this.responseText);
                    data.plan = 'plus';
                    data.hasPlus = true;
                    Object.defineProperty(this, 'responseText', { value: JSON.stringify(data) });
                } catch {}
            }
        });
        return send.apply(this, arguments);
    };

 
    window.addEventListener("DOMContentLoaded", () => {
        const stateElement = document.querySelector('#state');
        if (stateElement) {
            stateElement.textContent = stateElement.textContent
                .replace('"hasPlus":false', '"hasPlus":true')
                .replace('"plan":"free"', '"plan":"plus"');
        }
    });

   
    window.addEventListener('load', () => {
        const banner = document.querySelector('#showroom') || document.querySelector('#showroom_header');
        banner?.removeAttribute('id');
        banner?.removeAttribute('class');
    });
})();