ProjEulerProgress

Displays progress

当前为 2016-10-11 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name ProjEulerProgress
  3. // @namespace pep
  4. // @description Displays progress
  5. // @include https://projecteuler.net/progress
  6. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
  7. // @author oerpli
  8. // @version 1.0
  9. // @grant none
  10. // ==/UserScript==
  11. var regex = new RegExp("Progress: ([0-9]*) \/ ([0-9]*)");
  12. var ach = $(".info a span div").filter(function () {
  13. return regex.test($(this).text());
  14. });
  15.  
  16. ach.each(function(){
  17. var str = $(this).text();
  18. var res = str.match(regex);
  19. if(res){
  20. var x1 = 1*res[1];
  21. var x2 = 1*res[2];
  22. var gradient = 'linear-gradient(90deg, #aaffc2 ' + (x1/x2*100) +'%, #FFF ' + (x1/x2*100) + '%)';
  23. $(this).parent().parent().parent().parent().css('background',gradient);
  24. }
  25. });