atcoder-GoogleCalender

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

As of 2019-10-05. See the latest version.

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 or Violentmonkey 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.

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

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

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

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

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

  1. // ==UserScript==
  2. // @name atcoder-GoogleCalender
  3. // @namespace https://github.com/penicillin0/
  4. // @version 0.1.2
  5. // @description AtCoderでGoogle Calender に追加するリンクを生成。面倒な日時の入力を省略できます。
  6. // @author penicillin0
  7. // @license MIT
  8. // @match https://atcoder.jp/contests/*
  9. // @homepage https://github.com/penicillin0/atcoder-add-calender#readme
  10. // @supportURL https://twitter.com/penicillin0at
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. 'use strict';
  15. const contest_name = document.querySelector('a.contest-title').innerHTML;
  16. const contest_url = document.querySelector('a.contest-title');
  17.  
  18. // 開始時間と修了時間の取得
  19. const times = document.querySelectorAll('small.contest-duration a');
  20. const start_time_formed = String(times[0]).split('=')[1].replace('&p1', '') + '00';
  21. const end_time_formed = String(times[1]).split('=')[1].replace('&p1', '') + '00';
  22.  
  23.  
  24. const google_calendar_url = 'http://www.google.com/calendar/event?' +
  25. 'action=' + 'TEMPLATE' +
  26. '&text=' + contest_name +
  27. '&dates=' + start_time_formed + '/' + end_time_formed +
  28. '&details=' + contest_url;
  29.  
  30. const insert_txt = ` <a href='${google_calendar_url}', target="_blank">Google Calendar</a>`;
  31. const place = document.querySelector('small.contest-duration');
  32. // window.alert(place)
  33. place.insertAdjacentHTML('beforeend', insert_txt);
  34.  
  35. })();