ffLogs

显示gcd和能力技间隔是否正常

  1. // ==UserScript==
  2. // @name ffLogs
  3. // @version 1.0
  4. // @description 显示gcd和能力技间隔是否正常
  5. // @match https://*.fflogs.com/reports/*
  6. // @namespace
  7. // ==/UserScript==
  8. (function() {
  9. var showSkillGap = function(){
  10. if(!(/type=casts/.test(location.href) && /view=events/.test(location.href) && /source=/.test(location.href) && !/hostility=1/.test(location.href))) return;
  11. let table = document.getElementsByClassName("summary-table events-table events-grid-view dataTable no-footer dtr-inline")[0];
  12. if(!table) return;
  13. let head = table.tHead.rows[0];
  14. if(head.cells.length != 5) return;
  15. let cell0 = head.cells[0];
  16. let cell1 = head.insertCell(1);
  17. cell1.outerHTML = cell0.outerHTML;
  18. //cell1.innerHTML = cell0.innerHTML;
  19.  
  20. let body = table.tBodies[0];
  21.  
  22. let casts = [];
  23. for(var i = 0; i < body.rows.length; i++){
  24. let row = body.rows[i];
  25. //if(row.cells[2].innerText.indexOf("Canceled") != -1) {continue};//断读条的跳过
  26.  
  27. casts[i] = {'time' : time2Ms(row.cells[0].innerHTML),
  28. 'gcd' : !row.cells[2].classList.contains('indented-cell'),
  29. 'beginCast' : row.cells[1].innerHTML == "起始施法" || row.cells[1].innerHTML == "Begin Cast",
  30. 'gcdTime' : 0
  31. //,'interrupt' : row.cells[2].innerText.indexOf("Canceled") != -1
  32. };
  33. if(casts[i].beginCast == true){
  34. casts[i].gcdTime = parseFloat(row.cells[2].querySelector(".event-minor-details").innerText)*1000 + 100 -50;//100是读条税,-50是波动容错
  35. }
  36.  
  37. let newCell = row.insertCell(1);
  38. let result = getCastGap(casts,i);
  39.  
  40. newCell.outerHTML = `<td class="main-table-number" style="${result.showTip?"color:red":""}" tabindex="0">${result.gap}</td>`;
  41.  
  42. }
  43. }
  44.  
  45. function getCastGap(casts,i){
  46. let thisCast = casts[i];
  47. for(var last = i -1 ; last >=0; last--){
  48. if(thisCast.gcd == true){
  49. if(casts[last].gcd == true){
  50. if(casts[last].beginCast == false && last -1 >= 0 && casts[last -1].beginCast == true){
  51. let gap = thisCast.time - casts[last-1].time; //上一个是读条技能以开始读条时间为gcd开始时间
  52. let showTip = gap < casts[last-1].gcdTime; //判断gcd时间是否正常
  53. if(showTip){
  54. return {"gap":gap,"showTip":true};
  55. }else{
  56. return {"gap":gap,"showTip":false};
  57. }
  58. }else{//该技能GCD,上一个瞬发gcd
  59. return {"gap":thisCast.time - casts[last].time,"showTip":false};
  60. }
  61. }
  62. }else{//该技能能力技
  63. return {"gap":thisCast.time - casts[last].time,"showTip":thisCast.time - casts[last].time < 560};//判断能力技间隔
  64. }
  65. }
  66. return {"gap":0,"showTip":false};
  67. }
  68.  
  69. function time2Ms(time){
  70. let minus = 1;
  71. if(time.length == 10 && time.startsWith("-")){
  72. time = time.substring(1);
  73. minus = -1;
  74. }
  75. if(time.length != 9) return;
  76. return minus*(parseInt(time.substring(0,2))*60*1000 + parseInt(time.substring(3,5))*1000 + parseInt(time.substring(6,9)));
  77. }
  78.  
  79. setInterval(showSkillGap,500);
  80.  
  81.  
  82. })();