HeroQuizz highlight correct answer

Highlights the correct answers on HeroQuizz.

  1. // ==UserScript==
  2. // @name HeroQuizz highlight correct answer
  3. // @namespace http://mathemaniac.org/
  4. // @version 1.0.0
  5. // @description Highlights the correct answers on HeroQuizz.
  6. // @match http://*.heroquizz.com/r/*
  7. // @copyright 2016, Sebastian Paaske Tørholm
  8. // @require https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js
  9. // @grant none
  10. // ==/UserScript==
  11. /* jshint -W097 */
  12. 'use strict';
  13.  
  14. /* Example HTML:
  15. <div class="my_answers" id="r4_1" onclick="AnswerQuestion(4, 1, 28, 2)">Ja, vi er helt alene</div>
  16. <div class="my_answers" id="r4_2" onclick="AnswerQuestion(4, 2, 28, 2)">Nej, naturligvis findes der live på andre planeter</div>
  17.  
  18. #1 is question number, #2 is answer number within question, #3 is actual question number, #4 is right answer number
  19. */
  20.  
  21. $('.my_answers').each( function () {
  22. var args = $(this).attr('onclick').match(/\d+/g);
  23. if (args[1] === args[3]) {
  24. $(this).css( { "background-color": '#A1E39F' } );
  25. }
  26. } );