Replay Rewrite - Player Paths On Replay

Adds player movement trails to GLB replays viewed with the replay rewrite script.

  1. // ==UserScript==
  2. // @name Replay Rewrite - Player Paths On Replay
  3. // @description Adds player movement trails to GLB replays viewed with the replay rewrite script.
  4. // @namespace pbr/ppor
  5. // @include https://*goallineblitz.com/game/replay.pl?game_id=*&pbp_id=*
  6. // @include https://glb.warriorgeneral.com/game/replay.pl?game_id=*&pbp_id=*
  7. // @copyright 2009, pabst
  8. // @license (CC) Attribution Share Alike; http://creativecommons.org/licenses/by-sa/3.0/
  9. // @version 20.12.303
  10. // @require https://gf.qytechs.cn/scripts/418636-libpbr2-1/code/libpbr21.js?version=880565
  11.  
  12. // ==/UserScript==
  13.  
  14. /*
  15. *
  16. * based on code by Cabrasher
  17. * pabst did this 08/06/26+
  18. *
  19. *
  20. * nikkoum updated to point to https and ditto for the library ...
  21. */
  22.  
  23. var scriptName = "Player Paths";
  24. var scriptVersion = "14.01.30";
  25. var scriptWebpage = "http://userscripts.org/scripts/show/54519";
  26.  
  27. var tracedPlayers = new Array();
  28. var step = 2;
  29.  
  30. window.setTimeout( function() {
  31. init();
  32. }, 100);
  33.  
  34. function activate(e) {
  35. console.log("activate player tracing");
  36. lock();
  37.  
  38. tracemain();
  39.  
  40. unlock();
  41. }
  42.  
  43. function tracemain() {
  44. var icons = document.getElementsByClassName("o_icon");
  45. for (var i=0; i<icons.length; i++) {
  46. icons[i].firstChild.removeAttribute("onclick");
  47. icons[i].firstChild.removeAttribute("onmouseover");
  48. icons[i].firstChild.removeAttribute("onmouseout");
  49. }
  50. icons = document.getElementsByClassName("d_icon");
  51. for (var i=0; i<icons.length; i++) {
  52. icons[i].firstChild.removeAttribute("onclick");
  53. icons[i].firstChild.removeAttribute("onmouseover");
  54. icons[i].firstChild.removeAttribute("onmouseout");
  55. }
  56.  
  57. var paths = document.getElementsByClassName("player_path");
  58. while (paths.length > 0) {
  59. paths[0].parentNode.removeChild(paths[0]);
  60. paths = document.getElementsByClassName("player_path");
  61. }
  62. var o = document.getElementsByClassName("o_icon");
  63. for (var i=0; i<o.length; i++) {
  64. o[i].addEventListener("click",function (e) { playerClicked(e); }, false);
  65. }
  66. var o = document.getElementsByClassName("d_icon");
  67. for (var i=0; i<o.length; i++) {
  68. o[i].addEventListener("click",function (e) { playerClicked(e); }, false);
  69. }
  70.  
  71. for (var i=0; i<tracedPlayers.length; i++) {
  72. //console.log(i+" : "+tracedPlayers[i]);
  73. var target = document.getElementById("pos_dot_"+tracedPlayers[i]);
  74. if (target != null) {
  75. var btn = new Object();
  76. btn.target = target.firstChild;
  77. playerClicked(btn);
  78. }
  79. }
  80. }
  81.  
  82. function traceClear(div) {
  83. var inputs = [];
  84. while ((inputs = div.getElementsByTagName("input")).length > 0) {
  85. var box = inputs[0];
  86. box.parentNode.removeChild(box);
  87. }
  88. }
  89.  
  90. function playerClicked(elemInput) {
  91. //console.log(elemInput.target+" : "+elemInput.target.parentNode.id);
  92. var id = elemInput.target.parentNode.id.split("_")[2];
  93. if (document.getElementById("line_"+id) != null) {
  94. var d = document.getElementById("line_"+id);
  95. d.parentNode.removeChild(d);
  96. for (var i=0; i<tracedPlayers.length; i++) {
  97. if (tracedPlayers[i] == id) {
  98. tracedPlayers.splice(i,1);
  99. break;
  100. }
  101. }
  102. return;
  103. }
  104.  
  105. if (tracedPlayers.indexOf(id) == -1) {
  106. tracedPlayers.push(id);
  107. }
  108.  
  109. var play_data = unsafeWindow.play_data;
  110. var arrColors = new Array('black', 'blue', 'red', 'yellow', 'purple', 'orange',' aqua', 'bisque', 'darkgray', 'lightskyblue', 'magenta', 'greenyellow', 'mintcream', 'salmon', 'tan', 'turquoise', 'silver', 'slateblue', 'plum', 'orangered', 'hotpink', 'goldenrod', 'white');
  111. for (var pl=0; pl<play_data[0].length; pl++) {
  112.  
  113. if (play_data[0][pl].id == id) {
  114. var maxX = -1;
  115. var minX = 2000;
  116. var maxY = -1;
  117. var minY = 2000;
  118.  
  119. var color = arrColors[pl%arrColors.length];
  120. var link = elemInput.target.parentNode.parentNode.parentNode.childNodes[2];
  121. if (link.style.color != "") {
  122. color = link.style.color;
  123. }
  124. var p = pl;
  125. var idx = pl;
  126. var divArray = new Array();
  127. for (var cf=0; cf<play_data.length-3; cf++) {
  128. try {
  129. if (play_data[0][pl].id != play_data[cf+1][idx].id) {
  130. for (var i=0; i<play_data[cf+1].length; i++) {
  131. if (play_data[0][pl].id == play_data[cf+1][i].id) {
  132. idx = i;
  133. break;
  134. }
  135. }
  136. }
  137. var x1 = (play_data[cf][p].x)*3+20;
  138. var y1 = (play_data[cf][p].y)*3+40;
  139. var x2 = (play_data[cf+1][idx].x)*3+20;
  140. var y2 = (play_data[cf+1][idx].y)*3+40;
  141.  
  142. minX = Math.min(minX,x1);
  143. minX = Math.min(minX,x2);
  144. maxX = Math.max(maxX,x1);
  145. maxX = Math.max(maxX,x2);
  146. minY = Math.min(minY,y1);
  147. minY = Math.min(minY,y2);
  148. maxY = Math.max(maxY,y1);
  149. maxY = Math.max(maxY,y2);
  150.  
  151. if ((cf % step) == 0) {
  152. divArray.push(makeDiv(x1, y1, 2, 2, color));
  153. }
  154. p = idx;
  155. }
  156. catch (e) {
  157. console.log(e);
  158. }
  159. }
  160.  
  161. if (divArray.length > 0) {
  162. var mainDiv = document.createElement('div');
  163. mainDiv.className = "player_path";
  164. mainDiv.id = 'line_' + id;
  165. mainDiv.style.left = Math.round(minX)+"px";
  166. mainDiv.style.top = Math.round(minY)+"px";
  167. mainDiv.style.width = Math.round((maxX-minX)+1)+"px";
  168. mainDiv.style.height = Math.round((maxY-minY)+1)+"px";
  169. mainDiv.style.zIndex = 500;
  170.  
  171. for (var d=0; d<divArray.length; d++) {
  172. mainDiv.appendChild(divArray[d]);
  173. }
  174. document.getElementById('replay_area').appendChild(mainDiv);
  175. }
  176. }
  177. }
  178. }
  179.  
  180. function findPlayerToTrace(cf, id) {
  181. for (var pl=0; pl<play_data[cf].length; pl++) {
  182. if (play_data[cf][pl].id == id) {
  183. return pl;
  184. }
  185. }
  186. console.log("replayRewrite.trace : I shouldn't happen.");
  187. return -1;
  188. }
  189.  
  190. function makeDiv(x, y, w, h, backColor) {
  191. var newDiv = document.createElement('div');
  192. newDiv.style.left = x + 'px';
  193. newDiv.style.top = y + 'px';
  194. newDiv.style.width = w + 'px';
  195. newDiv.style.height = h + 'px';
  196. newDiv.style.zIndex = 500;
  197. newDiv.style.backgroundColor= backColor;
  198. newDiv.className='player_icon';
  199. newDiv.id='ds';
  200. return newDiv;
  201. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址