OGame - UserPositions

Shows user position in galaxy at highscore page.

  1. // ==UserScript==
  2. // @name OGame - UserPositions
  3. // @author Gh61
  4. // @version 1.1
  5. // @description Shows user position in galaxy at highscore page.
  6. // @include http://*.ogame.*/game/index.php?*page=highscore*
  7. // @copyright 2014, Gh61
  8. // @namespace https://greasyfork.org/users/5945
  9. // ==/UserScript==
  10.  
  11. // add jQuery
  12. var $j;// no conflict
  13. (function(){
  14. $j = unsafeWindow.jQuery;
  15. $j.urlParam = function(name, url) {
  16. if (!url) {
  17. url = window.location.href;
  18. }
  19. var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(url);
  20. if (!results) {
  21. return "";
  22. }
  23. return results[1] || "";
  24. }
  25. UP_LetsJQuery($j);
  26. })();
  27.  
  28. function UP_LetsJQuery($) {
  29. //console.log($); // check if the dollar (jquery) function works
  30. //console.log($().jquery); // check jQuery version
  31. $(document).ajaxComplete(function () {
  32. UP_UpdatePositions($);
  33. });
  34. UP_UpdatePositions($);
  35. }
  36.  
  37. function UP_UpdatePositions($){
  38. $(".userHighscore td.name a:not([target=_ally])").each(function(index, element){
  39. var $this = $(this);
  40. var url = $this.attr("href");
  41. var galaxy = $.urlParam("galaxy", url);
  42. var system = $.urlParam("system", url);
  43. var position = $.urlParam("position", url);
  44. $this.find('.planet-location').remove();
  45. $this.append($('<span class="planet-location">').html("[" + galaxy + ":" + system + ":" + position + "]"))
  46. });
  47. }