Trimps tools

Trimps tools (visual)

目前为 2017-03-14 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Trimps tools
  3. // @namespace trimps.github.io
  4. // @version 1.005
  5. // @description Trimps tools (visual)
  6. // @author Anton
  7. // @match https://trimps.github.io
  8. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. var tMain, $ = jQuery;
  15.  
  16. var _getBarWidthPercent = function(barSelector) {
  17. return jQuery(barSelector).width() / jQuery(barSelector).parent().width() * 100;
  18. }
  19.  
  20. var _checkProgress = function() {
  21. var maxProgress = 0, maxResource = '';
  22. var food = _getBarWidthPercent('#foodBar');
  23. var wood = _getBarWidthPercent('#woodBar');
  24. var metal = _getBarWidthPercent('#metalBar');
  25. if (food > maxProgress) {maxProgress = food; maxResource = 'food';}
  26. if (wood > maxProgress) {maxProgress = wood; maxResource = 'wood';}
  27. if (metal > maxProgress) {maxProgress = metal; maxResource = 'metal';}
  28. document.title = '' + Math.floor(maxProgress) + '% ' + maxResource;
  29. };
  30.  
  31. var _styleUpdate = function() {
  32. // remove counts
  33. $('head').append('<style type="text/css">.thingOwned{display: none;}</style>');
  34. // remove tabs
  35. $('#buyTabs').hide();
  36. filterTabs('all');
  37. // remove captions
  38. $('#buildingsTitleDiv,#upgradesTitleDiv,#equipmentTitleDiv').hide();
  39. // fix height
  40. $('#buyContainer').css('height', 'calc(99vh - 20vw - 149px)');
  41. }
  42.  
  43. setTimeout(function() {
  44. tMain = setInterval(_checkProgress, 500);
  45. _styleUpdate();
  46. }, 1000);
  47.  
  48. })();