Trimps tools

Trimps tools (visual)

目前为 2017-03-11 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Trimps tools
  3. // @namespace trimps.github.io
  4. // @version 1.003
  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;
  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;
  22. var food = _getBarWidthPercent('#foodBar');
  23. var wood = _getBarWidthPercent('#woodBar');
  24. var metal = _getBarWidthPercent('#metalBar');
  25. if (food > maxProgress) maxProgress = food;
  26. if (wood > maxProgress) maxProgress = wood;
  27. if (metal > maxProgress) maxProgress = metal;
  28. document.title = '' + maxProgress + '%';
  29. };
  30. setTimeout(function() {
  31. tMain = setInterval(_checkProgress, 500);
  32. }, 1000);
  33.  
  34. })();