cvzi/Rottentomatoes-userscript

Audience Score (Use algolia.com-API)

Closed this issue · 2 comments

cvzi commented

I've checked out the rottentomatoes site and I found when I type in the search field, the search results appear in a drop down manner.
They use another API for these search results and I can probably use that API for this script. I think last time someone requested the user score for this script, that was not the case (or I missed it).

Here as example request:
https://www.codepunker.com/tools/http-requests/649221-0mi9ljx

JS code
GM.xmlHttpRequest({
  method: 'POST',
  url: "https://79frdp12pn-dsn.algolia.net/1/indexes/*/queries?x-algolia-agent=Algolia%20for%20JavaScript%20(4.12.0)%3B%20Browser%20(lite)&x-algolia-api-key=XXXX&x-algolia-application-id=YYYY",
  data: '{"requests":[{"indexName":"content_rt","query":"better call s","params":"filters=rtId%20%3E%200%20AND%20isEmsSearchable%20%3D%201&hitsPerPage=20"}]}',
  onload: function (response) {
    console.log(response)
  },
  onerror: function (response) {
    console.log(response)
  }
})

Which returns (among other stuff) the following data:

{
    "results":
    [
        {
            "hits":
            [
                {
                    "emsId": "81d34ca7-4d1e-375b-bb29-ae6f3446d270",
                    "tmsId": "SH018632100000",
                    "rtId": 3150,
                    "type": "tv",
                    "title": "Better Call Saul",
                    "titles":
                    [
                        "Better Call Saul",
                        "Call Saul"
                    ],
                    "vanity": "better_call_saul",
                    "description": "Six years before Saul Goodman meets Walter White, he is known as small-time lawyer Jimmy McGill.",
                    "rottenTomatoes":
                    {
                        "audienceScore": 96,
                        "criticsIconUrl": "https://content6.flixster.com/static/images/rt-icons/fresh.png",
                        "audienceIconUrl": "https://content6.flixster.com/static/images/rt-icons/red_popcorn.png",
                        "criticsScore": 98
                    },
                    "fnowTitle": "Better Call Saul"
                }
            ]
        }
    ]
}

Original post: https://greasyfork.org/en/scripts/35443-show-rottentomatoes-meter/discussions/116087

cvzi commented

Added in Version 26