Quick and dirty job counter

Counts up the table rows in the work history dashboard

当前为 2015-10-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Quick and dirty job counter
  3. // @namespace mobiusevalon.tibbius.com
  4. // @version 0.1
  5. // @description Counts up the table rows in the work history dashboard
  6. // @author Mobius Evalon
  7. // @include /^https{0,1}:\/\/work\.crowdsurfwork\.com\/reports\/work_data\/worker.*$/
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. function counter()
  12. {
  13. var counter = document.createElement("span");
  14. var script = document.createElement("script");
  15. var head = document.getElementsByTagName("head")[0];
  16.  
  17. script.type = "text/javascript";
  18. script.innerHTML = "function count() {"+
  19. "var table = document.getElementsByTagName('table')[0];"+
  20. "if(table !== undefined) {"+
  21. "var tbody = table.getElementsByTagName('tbody')[0];"+
  22. "if(tbody !== undefined) this.innerHTML = 'Job count: '+tbody.getElementsByTagName('tr').length+' (click to refresh)'; }}";
  23. head.appendChild(script);
  24.  
  25. counter.style.paddingLeft = "10px;"
  26. counter.innerHTML = "Job count: 0 (click to refresh)";
  27. if(counter.addEventListener) counter.addEventListener("click",count,false);
  28. else if(counter.attachEvent) counter.attachEvent("onclick",count);
  29. return counter;
  30. }
  31.  
  32. var date_filter = document.getElementById("date_filter");
  33. if(date_filter !== undefined && date_filter.tagName == "SELECT") date_filter.parentNode.appendChild(counter());