Misskey share button for AtCoder

Add misskey share button

2023-07-19 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Misskey share button for AtCoder
// @namespace    http://kaminarinet.com/
// @version      0.3.0
// @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://s3.arkjp.net/misskey/webpublic-0c66b1ca-b8c0-4eaa-9827-47674f4a1580.png", "misskey.io");
  makeicon("https://tools.kaminarinet.com/misskey_laptop.png", "misskey.kyoupro.com");

}());