this is an example of highlightBlock doing a bit of what you say, that works with blockly interpreter demo:
function highlightBlock(id) {
Blockly.mainWorkspace.highlightBlock(id);
var currentBlock = Blockly.mainWorkspace.getBlockById(id);
highlightPause = true;
if (currentBlock.type == 'controls_repeat_ext') {
var count = myInterpreter.getScope().properties.count.data;
if (count != undefined) {
console.log('count: ' + count);
}
}
if (currentBlock.type == 'variables_set') {
var n = myInterpreter.getScope().properties.n.data;
if (n != undefined) {
console.log('n: ' + n);
}
}
};