im looking To scrape a specific element inside the raw HTML of a specific div using a Chrome extension,

On my phone right now, but assuming `cardfront_content` is a class, you can get the dom element from a chrome extension like so

JavaScript:
const element = document.querySelectorAll('div.cardfront_content img.level');
 
Oh wait, I misunderstood. You're looking to get the 'x' value in level. You can do that by following this

JavaScript:
const cardfrontContent = document.getElementsByClassName('cardfront_content')

// Loop through each div that has the cardfront content class
for(const content of cardfrontContent) {
    const levels = content.getElementsByClassName('level')
    
    // For each div, loop through each class name that has 'level'
    for(const level of levels) {
        // We have the level element here, and we can obtain the number from the class name by splitting level level to get the number
        console.log('value: ', level.className.split('level level')[1])
    }
}

I think this should set you in the correct path depending on what you'd want to do. If you're just operating on a single element (maybe because it's triggered via onClick or something), then you would just need to do a level.className.split('level level')[1] where level is target element.
 
Back
Top