Last active
March 25, 2017 22:41
-
-
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
This file contains 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 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