AtCoder-Google-Calender

AtCoderでGoogle Calender に追加するリンクを生成。面倒な日時の入力を省略できます。

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         AtCoder-Google-Calender
// @namespace    https://github.com/penicillin0/
// @version      0.1.5
// @description  AtCoderでGoogle Calender に追加するリンクを生成。面倒な日時の入力を省略できます。
// @author       penicillin0
// @license      MIT
// @match        https://atcoder.jp/contests/*
// @homepage     https://github.com/penicillin0/AtCoder-Google-Calender#readme
// @supportURL   https://twitter.com/penicillin0at
// ==/UserScript==

(function () {
    'use strict';
    const contest_name = document.querySelector('a.contest-title').innerHTML;
    const contest_url = document.querySelector('a.contest-title');

    // 開始時間と修了時間の取得
    const times = document.querySelectorAll('small.contest-duration a');
    const start_time_formed = String(times[0]).split('=')[1].replace('&p1', '') + '00';
    const end_time_formed = String(times[1]).split('=')[1].replace('&p1', '') + '00';


    const google_calendar_url = 'http://www.google.com/calendar/event?' +
        'action=' + 'TEMPLATE' +
        '&text=' + contest_name +
        '&dates=' + start_time_formed + '/' + end_time_formed +
        '&location=' + contest_url;

    const insert_txt = `  <a href='${google_calendar_url}', target="_blank">Google Calendar</a>`;
    const place = document.querySelector('small.contest-duration');
    // window.alert(place)
    place.insertAdjacentHTML('beforeend', insert_txt);

})();