Code Monkey home page Code Monkey logo

Comments (4)

forrvalhalla avatar forrvalhalla commented on June 2, 2024 1

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.

from konami-command.

jesus2099 avatar jesus2099 commented on June 2, 2024

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.

from konami-command.

jesus2099 avatar jesus2099 commented on June 2, 2024

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.

from konami-command.

jesus2099 avatar jesus2099 commented on June 2, 2024

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.

from konami-command.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.