AtCoderRatingTweet

ja

  1. // ==UserScript==
  2. // @name AtCoderRatingTweet
  3. // @namespace AtCoderRatingTweet
  4. // @version 1.0
  5. // @author Luzhiled
  6. // @description ja
  7. // @match http://atcoder.jp/user/*
  8. // @match https://atcoder.jp/user/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. let contest_name = rating_history[0][3];
  15. contest_name = contest_name.replace("AtCoder Grand Contest", "AGC");
  16. contest_name = contest_name.replace("AtCoder Regular Contest", "ARC");
  17. contest_name = contest_name.replace("AtCoder Biginner Contest", "ABC");
  18.  
  19. let latte = rating_history[0][1];
  20. let izryt = true;
  21. for (let i = 1; i < rating_history.length; ++i) {
  22. if (latte <= rating_history[i][1]) {
  23. izryt = false;
  24. }
  25. }
  26.  
  27. let previous_rating = rating_history.length > 1 ? rating_history[1][1] : 0;
  28. let now_rating = rating_history[0][1];
  29. let diff = now_rating - previous_rating;
  30. let sign = (diff >= 0 ? (diff === 0 ? "±" : "+") : "");
  31. if (previous_rating === 0) previous_rating = "Unrated";
  32.  
  33. let tweet_text = `${contest_name} : ${previous_rating} -> ${now_rating} (${sign}${diff}${(izryt ? ", highest!!" : "")})`;
  34.  
  35. $('div.col-sm-8 > dl.dl-horizontal').append(`<dt>Tweet</dt><dd><a href="https://twitter.com/share" data-url=" " class="twitter-share-button">Tweet</a><script>!function(d,s,id){let tweet_text = \`${tweet_text}\`;document.getElementsByClassName("twitter-share-button")[0].setAttribute("data-text", tweet_text);let js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script></dd>`);
  36. })();