U
U
Upas952020-04-18 18:45:04
JavaScript
Upas95, 2020-04-18 18:45:04

How to click a button on someone else's site through the console?

There is a site where you need to press all buttons with aria-label="Add to favorite tracks"
I tried different scripts through the console, those that access the button class - cause, among other things, pressing buttons with a class: class="action-item- btn datagrid-action", etc.

The $('button.datagrid-action').click(); function worked best.
But all buttons that contain "datagrid-action" are pressed this way:
button class="datagrid-action" type="button" aria-label="Show menu">
​button
class="datagrid-action" type= "button" aria-label="Remove from Favorite Tracks">
​button
class="action-item-btn datagrid-action" type="button"

Is there a way to set additional options? Or how else can this problem be solved?

Button Properties:
class="datagrid-action"
type="button"
aria-label="Add to Favorite Tracks"

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
kn1ght_t, 2020-04-18
@Upas95

const buttons = document.querySelectorAll('button.datagrid-action[type="button"][aria-label="Добавить в любимые треки"]');

Array.from(buttons).forEach(b => {
  b.click();
});

H
Hcuy, 2020-04-18
@Hcuy

document.getElementsByClassName(' Класс вашей кнопки')[0].click();

Try it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question