Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Long lyrics not loaded any more in petit lyrics #32

Open
jesus2099 opened this issue Feb 5, 2015 · 4 comments
Open

Long lyrics not loaded any more in petit lyrics #32

jesus2099 opened this issue Feb 5, 2015 · 4 comments

Comments

@jesus2099
Copy link
Owner

jesus2099 commented Feb 5, 2015

https://greasyfork.org/en/forum/discussion/3042/long-lyrics-interrupted-at-petitlyrics-com

madauden posted: 1/30/2015

Long lyrics interrupted at Petitlyrics.com

Lyrics are interrupted when they are long enough at Petitlyrics.com.
Open the following page and turn the script on and off to reproduce:
https://petitlyrics.com/lyrics/1009898

@jesus2099 jesus2099 added this to the 2020 milestone Feb 1, 2019
@jesus2099 jesus2099 modified the milestones: 2020, 2021 Aug 27, 2020
@jesus2099 jesus2099 modified the milestones: 2021, 2022 Aug 21, 2021
@forrvalhalla
Copy link

Came here from the comments posted on greasyfork. Hopefully I am posting in the right place (I've never posted on GitHub before) but this still seems to be a problem as of December 2021. At around 15/16 lines it cuts off from the rest of the lyrics that are there normally.

@jesus2099
Copy link
Owner Author

Thank you for your report, @forrvalhalla.
It's the right place.

But I have to learn how my user script works again. I forgot how I coded this, years ago.
Hopefully, I will try within these 2 weeks.

@jesus2099
Copy link
Owner Author

Ach, it seems it will be impossible to fix.
The full lyrics are provided by https://petitlyrics.com/com/get_lyrics.ajax.
Then the content (a table of rows of text, URI encoded then Base 64 encoded).

Here is the decoder:

// https://www.base64decoder.io/javascript/#javascript-generic-base64-decode-with-support-for-16-bit-encoded-utf-16-strings
// Javascript Generic Base64 decode with support for 16-bit encoded (UTF-16) strings
function base64DecodeUnicodeToString(str) {
    // Convert Base64 encoded bytes to percent-encoding, and then get the original string.
	var percentEncodedStr = atob(str).split("").map(function(c) {
		return "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2);
	}).join("");
    return decodeURIComponent(percentEncodedStr);
}

The request is made by https://petitlyrics.com/lyrics/* page in POST and Content-Type: application/x-www-form-urlencoded; charset=UTF-8.
With no query parameters but the big problem is that it should be requested with an X-CSRF-Token.
I don't know how to do that in user script. I don't think it is even possible, as the token has to be generated by server, I guess.

@jesus2099
Copy link
Owner Author

jesus2099 commented Dec 22, 2021

Maybe I can retrieve that data[i].lyrics and BTW I see that they do send a query parameter: lyrics_id.

	$(document).ready(function () {
		eval("var a=\"sjn3hEe0VJLr-q_GZomfbBtIXyNgU4WxFuDHM8v5p2TS7AQdzi.C9lP1k6RcYaK+O@w\";var b=a.split(\"\").sort().join(\"\");var c=\"hrV2EEe3r77E00hrTe32Ve7Jh-3Ae2LJ\";var d=\"\";for(var e=0;e<c.length;e++)d+=b.charAt(a.indexOf(c.charAt(e)));var key = (\"\"+d+\"\");");

// Such a mysterious key!

        $.post(
            "/com/get_lyrics.ajax",
            {
                lyrics_id:1009898
            },
            function(data, textstatus, XMLHttpRequest){

                var len = data.length;
                for(var i=0; i<len; i++){
                    
                    
                    context.font = "12px sans-serif";
                    context.fillText(Base64.decode(data[i].lyrics), 0, (20*i)+20);
                    
                }
                $(".ffrm").hide();$(".ffrm").show();
            }
        );
	});

There are some stuff I still want to check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants