Skip to content

Instantly share code, notes, and snippets.

@vayn
Created October 24, 2016 09:28
Show Gist options
  • Select an option

  • Save vayn/42557261a5467acd5cf394ceb72afee3 to your computer and use it in GitHub Desktop.

Select an option

Save vayn/42557261a5467acd5cf394ceb72afee3 to your computer and use it in GitHub Desktop.

Revisions

  1. vayn created this gist Oct 24, 2016.
    16 changes: 16 additions & 0 deletions survey_cracker.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    function getRandomInt(min, max) {
    return Math.floor(Math.random() * (max - min + 1)) + min;
    }

    var radios = Array.prototype.slice.call(document.querySelectorAll(".css-radio"))
    var goods = radios.filter(function(element) {
    return element.value >= 5;
    });

    for(var i = 0; i < goods.length; i++) {
    if (getRandomInt(0, 1) == 0) {
    goods[i].checked = true
    } else if (i+1 <= length) {
    goods[i+1].checked = true
    }
    }