Skip to content

Instantly share code, notes, and snippets.

@adamwight
Created January 29, 2021 11:12
Show Gist options
  • Save adamwight/cfb01136c30744d0f4fa63b6bea0dda0 to your computer and use it in GitHub Desktop.
Save adamwight/cfb01136c30744d0f4fa63b6bea0dda0 to your computer and use it in GitHub Desktop.
Another TicTac userscript
// ==UserScript==
// @name Autofill date
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://tictac.wikimedia.de/web
// @grant none
// ==/UserScript==
(function() {
'use strict';
var instantEdit = true,
pollInterval = 250,
maxTimeout = 10000;
function isTimesheetDayViewPage() {
return $('.oe_form_button_edit').length > 0;
}
function clickEditMode() {
$('.oe_form_button_edit').click();
}
function clickAddItem() {
$('.oe_form_field_one2many_list_row_add a').click();
}
var waitedTime = 0;
function waitUntilLoad(callback) {
if ($('.oe_loading').length > 0 && !$('.oe_loading').is(':visible')) {
console.log("Firing userscript callback.");
callback();
return;
}
if (waitedTime > maxTimeout) {
console.log("Timed out of userscript.");
return;
}
setTimeout(function () {
waitedTime += pollInterval;
console.log("waited " + waitedTime);
waitUntilLoad(callback)
}, pollInterval);
}
waitUntilLoad(function () {
if (instantEdit && isTimesheetDayViewPage()) {
clickEditMode();
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment