1

I want to create a script that would select the correct option automatically

Here is what I have so far

http://jsfiddle.net/VqQaN/58/

var labels = document.getElementsByTagName('li'); //get the li
for (var i = 0; i < labels.length; ++i) { //loop through the li
    if (labels[i].textContent == "misafir getirebilir") { //check li text
        labels[i].click(); //if correct text, click the li
    }
}

console.log ("answerTxt: ", labels);
Andrey
  • 1,247
  • 11
  • 30

2 Answers2

0

You can use Jquery for that: How can I use jQuery in Greasemonkey?

While using something like this: Setting "checked" for a checkbox with jQuery?

Community
  • 1
  • 1
puelo
  • 5,464
  • 2
  • 34
  • 62
0
var labels = document.getElementsByTagName('li'); //get the li
for (var i = 0; i < labels.length; ++i) { //loop through the li
    if (labels[i].textContent == "1 misafir getirebilir") { //check li text
        labels[i].querySelector('input').click(); //if correct text, click the li
    }
}

Demo

zanetu
  • 3,740
  • 1
  • 21
  • 17