0

There's this pack simulator on a website I frequent. You are randomly given 10 basketball players in the game with various values on how much they are worth. When you load the page, the cards are face down so you have to click on each one to "reveal" the card and add to your total. The idea is to maximize the value of each pack.

I figured out that the flipping is all show and the total pack score is actually there as soon as you load the page. So I'm trying to write a greasemonkey script to refresh the page until the value is above a certain threshold. I can get to the span with this code:

document.getElementsByClassName("pack-score")[0];

which gets me a span that looks like this:

<span class="pack-score" data-score="12352">

So how would I access the data-score value inside that span, so I can then use it as a value for the code logic?

Programmer4Life
  • 201
  • 2
  • 5

1 Answers1

0
document.getElementsByClassName("pack-score")[0].getAttribute('data-score')

or in jquery

$(".pack-score").find('span').data('score')
Sameer
  • 383
  • 1
  • 10