Misskey share button for AtCoder

Add misskey share button

اعتبارا من 26-05-2024. شاهد أحدث إصدار.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name         Misskey share button for AtCoder
// @namespace    http://kaminarinet.com/
// @version      0.4.1
// @description  Add misskey share button
// @author       KA37RI
// @match        https://atcoder.jp/users/*
// @match        https://atcoder.jp/contests/
// @match        https://atcoder.jp/contests/*
// @match        https://atcoder.jp/contests/*/submissions/*
// @match        https://atcoder.jp/users/*/history/share/*
// @icon         none
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
  let a2a = document.getElementsByClassName("a2a_kit")[0];

  function makeicon(img_url, server_name) {
    let im = document.createElement("img");
    im.setAttribute("src", img_url);
    im.setAttribute("width", "20px");
    im.setAttribute("height", "20px");

    let lk = document.createElement("a");
    lk.appendChild(im);
    lk.addEventListener("click", function() {
      let mesURL = a2a.getAttribute("data-a2a-url");
      let mesContent = a2a.getAttribute("data-a2a-title");
      if(mesContent.slice(-1) != "\n") {
        mesContent += "\n";
      }
      let message = encodeURIComponent(mesContent + mesURL);
      let share = `https://${server_name}/share?text=${message}`;
      window.open(share);
    });

    a2a.appendChild(lk);
  }

  makeicon("https://media.misskeyusercontent.jp/misskey/webpublic-0c66b1ca-b8c0-4eaa-9827-47674f4a1580.png", "misskey.io");
  makeicon("https://s3.isk01.sakurastorage.jp/misskey-kyoupro/misskey/757ffa6b-17ea-4bb6-b390-9b586f454eff.webp", "misskey.kyoupro.com");

}());