AtCoder Twitter Avatar

Display Twitter avatar on AtCoder user page

Stan na 24-09-2018. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         AtCoder Twitter Avatar
// @namespace    https://ciffelia.com/
// @version      1.0.0
// @description  Display Twitter avatar on AtCoder user page
// @author       prince <[email protected]> (https://ciffelia.com/)
// @license      MIT
// @homepage     https://github.com/prince0203/atcoder-twitter-avatar#readme
// @supportURL   https://github.com/prince0203/atcoder-twitter-avatar/issues
// @match        http*://atcoder.jp/user/*
// @match        https://beta.atcoder.jp/users/*
// @run-at       document-end
// ==/UserScript==

(function () {
  'use strict';

  const twLinkElm = document.querySelector('a[href*="//twitter.com/"]');

  const screenName = twLinkElm.innerText;
  const avatarUrl = `https://avatars.io/twitter/${screenName}/small`;

  const avatarElm = document.createElement('img');
  avatarElm.src = avatarUrl;
  avatarElm.referrerPolicy = 'no-referrer';
  Object.assign(avatarElm.style, {
    width: '20px',
    height: '20px',
    marginRight: '5px',
    borderRadius: '50%'
  });

  twLinkElm.insertAdjacentElement('afterbegin', avatarElm);

}());