Resource Value Saver

Store resource values from the ticker for calculation in other scripts

目前为 2021-06-02 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Resource Value Saver
  3. // @namespace http://www.knightsradiant.pw
  4. // @version 0.1
  5. // @description Store resource values from the ticker for calculation in other scripts
  6. // @author Talus
  7. // @match https://politicsandwar.com/index.php?id=26*
  8. // @require https://code.jquery.com/jquery-3.4.1.min.js
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function(){
  13. var tickerSelectPath = '#rightcolumn > p.alert.alert-warning > marquee';
  14. var resourceRE = /Food: \$(?<food>[\d,]+) Steel: \$(?<steel>[\d,]+) Aluminum: \$(?<aluminum>[\d,]+) Munitions: \$(?<munitions>[\d,]+) Gasoline: \$(?<gasoline>[\d,]+) Coal: \$(?<coal>[\d,]+) Oil: \$(?<oil>[\d,]+) Uranium: \$(?<uranium>[\d,]+) Iron: \$(?<iron>[\d,]+) Bauxite: \$(?<bauxite>[\d,]+) Lead: \$(?<lead>[\d,]+) Credits: \$(?<credits>[\d,]+)/;
  15. var $ = window.jQuery;
  16. var tickerText = $(tickerSelectPath).text();
  17. var resourceValues = tickerText.match(resourceRE).groups;
  18. for (const property in resourceValues) {
  19. resourceValues[property] = resourceValues[property].replaceAll(',','');
  20. }
  21. localStorage.setItem('resourceValues', JSON.stringify(resourceValues));
  22. })();