NewAtcoderRatingTweet

ja

2017-10-21 기준 버전입니다. 최신 버전을 확인하세요.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

You will need to install an extension such as Tampermonkey to install this script.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         NewAtcoderRatingTweet
// @namespace    NewAtcoderRatingTweet
// @version      1.0
// @author       Luzhiled
// @description  ja
// @match        https://beta.atcoder.jp/users/*
// @grant        none
// ==/UserScript==

(function() {
  'use strict';
  let path_name = location.pathname;
  if (path_name.endsWith("/")) {
    path_name = path_name.slice(0, -1);
  }
  if (path_name.endsWith("/" + userScreenName)) {
    let contest_name = rating_history[rating_history.length - 1].ContestName;
    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[rating_history.length - 1].NewRating;
    let izryt = true;
    for (let i = 0; i < rating_history.length - 1; ++i) {
      if (latte <= rating_history[i].NewRating) {
        izryt = false;
      }
    }

    let previous_rating = rating_history.length > 1 ? rating_history[rating_history.length - 2].NewRating : 0;
    let now_rating      = rating_history[rating_history.length - 1].NewRating;
    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 > table.dl-table').append(`<tr><th>Tweet</th><td><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></td></tr>`);
  }
})();