Skip to content

Instantly share code, notes, and snippets.

@dbischof
Last active March 25, 2017 22:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbischof/2c3d80ea51b5d1c0f980d925f0759afb to your computer and use it in GitHub Desktop.
Save dbischof/2c3d80ea51b5d1c0f980d925f0759afb to your computer and use it in GitHub Desktop.
Userscript to set stock due date on new TradeGecko purchase orders to current date
// ==UserScript==
// @name TG PO Stock Due Changer
// @description Set stock due date on new TradeGecko purchase orders to current date
// @match https://go.tradegecko.com/*
// @version 0.2
// ==/UserScript==
var targetPage = '/purchase_orders/new';
var currentPage = window.location.pathname;
if (currentPage == targetPage) {
updateStockDueDate();
}
setInterval(function() {
if (currentPage != window.location.pathname) {
currentPage = window.location.pathname;
if (currentPage == targetPage) {
updateStockDueDate();
}
}
}, 2000);
function updateStockDueDate() {
var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
var today = new Date();
$('dt:contains("Stock Due")').siblings('.date-picker').find('input').val(today.getDate() + ' ' + months[today.getMonth()] + ' ' + today.getFullYear()).trigger("change");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment