Quick and dirty job counter

Counts up the table rows in the work history dashboard

目前為 2015-10-22 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Quick and dirty job counter
// @namespace    mobiusevalon.tibbius.com
// @version      0.1
// @description  Counts up the table rows in the work history dashboard
// @author       Mobius Evalon
// @include      /^https{0,1}:\/\/work\.crowdsurfwork\.com\/reports\/work_data\/worker.*$/
// @grant        none
// ==/UserScript==

function counter()
{
    var counter = document.createElement("span");
    var script = document.createElement("script");
    var head = document.getElementsByTagName("head")[0];

    script.type = "text/javascript";
    script.innerHTML = "function count() {"+
        "var table = document.getElementsByTagName('table')[0];"+
        "if(table !== undefined) {"+
        "var tbody = table.getElementsByTagName('tbody')[0];"+
        "if(tbody !== undefined) this.innerHTML = 'Job count: '+tbody.getElementsByTagName('tr').length+' (click to refresh)'; }}";
    head.appendChild(script);

    counter.style.paddingLeft = "10px;"
    counter.innerHTML = "Job count: 0 (click to refresh)";
    if(counter.addEventListener) counter.addEventListener("click",count,false);
    else if(counter.attachEvent) counter.attachEvent("onclick",count);
    return counter;
}

var date_filter = document.getElementById("date_filter");
if(date_filter !== undefined && date_filter.tagName == "SELECT") date_filter.parentNode.appendChild(counter());