projetFER

Fer

当前为 2014-08-05 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name projetFER
  3. // @namespace projetFER
  4. // @description Fer
  5. // @include http://www.worldofstargate.fr/*
  6. // @version 1
  7. // ==/UserScript==
  8.  
  9. function addJQuery(callback) {
  10. var script = document.createElement("script");
  11. script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
  12. script.addEventListener('load', function() {
  13. var script = document.createElement("script");
  14. script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
  15. document.body.appendChild(script);
  16. }, false);
  17. document.body.appendChild(script);
  18. }
  19. // the guts of this userscript
  20. function main() {
  21. $(document).keyup(function (event) {
  22. console.log(event.keyCode);
  23. if(event.keyCode == 82 ){
  24. var tabResu = $('div[class^="resu_bar_"]');
  25. var j = 0;
  26. var h = 0;
  27. var m = 0;
  28. var s = 0;
  29. var globalTime = 0;
  30. var timeAfficher = "";
  31. if(tabResu.length > 0){
  32. tabResu.each(function(res){
  33. globalTime += parseInt($(this).find("span:nth-child(4)").text());
  34. });
  35. console.log(globalTime);
  36. var tmp = 0;
  37. j = (globalTime - globalTime % 86400)/86400;
  38. tmp += j*86400;
  39. h = (globalTime - tmp - ((globalTime-tmp)%3600))/3600;
  40. tmp += h*3600;
  41. m = (globalTime - tmp - ((globalTime-tmp)%60))/60;
  42. tmp += m*60
  43. s = globalTime - tmp;
  44. }
  45. timeAfficher += "\t<p class=\"awesome\"> Temps résurrection : "+j+"j"+h+"h"+m+"m"+s+"s" +"</p>";
  46.  
  47. var lien = $(".medium.lightblue.awesome");
  48. if(lien.text().indexOf("planification") != -1){
  49. console.log(lien);
  50. lien.after(timeAfficher);
  51. }
  52. }
  53. });
  54. }
  55. addJQuery(main);