(Sandboxed) Lioden Improvements

Adds various improvements to the game Lioden. Sandboexed portion of the script.

目前為 2015-09-26 提交的版本,檢視 最新版本

  1. // Generated by CoffeeScript 1.9.3
  2.  
  3. /* UserScript options {{{1
  4. See http://wiki.greasespot.net/Metadata_Block for more info.
  5.  
  6. // ==UserScript==
  7. // @name (Sandboxed) Lioden Improvements
  8. // @description Adds various improvements to the game Lioden. Sandboexed portion of the script.
  9. // @namespace ahto
  10. // @version 0.1
  11. // @include http://*.lioden.com/*
  12. // @include http://lioden.com/*
  13. // @require https://greasyfork.org/scripts/10922-ahto-library/code/Ahto%20Library.js?version=75750
  14. // @grant GM_addStyle
  15. // ==/UserScript==
  16. */
  17. var HUNT_BLINK_TIMEOUT, blinker, getResults, logout, minutesLeft, moveToToplinks, navbar, newNavbarItem, toplinks, wait;
  18.  
  19. HUNT_BLINK_TIMEOUT = 500;
  20.  
  21. GM_addStyle("/* Make the top bar slimmer. */\n.main { margin-top: 10px; }\n\n/*\n * Remove the Lioden logo since I can't figure out how to shrink it,\n * and it's taking up too much space on the page. It overlaps the veeery\n * top bar, with the link to the wiki and forums and stuff.\n *\n * TODO: Figure out how to just shrink it instead of flat-out removing it.\n */\n.navbar-brand > img { display: none; }");
  22.  
  23. navbar = $('.nav.visible-lg');
  24.  
  25. toplinks = $('.toplinks');
  26.  
  27. logout = toplinks.find('a[href="/logout.php"]');
  28.  
  29. moveToToplinks = function(page, linkText) {
  30. var link;
  31. link = navbar.find("a[href='" + page + "']").parent();
  32. link.remove();
  33. link.find('a').text(linkText);
  34. return logout.before(link);
  35. };
  36.  
  37. moveToToplinks('/oasis.php', 'Oasis');
  38.  
  39. moveToToplinks('/boards.php', 'Chatter');
  40.  
  41. moveToToplinks('/news.php', 'News');
  42.  
  43. moveToToplinks('/event.php', 'Event');
  44.  
  45. moveToToplinks('/faq.php', 'FAQ');
  46.  
  47. newNavbarItem = function(page, linkText) {
  48. return navbar.append("<li><a href='" + page + "'>" + linkText + "</a></li>");
  49. };
  50.  
  51. newNavbarItem('/hunting.php', 'HUNTING');
  52.  
  53. newNavbarItem('/exploring.php', 'EXPLORING');
  54.  
  55. newNavbarItem('/branch.php', 'BRANCH');
  56.  
  57. newNavbarItem('/search_branches.php', 'BRANCHES');
  58.  
  59. newNavbarItem('/territory_map.php', 'TERRITORIES');
  60.  
  61. if (urlMatches(new RegExp('/hunting\\.php', 'i'))) {
  62. minutesLeft = findMatches('div.center > p', 0, 1).text();
  63. getResults = findMatches('input[name=get_results', 0, 1);
  64. if (minutesLeft.length) {
  65. minutesLeft = (/([0-9]+) minutes/.exec(minutesLeft))[1];
  66. minutesLeft = safeParseInt(minutesLeft);
  67. console.log(minutesLeft, 'minutes remaining.');
  68. wait = (minutesLeft + 1) * 60 * 1000;
  69. console.log("Reloading in " + wait + " ms...");
  70. setTimeout_(wait, function() {
  71. return location.reload();
  72. });
  73. } else if (getResults.length) {
  74. blinker = setInterval((function() {
  75. if (document.title === 'Ready!') {
  76. return document.title = '!!!!!!!!!!!!!!!!';
  77. } else {
  78. return document.title = 'Ready!';
  79. }
  80. }), HUNT_BLINK_TIMEOUT);
  81. window.onfocus = function() {
  82. clearInterval(blinker);
  83. return document.title = 'Ready!';
  84. };
  85. }
  86. }