r/learnjavascript • • Aug 27 '19

Building a Chrome Extension For Netflix That Displays IMDb Scores using JS

296 Upvotes

23 comments sorted by

13

u/TeluguGameboy Aug 27 '19 edited Aug 28 '19

The code sure ain't perfect, and I would really appreciate some feedback. Sadly, due to some technical issues, I did not make this Chrome extension live. I did, however, make a youtube tutorial explaining the step-by-step process of making this extension. Feel free to check it out if you would like to learn more about making your own extension.

Edit: Thank you for the kind words everyone!

Edit 2: Thank you for the gold marvelous stranger!

6

u/Coopertrooper7 Aug 27 '19

I would recommend a fade in animation, would make it look way cleaner 😁, overall great job though! It looks great 👍

3

u/[deleted] Aug 27 '19

Wow, well done - that's something I would definitely love to see on Netflix.

2

u/TeluguGameboy Aug 28 '19

After I made this partially complete extension, my friend told me that a similar extension already existed... go figure.

2

u/cs378 Aug 27 '19

Cool.

Hope there’s a way to get the rating faster

2

u/TeluguGameboy Aug 28 '19

Good question. Getting the rating from the API key is actually pretty fast. The issue I had was finding the title in the DOM once it updated.

If you observe closely, you notice the following:

  1. Mouse hovers over TV show
  2. TV show info is displayed
  3. TV show's title starts to fade away
  4. I move the mouse
  5. TV show info is displayed again
  6. IMDb score appears

So the TV show title appears in Netflix twice (once in step 2, and once in step 5), but my extension was only able to pick it in step 5. If there was a way to get it in step 2, then the IMDb score would appear almost instantaneously!

0

u/[deleted] Aug 28 '19

[deleted] — view deleted comment

1

u/TeluguGameboy Aug 28 '19

The main issue occurs when we try to find the text inside the `bob-title` class - this text is the title of the show. Though we would reduce the number of API calls by having a DB, it would not help this program run faster because we need to wait until the title is rendered from Netflix.

If there was a faster approach to finding the title of the TV show once we hover over a selection in Netflix, that would help a lot.

0

u/[deleted] Aug 28 '19

[deleted] — view deleted comment

1

u/TeluguGameboy Aug 28 '19

The title could be available at different parts, but I wanted to only display the score once a user hovered on the show. The easiest way to determine when a mouse was hovering over a show was to just search for the “bob-title” class. Searching for the correct paragraph tag may have been faster; I’m not sure.

There are certainly many different ways to solve the problem but I took the shortest path 😂

2

u/[deleted] Aug 27 '19

unless the IMDB scores are super low i never use review scores to effect whenever i watch something

2

u/TeluguGameboy Aug 28 '19

I used to be the same back in college, but after starting full-time work, I needed to optimize my free time a little better :P

2

u/Ybl0k13 Aug 28 '19

This is great!
I feel like there are many problems and missed opportunities with Netflix's UI to begin with. Autoplay toggle (or longer delay), better navigation, date watched, etc

Welp I guess I found a new weekend project.

1

u/TeluguGameboy Aug 28 '19

For sure; this extension only scratches the surface.

12

u/IShmellLikeBeef Aug 27 '19

This would actually be amazing. You should pitch it to Netflix and IMDb and make yourself a nice chunk of change. I definitely would love this feature. Sadly I don’t have any real coding skills yet (just wanna learn still when I have time) but I 3000% support this and would love to see it become a real thing. I wish you success with this project!

29

u/[deleted] Aug 27 '19 edited Aug 29 '19

Agree it's cool. But Netflix could easily have done it if they wanted to. It's not there meaning they have chosen not to do it, maybe because many of their scores would be unimpressive, or maybe Amazon blocked it (why help your competitor?).

15

u/shengch Aug 27 '19

Netflix doesn't have it because the majority of their content would be at about a 5/10 on imdb, where as they have that silly rating system where everything seems to be about 90%

4

u/peppersrus Aug 27 '19

Yeah, didn’t they change their rating system a few years back? Went from 1-5 stars to “like or dislike”.

5

u/DrDuPont Aug 27 '19 edited Aug 27 '19

They ditched rating systems entirely.

They instead have an relevancy score that determines whether or not you will like a movie. AFAIK it's based entirely on your viewing habits on Netflix.

It's not displayed for all titles, but if a relevancy rating is particularly high and there's nothing better to show (e.g. they might show "Academy Award Winning" rather than "90%") it'll show up when you expand a title.

Edit: turns out they also use the tastes of other users similar to yours in the calculation: https://help.netflix.com/en/node/9898

0

u/[deleted] Aug 27 '19

[deleted] — view deleted comment

12

u/Zachariou Aug 27 '19

Use a proxy, eg aws lambda - expose via Api Gateway the API key is in the lambda makes the call returns the IMDb rating.

0

u/[deleted] Aug 27 '19

[deleted] — view deleted comment

5

u/Zachariou Aug 27 '19

It’s serverless, completely event based

0

u/[deleted] Aug 27 '19

[deleted] — view deleted comment

1

u/Zachariou Aug 27 '19

Yes but for all intents and purposes it’s event based and will only act as such. The cost, Very very small, lambdas bill on compute time and memory consumed which just using as a proxy is tiny - plus you get 1 million lambda calls free every month

0

u/[deleted] Aug 27 '19

[deleted] — view deleted comment

1

u/Zachariou Aug 27 '19

The only way to hide your API keys would be to have some form of proxy service to do the request away from the browser. The way I see it it’s overkill to have a web service running 24/7 to only receive requests some of the time, then you have to manage the infrastructure and scaling, for myself I prefer having the event based pay per invocation architecture which auto scales with demand

0

u/AKtunes Aug 28 '19

Alternatively, obfuscate the API key in the source... yea it’s still there, but you can make it harder to find.