ac-diff-reversal-notifier

AtCoderのコンテストにおいて前の問題より後ろの問題の正解者が多い時に通知します

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         ac-diff-reversal-notifier
// @namespace    https://github.com/polyester-CTRL
// @version      0.1
// @description  AtCoderのコンテストにおいて前の問題より後ろの問題の正解者が多い時に通知します
// @author       polyester-CTRL
// @match        https://atcoder.jp/contests/*/standings
// @match        https://atcoder.jp/contests/*/standings/json
// @require      https://cdn.jsdelivr.net/npm/[email protected]/dist/axios.min.js
// @grant        none
// ==/UserScript==

(function () {
  'use strict';

  // My code 
  if ((!('Notification' in window)) || (startTime === undefined)) {
    return;
  }
  let permission = Notification.permission;
  if (permission === 'denied') {
    return;
  }
  let jsonURL = window.location.href.replace(/\/+$/, '') + '/json';
  console.log(jsonURL);
  Notification.requestPermission().then(function () {
    if (endTime.isBefore()) {
      return;
    }

    let id = setInterval(function () {
      if (startTime.isAfter()) {
        return;
      }
      if (endTime.isBefore()) {
        clearInterval(id);
        return;
      }
      let taskData;
      axios.get(jsonURL)
        .then(function (response) {
          taskData = response.TaskInfo;
        })
        .catch(function (error) {
          console.log(error);
        });
      vueStandings.$watch('standings', function (newData, oldData) {
        if (!newData) {
          return;
        }
        let tasks = newData.TaskInfo;
        for (let i = 0; i < tasks.length - 1; i++) {
          if (vueStandings.ac[i] < vueStandings.ac[i + 1]) {
            new Notification(taskData[i].Assignment + ':' + vueStandings.ac[i] + '/' +
              taskData[i + 1].Assignment + ':' + vueStandings.ac[i + 1]);
          }
        }
      });
      // 3分おきに動作させる
    }, 3 * 60 * 1000);
  });
});