Redmine工时统计

方便统计redmine工时

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Redmine工时统计
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  方便统计redmine工时
// @author       You
// @match        http://192.168.6.8:33988/workreports*
// @match        http://redmine-pa.mxnavi.com/workreports*
// @icon         https://www.google.com/s2/favicons?domain=6.8
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    // Your code here...

    function showWorkTime() {
        var workTimeArray = Array();

        document.querySelector("#workreport-table").querySelectorAll("tr").forEach((element, index) => {
              if(element.children[0].hasAttribute("rowspan")){
                  workTimeArray.push(parseFloat(element.children[7].innerHTML));
              }
        });
        var allTime = parseFloat(workTimeArray.reduce((a, b) => a + b, 0)).toFixed(2);
        alert("当前页面的工作量统计:"+allTime);
    }

    var button = document.createElement("button");
    button.innerHTML = "统计当前工时";
    button.style.position = "fixed";
    button.style.top = "100px";
    button.style.right = "100px";
    button.onclick = showWorkTime;
    document.body.appendChild(button);
})();