您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Add options to workflowmax.com timesheet
当前为
// ==UserScript== // @name Timesheet // @namespace http://geosolve.co.nz // @description Add options to workflowmax.com timesheet // @include https://my.workflowmax.com/my/timesheet.aspx?*tab=weekly* // @version 1.5.3 // @grant none // ==/UserScript== //window.addEventListener ("load", Greasemonkey_main, false); Greasemonkey_main(); function Greasemonkey_main () { var bDebug = false; var isSort = getQueryVariable("sort"); var head = document.getElementsByClassName("heading"); var jobCol = head[0].getElementsByClassName("time-job"); head[0].getElementsByClassName("time-job")[0].innerHTML = ('<br><a href="https://my.workflowmax.com/my/timesheet.aspx?filter=&tab=weekly&sort=job">Job/Task</a>'); head[0].getElementsByClassName("time-job")[0].title = "Sort by Job Number." head[0].getElementsByClassName("time-client")[0].innerHTML = ('<br><a href="https://my.workflowmax.com/my/timesheet.aspx?filter=&tab=weekly&sort=client">Client</a>'); head[0].getElementsByClassName("time-client")[0].title = "Sort by Client name." head[0].getElementsByClassName("total-heading")[0].innerHTML = ('<br><a href="https://my.workflowmax.com/my/timesheet.aspx?filter=&tab=weekly&sort=total">Total</a>'); head[0].getElementsByClassName("total-heading")[0].title = "Sort by total hours."; //figure out which sort we're using and set it all up to work var sortType = "time-job"; var upDown = "Down"; if (isSort == "job") { sortType = "time-job" head[0].getElementsByClassName("time-job")[0].innerHTML = ('<br><a href="https://my.workflowmax.com/my/timesheet.aspx?filter=&tab=weekly&sort=jobu">Job/Task</a>'); upDown = "Down"; } else if (isSort == "jobu") { sortType = "time-job" head[0].getElementsByClassName("time-job")[0].innerHTML = ('<br><a href="https://my.workflowmax.com/my/timesheet.aspx?filter=&tab=weekly&sort=job">Job/Task</a>'); upDown = "Up"; } else if (isSort == "client") { sortType = "time-client" head[0].getElementsByClassName("time-client")[0].innerHTML = ('<br><a href="https://my.workflowmax.com/my/timesheet.aspx?filter=&tab=weekly&sort=clientu">Client</a>'); upDown = "Down"; } else if (isSort == "clientu") { sortType = "time-client" head[0].getElementsByClassName("time-client")[0].innerHTML = ('<br><a href="https://my.workflowmax.com/my/timesheet.aspx?filter=&tab=weekly&sort=client">Client</a>'); upDown = "Up"; } else if (isSort == "total") { sortType = "total-task" upDown = "Down"; }; var timeTable = document.getElementById("ctl00_PageContent_weeklyTimesheetSummaryTable"); if (bDebug == true) { var banner = document.getElementsByClassName("MaxBanner"); } var rows = timeTable.getElementsByClassName("summary-row"); var notes = timeTable.children; console.log(notes.length); var i; var list = new Array(1); list[0] = new Array(4); for (i = 0; i <= rows.length-1; i++) { if (bDebug == true) {console.log(i);} list.push(i); list[i] = new Array(4); list[i][0] = i; list[i][1] = rows[i]; if (bDebug == true) {console.log(typeof(list[i][1]));}; list[i][2] = rows[i].getElementsByClassName(sortType)[0].innerHTML; list[i][3] = notes[i * 2 + 1]; if (bDebug == true) {console.log(list[i][2]);}; if (bDebug == true) {console.log(sortType);}; } if (bDebug == true) {console.log(i);}; try {list.splice(i,1);} catch(err) {console.log(err.message);}; //debug output if (bDebug == true) { for (i = 0; i <= rows.length -1; i++) { banner[0].innerHTML += i; banner[0].innerHTML += list[i][2]; } banner[0].innerHTML += list.length; banner[0].innerHTML += rows.length; } try {if (isSort=="total") { if (bDebug == true) {console.log('isSort="total"');}; list.sort(time); } else if(isSort.charAt(isSort.length-1) == "u") { if (bDebug == true) {console.log('isSort.charAt(isSort.length-1) == "u"');}; list.sort(compareu); } else { if (bDebug == true) {console.log('else');}; list.sort(compare); } } catch (err){console.log(err.message);}; for (i = 0; i <= rows.length-1; i++) { if (bDebug == true) {console.log(i);} if (bDebug == true) {console.log(list[i][2]);}; if (i == 0) { } else { if (bDebug == true) {console.log(typeof(list[i][0]));}; if (bDebug == true) {console.log(typeof(list[i][1]));}; try {timeTable.insertBefore(list[i][1],list[i-1][1]);} catch(err) {console.log(err.message);} try {timeTable.insertBefore(list[i][3],list[i][1].nextSibling);} catch(err) {console.log(err.message);} } } } function compare(a,b) { //compare A > Z var result = a[2].localeCompare(b[2]); if (result == -1) {result = 1} else if (result == 1) {result = -1}; return result; //return "-1"; }; function compareu(a,b) { //compare A > Z var result = a[2].localeCompare(b[2]); return result; //return "-1"; }; function time(a,b) { var a2 = parseFloat(a[2].replace(":",".")); var b2 = parseFloat(b[2].replace(":",".")); return a2 > b2 ? 1 : a2 < b2 ? -1 : 0; }; function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i<vars.length;i++) { var pair = vars[i].split("="); if(pair[0] == variable){return pair[1];} } return("job"); };
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址