Last active
May 5, 2017 13:41
-
-
Save ggreensolu/80b2b07287c096dbef092f1b6817391f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Clicktime Script | |
// @namespace http://tampermonkey.net/ | |
// @version 0.2 | |
// @description Sets timecard to previous week, if Wednesday or before. | |
// @author Garrett Green | |
// @match https://app.clicktime.com/App/WeekEntry/ | |
// @grant none | |
// @require http://code.jquery.com/jquery-latest.js | |
// @require https://cdnjs.cloudflare.com/ajax/libs/js-url/2.3.0/url.js | |
// @require https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/moment.min.js | |
//==/UserScript== | |
/* jshint -W097 */ | |
'use strict'; | |
// Your code here... | |
(function () { | |
var today = moment(); | |
//If Wednesday or before, go to previous week. | |
if (today.day() <= 3) { | |
//Goto previous Saturday | |
var m = today.day(-1); | |
//Get Current URL | |
var u = url(); | |
//If it doesn'y end with a question mark add it. | |
if (!u.endsWith('?')) { | |
u += '?'; | |
} | |
//Add date parameter to url. | |
u += 'dt=' + m.format('YYYYMMDD'); | |
//Redirect to that url. | |
window.location.href = u; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment