Keyboard only mode for Smart Review using GreaseMonkey

Hi

We’ve made a user script with GreaseMonkey so that you can do Smart Review on Practice Portuguese without having to use your mouse or touchpad. It focuses the cursor inside the text area each time, and automatically advances you to the next section.

To use it, install GreaseMonkey extension or add-on to your browser, and load this script below.

Enjoy
Edward

// ==UserScript==
// @name     Smart Review
// @version  1
// @grant    none
// @match https://www.practiceportuguese.com/*
// @run-at document-end
// ==/UserScript==

// Variable in which the time of the last activation of the button is stored
var time_pressed = null;
// Interval in which the button is searched for
var refresh_interval = 800;
// Time interval that is waited before the button can be pressed again
var guard_interval = 10000;


var buttonname = '.lessonBubble.nextBubble > a';

setInterval(function () {
    'use strict';
    if (document.querySelector(buttonname)) {
      var time_delta = new Date() - time_pressed;
      if (time_pressed === null || time_delta > guard_interval) {
        document.querySelector(buttonname).click();
        time_pressed = new Date();
      }
    }
}, refresh_interval);

$ = unsafeWindow.jQuery;
setInterval(function() {
  $('.ls-question > p > input:first').css('background-color', 'pink').focus();
  
}, refresh_interval);
1 Like

Thanks for posting, @edward. I’m going to see about including this in our core code, at least the autofocussing text fields, since that’s something we should have already. The auto-advancing, is that to dismiss the answer screen after x seconds? (You should already be able to use enter/return key) Only concern is missing the extra tips and audio pronunciation etc… but maybe we could later have this as a toggle option somewhere, if I’m understanding this correctly.

As a power user, do you prefer using this quiz mode of smart review over the flash cards (which should already be fully keyboard controllable).

Thanks for getting creative and posting!

Hi Joel - I prefer the quiz mode for smart review, there’s too much self-doubt for me with the flash cards can’t quite trust myself that I really knew the answer or not especially for longer sentences where i got most things right! The auto-advance in the Greasemonkey script mimicks pressing the continue button after each batch of quiz questions - not after each question, as I do often listen to the audio again or read the notes. I usually do my 300+ daily phrases to review in 1-3 sittings per day, so it was getting repetiive to have to click next after each say 15 questions, and also the tabbing onto the text input was repetitive and if you start tabbing before the question has loaded fully then you start tabbing through all the browser controls and have to use the mouse to focus the input. But the greasemonkey script has solved both these things for us now! Thanks!

1 Like

Here’s an update to the greasemonkey script which fixes problem when there is more than 1 text input in a question:

// ==UserScript==
// @name     Smart Review
// @version  1
// @grant    none
// @match https://www.practiceportuguese.com/*
// @run-at document-end
// ==/UserScript==

// Variable in which the time of the last activation of the button is stored
var time_pressed = null;
// Interval in which the button is searched for
var refresh_interval = 800;
// Time interval that is waited before the button can be pressed again
var guard_interval = 10000;


var buttonname = '.lessonBubble.nextBubble > a';

setInterval(function () {
    'use strict';
    if (document.querySelector(buttonname)) {
      var time_delta = new Date() - time_pressed;
      if (time_pressed === null || time_delta > guard_interval) {
        document.querySelector(buttonname).click();
        time_pressed = new Date();
      }
    }
}, refresh_interval);

$ = unsafeWindow.jQuery;
setInterval(function() {
	if ($('.ls-question > p > input:visible').length == 1) $('.ls-question > p > input:visible').css('background-color', 'pink').focus();
  
}, refresh_interval);




//window.addEventListener('load', function() {
//  $ = unsafeWindow.jQuery;
	//setInterval(function() {
  //  $('.ls-question > p > input:first').focus().select();
 // }, refresh_interval);
 // unsafeWindow.console.log("MOOO:");
 //	unsafeWindow.console.log(document.querySelector('.ls-question > p > input:first')));
   // document.querySelector('.ls-question > p > input:first').select();
//}, false);

Dear Joel

I’ve since discovered the flash cards are excellent practice if I say the phrase out loud, then it’s very clear to myself whether I got it right or wrong, and it’s practicing a different brain process (not to mention speaking) compared to the quiz mode.

As for quiz mode what I think would be great is the option to review with just the video questions - ie the different people saying the phrases, without having just been prompted by the choice/completion questions in each batch. I find that the initial questions plant the phrase in short-term memory and then it’s always coming out of that memory bank instead of the older memory.

Hope I’m making sense!

Thank you
Nicholas

1 Like