Skip to content

Instantly share code, notes, and snippets.

@karllindmark
Last active March 31, 2016 17:49
Show Gist options
  • Save karllindmark/0143d8fc5b86b4cc7295f1f95539a650 to your computer and use it in GitHub Desktop.
Save karllindmark/0143d8fc5b86b4cc7295f1f95539a650 to your computer and use it in GitHub Desktop.
Visma Stämpla Chrome console script (quick & dirty) - worth noting is that you'll need to paste & run once every page load.
/* I'm not sure if this actually works in GreaseMonkey*, but something similar to this would be nice. */
var report = function(endDate) {
if (!endDate) {
console.error('No end date specified!');
return;
}
var interval = setInterval(function() {
if ($('#ctl00_maincontentholder_dayLabel').innerText.indexOf(endDate) !== -1) {
console.log('Found', endDate, ', exiting...');
clearInterval(interval);
return;
}
if ($('.editDayControl tr>td tr>td[colspan="3"]').innerText.indexOf('Ej schemalagd dag') === -1) {
$('#ctl00_maincontentholder_IntervalsForm_startTextBox_TheTextBox').value = '08:00';
$('#ctl00_maincontentholder_IntervalsForm_endTextBox_TheTextBox').value = '16:30';
$('#ctl00_maincontentholder_IntervalsForm_AddButton').click();
}
setTimeout(function() {
var a = $$('a');
a[a.length -1].click();
}, 100);
}, 1000);
};
(function() {
if ($('.editDayControl tr>td tr>td[colspan="3"]').innerText.indexOf('Ej schemalagd dag') === -1) {
$('#ctl00_maincontentholder_IntervalsForm_startTextBox_TheTextBox').value = '08:00';
$('#ctl00_maincontentholder_IntervalsForm_endTextBox_TheTextBox').value = '16:30';
$('#ctl00_maincontentholder_IntervalsForm_AddButton').click();
}
setTimeout(function() {
var a = $$('a');
a[a.length -1].click();
}, 100);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment