AtCoderRatingTweet

ja

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         AtCoderRatingTweet
// @namespace    AtCoderRatingTweet
// @version      1.0
// @author       Luzhiled
// @description  ja
// @match        http://atcoder.jp/user/*
// @match        https://atcoder.jp/user/*
// @grant        none
// ==/UserScript==

(function() {
  'use strict';
  let contest_name = rating_history[0][3];
  contest_name = contest_name.replace("AtCoder Grand Contest", "AGC");
  contest_name = contest_name.replace("AtCoder Regular Contest", "ARC");
  contest_name = contest_name.replace("AtCoder Biginner Contest", "ABC");

  let latte = rating_history[0][1];
  let izryt = true;
  for (let i = 1; i < rating_history.length; ++i) {
    if (latte <= rating_history[i][1]) {
      izryt = false;
    }
  }

  let previous_rating = rating_history.length > 1 ? rating_history[1][1] : 0;
  let now_rating      = rating_history[0][1];
  let diff = now_rating - previous_rating;
  let sign = (diff >= 0 ? (diff === 0 ? "±" : "+") : "");
  if (previous_rating === 0) previous_rating = "Unrated";

  let tweet_text = `${contest_name} : ${previous_rating} -> ${now_rating} (${sign}${diff}${(izryt ? ", highest!!" : "")})`;

  $('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>`);
})();