Este script no debería instalarse directamente. Es una biblioteca que utilizan otros scripts mediante la meta-directiva de inclusión // @require https://update.greasyfork.org/scripts/386712/816981/atcoder-userscript-libs.js
usLibs = typeof(usLibs) !== "undefined" ? usLibs :
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 23);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports) {
module.exports = moment;
/***/ }),
/* 1 */
/***/ (function(module, exports) {
module.exports = has;
/***/ }),
/* 2 */
/***/ (function(module, exports) {
module.exports = arrayToSet;
/***/ }),
/* 3 */
/***/ (function(module, exports) {
module.exports = setToArray;
/***/ }),
/* 4 */
/***/ (function(module, exports) {
module.exports = setCookie;
/***/ }),
/* 5 */
/***/ (function(module, exports) {
module.exports = getCookie;
/***/ }),
/* 6 */
/***/ (function(module, exports) {
module.exports = getCookieBool;
/***/ }),
/* 7 */
/***/ (function(module, exports) {
module.exports = delCookie;
/***/ }),
/* 8 */
/***/ (function(module, exports) {
module.exports = setLS;
/***/ }),
/* 9 */
/***/ (function(module, exports) {
module.exports = getLS;
/***/ }),
/* 10 */
/***/ (function(module, exports) {
module.exports = delLS;
/***/ }),
/* 11 */
/***/ (function(module, exports) {
module.exports = getServerTime;
/***/ }),
/* 12 */
/***/ (function(module, exports) {
module.exports = rand;
/***/ }),
/* 13 */
/***/ (function(module, exports) {
module.exports = copy;
/***/ }),
/* 14 */
/***/ (function(module, exports) {
module.exports = storeFavs;
/***/ }),
/* 15 */
/***/ (function(module, exports) {
module.exports = reloadFavs;
/***/ }),
/* 16 */
/***/ (function(module, exports) {
module.exports = toggleFav;
/***/ }),
/* 17 */
/***/ (function(module, exports) {
module.exports = LANG;
/***/ }),
/* 18 */
/***/ (function(module, exports) {
module.exports = userScreenName;
/***/ }),
/* 19 */
/***/ (function(module, exports) {
module.exports = (typeof contestScreenName !== "undefined" ? contestScreenName : null);
/***/ }),
/* 20 */
/***/ (function(module, exports) {
module.exports = (typeof startTime !== "undefined" ? startTime : null);
/***/ }),
/* 21 */
/***/ (function(module, exports) {
module.exports = (typeof endTime !== "undefined" ? endTime : null);
/***/ }),
/* 22 */
/***/ (function(module, exports) {
module.exports = jQuery;
/***/ }),
/* 23 */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
__webpack_require__.r(__webpack_exports__);
var rating_namespaceObject = {};
__webpack_require__.r(rating_namespaceObject);
__webpack_require__.d(rating_namespaceObject, "calcRatingFromHistory", function() { return calcRatingFromHistory; });
__webpack_require__.d(rating_namespaceObject, "calcRatingFromLast", function() { return calcRatingFromLast; });
__webpack_require__.d(rating_namespaceObject, "positivizeRating", function() { return positivizeRating; });
__webpack_require__.d(rating_namespaceObject, "unpositivizeRating", function() { return unpositivizeRating; });
__webpack_require__.d(rating_namespaceObject, "calcRequiredPerformance", function() { return calcRequiredPerformance; });
__webpack_require__.d(rating_namespaceObject, "colorBounds", function() { return colorBounds; });
__webpack_require__.d(rating_namespaceObject, "colorNames", function() { return colorNames; });
__webpack_require__.d(rating_namespaceObject, "getColor", function() { return getColor; });
var global_namespaceObject = {};
__webpack_require__.r(global_namespaceObject);
__webpack_require__.d(global_namespaceObject, "has", function() { return external_has_default.a; });
__webpack_require__.d(global_namespaceObject, "arrayToSet", function() { return external_arrayToSet_default.a; });
__webpack_require__.d(global_namespaceObject, "setToArray", function() { return external_setToArray_default.a; });
__webpack_require__.d(global_namespaceObject, "setCookie", function() { return external_setCookie_default.a; });
__webpack_require__.d(global_namespaceObject, "getCookie", function() { return external_getCookie_default.a; });
__webpack_require__.d(global_namespaceObject, "getCookieBool", function() { return external_getCookieBool_default.a; });
__webpack_require__.d(global_namespaceObject, "delCookie", function() { return external_delCookie_default.a; });
__webpack_require__.d(global_namespaceObject, "setLS", function() { return external_setLS_default.a; });
__webpack_require__.d(global_namespaceObject, "getLS", function() { return external_getLS_default.a; });
__webpack_require__.d(global_namespaceObject, "delLS", function() { return external_delLS_default.a; });
__webpack_require__.d(global_namespaceObject, "getServerTime", function() { return external_getServerTime_default.a; });
__webpack_require__.d(global_namespaceObject, "rand", function() { return external_rand_default.a; });
__webpack_require__.d(global_namespaceObject, "copy", function() { return external_copy_default.a; });
__webpack_require__.d(global_namespaceObject, "storeFavs", function() { return external_storeFavs_default.a; });
__webpack_require__.d(global_namespaceObject, "reloadFavs", function() { return external_reloadFavs_default.a; });
__webpack_require__.d(global_namespaceObject, "toggleFav", function() { return external_toggleFav_default.a; });
__webpack_require__.d(global_namespaceObject, "LANG", function() { return external_LANG_default.a; });
__webpack_require__.d(global_namespaceObject, "userScreenName", function() { return external_userScreenName_default.a; });
__webpack_require__.d(global_namespaceObject, "contestScreenName", function() { return external_typeof_contestScreenName_undefined_contestScreenName_null_default.a; });
__webpack_require__.d(global_namespaceObject, "startTime", function() { return external_typeof_startTime_undefined_startTime_null_default.a; });
__webpack_require__.d(global_namespaceObject, "endTime", function() { return external_typeof_endTime_undefined_endTime_null_default.a; });
var data_namespaceObject = {};
__webpack_require__.r(data_namespaceObject);
__webpack_require__.d(data_namespaceObject, "getJsonData", function() { return getJsonData; });
__webpack_require__.d(data_namespaceObject, "getStandingsData", function() { return getStandingsData; });
__webpack_require__.d(data_namespaceObject, "getAPerfsData", function() { return getAPerfsData; });
__webpack_require__.d(data_namespaceObject, "getResultsData", function() { return getResultsData; });
__webpack_require__.d(data_namespaceObject, "getHistoryData", function() { return getHistoryData; });
__webpack_require__.d(data_namespaceObject, "getMyHistoryData", function() { return getMyHistoryData; });
__webpack_require__.d(data_namespaceObject, "getPerformanceHistories", function() { return getPerformanceHistories; });
var contestInformation_namespaceObject = {};
__webpack_require__.r(contestInformation_namespaceObject);
__webpack_require__.d(contestInformation_namespaceObject, "fetchContestInformation", function() { return fetchContestInformation; });
// CONCATENATED MODULE: ./src/libs/rating.js
//Copyright © 2017 koba-e964.
//from : https://github.com/koba-e964/atcoder-rating-estimator
const finf = bigf(400);
function bigf(n) {
let numerator = 1.0;
let denominator = 1.0;
for (let i = 0; i < n; ++i) {
numerator *= 0.81;
denominator *= 0.9;
}
numerator = (1 - numerator) * 0.81 / 0.19;
denominator = (1 - denominator) * 0.9 / 0.1;
return Math.sqrt(numerator) / denominator;
}
function f(n) {
return (bigf(n) - finf) / (bigf(1) - finf) * 1200.0;
}
/**
* calculate unpositivized rating from performance history
* @param {Number[]} [history] performance history
* @returns {Number} unpositivized rating
*/
function calcRatingFromHistory(history) {
let n = history.length;
let numerator = 0.0;
let denominator = 0.0;
for (let i = n - 1; i >= 0; --i) {
numerator *= 0.9;
numerator += 0.9 * Math.pow(2, history[i] / 800.0);
denominator *= 0.9;
denominator += 0.9;
}
return Math.log2(numerator / denominator) * 800.0 - f(n);
}
/**
* calculate unpositivized rating from last state
* @param {Number} [last] last unpositivized rating
* @param {Number} [perf] performance
* @param {Number} [ratedMatches] count of participated rated contest
* @returns {number} estimated unpositivized rating
*/
function calcRatingFromLast(last, perf, ratedMatches) {
if (ratedMatches === 0) return perf - 1200;
last += f(ratedMatches);
const weight = 9 - 9 * 0.9 ** ratedMatches;
const numerator = weight * (2 ** (last / 800.0)) + 2 ** (perf / 800.0);
const denominator = 1 + weight;
return Math.log2(numerator / denominator) * 800.0 - f(ratedMatches + 1);
}
/**
* (-inf, inf) -> (0, inf)
* @param {Number} [rating] unpositivized rating
* @returns {number} positivized rating
*/
function positivizeRating(rating) {
if (rating >= 400.0) {
return rating;
}
return 400.0 * Math.exp((rating - 400.0) / 400.0);
}
/**
* (0, inf) -> (-inf, inf)
* @param {Number} [rating] positivized rating
* @returns {number} unpositivized rating
*/
function unpositivizeRating(rating) {
if (rating >= 400.0) {
return rating;
}
return 400.0 + 400.0 * Math.log(rating / 400.0);
}
/**
* calculate the performance required to reach a target rate
* @param {Number} [targetRating] targeted unpositivized rating
* @param {Number[]} [history] performance history
* @returns {number} performance
*/
function calcRequiredPerformance(targetRating, history) {
let upper = 10000.0;
let lower = -10000.0;
for (let i = 0; i < 100; ++i) {
const mid = (lower + upper) / 2;
const rating = calcRatingFromHistory([mid].concat(history));
if (targetRating <= rating) upper = mid;
else lower = mid;
}
return lower;
}
const colorBounds = {
"gray": 0,
"brown": 400,
"green": 800,
"cyan": 1200,
"blue": 1600,
"yellow": 2000,
"orange": 2400,
"red": 2800
};
const colorNames = ["unrated", "gray", "brown", "green", "cyan", "blue", "yellow", "orange", "red"];
function getColor(rating) {
let colorIndex = rating > 0 ? Math.min(Math.floor(rating / 400) + 1, 8) : 0;
return colorNames[colorIndex];
}
// EXTERNAL MODULE: external "jQuery"
var external_jQuery_ = __webpack_require__(22);
// EXTERNAL MODULE: external "moment"
var external_moment_ = __webpack_require__(0);
var external_moment_default = /*#__PURE__*/__webpack_require__.n(external_moment_);
// EXTERNAL MODULE: external "has"
var external_has_ = __webpack_require__(1);
var external_has_default = /*#__PURE__*/__webpack_require__.n(external_has_);
// EXTERNAL MODULE: external "arrayToSet"
var external_arrayToSet_ = __webpack_require__(2);
var external_arrayToSet_default = /*#__PURE__*/__webpack_require__.n(external_arrayToSet_);
// EXTERNAL MODULE: external "setToArray"
var external_setToArray_ = __webpack_require__(3);
var external_setToArray_default = /*#__PURE__*/__webpack_require__.n(external_setToArray_);
// EXTERNAL MODULE: external "setCookie"
var external_setCookie_ = __webpack_require__(4);
var external_setCookie_default = /*#__PURE__*/__webpack_require__.n(external_setCookie_);
// EXTERNAL MODULE: external "getCookie"
var external_getCookie_ = __webpack_require__(5);
var external_getCookie_default = /*#__PURE__*/__webpack_require__.n(external_getCookie_);
// EXTERNAL MODULE: external "getCookieBool"
var external_getCookieBool_ = __webpack_require__(6);
var external_getCookieBool_default = /*#__PURE__*/__webpack_require__.n(external_getCookieBool_);
// EXTERNAL MODULE: external "delCookie"
var external_delCookie_ = __webpack_require__(7);
var external_delCookie_default = /*#__PURE__*/__webpack_require__.n(external_delCookie_);
// EXTERNAL MODULE: external "setLS"
var external_setLS_ = __webpack_require__(8);
var external_setLS_default = /*#__PURE__*/__webpack_require__.n(external_setLS_);
// EXTERNAL MODULE: external "getLS"
var external_getLS_ = __webpack_require__(9);
var external_getLS_default = /*#__PURE__*/__webpack_require__.n(external_getLS_);
// EXTERNAL MODULE: external "delLS"
var external_delLS_ = __webpack_require__(10);
var external_delLS_default = /*#__PURE__*/__webpack_require__.n(external_delLS_);
// EXTERNAL MODULE: external "getServerTime"
var external_getServerTime_ = __webpack_require__(11);
var external_getServerTime_default = /*#__PURE__*/__webpack_require__.n(external_getServerTime_);
// EXTERNAL MODULE: external "rand"
var external_rand_ = __webpack_require__(12);
var external_rand_default = /*#__PURE__*/__webpack_require__.n(external_rand_);
// EXTERNAL MODULE: external "copy"
var external_copy_ = __webpack_require__(13);
var external_copy_default = /*#__PURE__*/__webpack_require__.n(external_copy_);
// EXTERNAL MODULE: external "storeFavs"
var external_storeFavs_ = __webpack_require__(14);
var external_storeFavs_default = /*#__PURE__*/__webpack_require__.n(external_storeFavs_);
// EXTERNAL MODULE: external "reloadFavs"
var external_reloadFavs_ = __webpack_require__(15);
var external_reloadFavs_default = /*#__PURE__*/__webpack_require__.n(external_reloadFavs_);
// EXTERNAL MODULE: external "toggleFav"
var external_toggleFav_ = __webpack_require__(16);
var external_toggleFav_default = /*#__PURE__*/__webpack_require__.n(external_toggleFav_);
// EXTERNAL MODULE: external "LANG"
var external_LANG_ = __webpack_require__(17);
var external_LANG_default = /*#__PURE__*/__webpack_require__.n(external_LANG_);
// EXTERNAL MODULE: external "userScreenName"
var external_userScreenName_ = __webpack_require__(18);
var external_userScreenName_default = /*#__PURE__*/__webpack_require__.n(external_userScreenName_);
// EXTERNAL MODULE: external "(typeof contestScreenName !== \"undefined\" ? contestScreenName : null)"
var external_typeof_contestScreenName_undefined_contestScreenName_null_ = __webpack_require__(19);
var external_typeof_contestScreenName_undefined_contestScreenName_null_default = /*#__PURE__*/__webpack_require__.n(external_typeof_contestScreenName_undefined_contestScreenName_null_);
// EXTERNAL MODULE: external "(typeof startTime !== \"undefined\" ? startTime : null)"
var external_typeof_startTime_undefined_startTime_null_ = __webpack_require__(20);
var external_typeof_startTime_undefined_startTime_null_default = /*#__PURE__*/__webpack_require__.n(external_typeof_startTime_undefined_startTime_null_);
// EXTERNAL MODULE: external "(typeof endTime !== \"undefined\" ? endTime : null)"
var external_typeof_endTime_undefined_endTime_null_ = __webpack_require__(21);
var external_typeof_endTime_undefined_endTime_null_default = /*#__PURE__*/__webpack_require__.n(external_typeof_endTime_undefined_endTime_null_);
// CONCATENATED MODULE: ./src/libs/global.js
//utils.js
//global variable
//only contest page
// CONCATENATED MODULE: ./src/libs/data.js
/**
* @typedef {{IsRated: boolean, Place: number, OldRating: number, NewRating: number, Performance: number, InnerPerformance: number, ContestScreenName: string, ContestName: string, EndTime : string}} UserResult
* @typedef {{Assignment: string, TaskName: string, TaskScreenName: string}} TaskInfo
* @typedef {{Count: number, Failure: number, Penalty: number, Score: number, Elapsed: number, Status: number, Pending: boolean, Frozen: boolean, Additional: null}} StandingResult
* @typedef {{Rank: number, Additional: null, UserName: string, UserScreenName: string, UserIsDeleted: boolean, Affiliation: string, Country: string, Rating: number, OldRating: number, IsRated: boolean, Competitions: number, TaskResults: StandingResult[], TotalResult: StandingResult}} StandingData
* @typedef {{Fixed: boolean, AdditionalColumns:null, TaskInfo: TaskInfo[], StandingsData: StandingData[]}} Standings
*/
/**
* urlにあるjsonデータを取得する
* @param url
* @return {Promise<{}>}
*/
async function getJsonData(url) {
return await external_jQuery_["ajax"]({url: url, dataType: "json"})
}
/**
*
* @param contestScreenName
* @return {Promise<Standings>}
*/
async function getStandingsData(contestScreenName) {
return await getJsonData(`https://atcoder.jp/contests/${contestScreenName}/standings/json`);
}
/**
* コンテストの結果一覧を取得する
* @param {string} [contestScreenName] コンテスト名
* @return {Promise<Object.<string, number>>}
*/
async function getAPerfsData(contestScreenName) {
return await getJsonData(`https://data.ac-predictor.com/aperfs/${contestScreenName}.json`);
}
/**
* コンテストの結果一覧を取得する
* @param {string} [contestScreenName] コンテスト名
* @return {Promise<UserResult[]>}
*/
async function getResultsData(contestScreenName) {
return await getJsonData(`https://atcoder.jp/contests/${contestScreenName}/results/json`);
}
/**
* ユーザーのコンテスト参加履歴を取得する
* @param {string} [userScreenName] ユーザー名
* @return {Promise<UserResult[]>}
*/
async function getHistoryData(userScreenName) {
return await getJsonData(`https://atcoder.jp/users/${userScreenName}/history/json`);
}
/**
* @type {UserResult[]}
*/
let myHistoryData = null;
/**
* 自分のパフォーマンス履歴を取得
* @return {Promise<UserResult[]>} パフォーマンス履歴を返すpromise
*/
async function getMyHistoryData() {
return new Promise((resolve) => {
if (myHistoryData || !external_userScreenName_default.a) resolve(myHistoryData);
getHistoryData(external_userScreenName_default.a).then((data) => {
resolve(myHistoryData = data);
})
});
}
/**
* ユーザーのパフォーマンス履歴を時間降順で取得
* @param {UserResult[]} [history] ユーザーのコンテスト結果履歴
* @return {number[]}
*/
function getPerformanceHistories(history) {
let onlyRated = history.filter(x => x.IsRated);
onlyRated.sort((a, b) => external_moment_default()(b.EndTime) - external_moment_default()(a.EndTime));
return onlyRated.map(x => x.Performance);
}
// CONCATENATED MODULE: ./src/libs/contestInformation.js
class ContestInformation{
/**
* @param {number[]} [participatableRange]
* @param {number[]} [ratedRange]
* @param {number} [penalty]
*/
constructor(participatableRange, ratedRange, penalty){
this.ParticipatableRange = participatableRange;
this.RatedRange = ratedRange;
this.Penalty = penalty;
}
}
/**
* トップページに表示されるコンテスト情報を取得
* @param {string} [contestScreenName] コンテスト名
* @return {Promise<ContestInformation>} コンテスト情報を返すPromise
*/
async function fetchContestInformation(contestScreenName) {
return new Promise(async (resolve) => {
const topPageDom = await $.ajax(`https://atcoder.jp/contests/${contestScreenName}`).then(x => new DOMParser().parseFromString(x, "text/html"));
const dataParagraph = topPageDom.getElementsByClassName("small")[0];
const data = Array.from(dataParagraph.children).map(x => x.innerText.split(':')[1].trim());
resolve(new ContestInformation(parseRangeString(data[0]), parseRangeString(data[1]), parseDurationString(data[2])));
});
/**
* 範囲を表す文字列をパースする
* @param {string} [s] 範囲を表す文字列
* @return {number[]} 範囲を表す配列
*/
function parseRangeString(s){
if (s === 'All') return [0, Infinity];
if (s.indexOf('~') === -1) return [0, -1];
let res = s.split('~').map(x => parseInt(x.trim()));
if (isNaN(res[0])) res[0] = 0;
if (isNaN(res[1])) res[1] = Infinity;
return res;
}
/**
* 期間を表す文字列をパースする
* @param {string} [s] 期間を表す文字列
* @return {number} パース結果(ミリ秒)
*/
function parseDurationString(s) {
if (s === "None" || s === "なし") return 0;
if (!/(\d+[^\d]+)/.test(s)) return NaN;
const dic = {ヶ月: "month", 日: "day", 時間: "hour", 分: "minute", 秒: "second"};
let res = {};
s.match(/(\d+[^\d]+)/g).forEach(x => {
const trimmed = x.trim(' ','s');
const num = trimmed.match(/\d+/)[0];
const unit = trimmed.match(/[^\d]+/)[0];
const convertedUnit = dic[unit]||unit;
res[convertedUnit] = num;
});
return external_moment_["duration"](res).asMilliseconds();
}
}
// CONCATENATED MODULE: ./src/main.js
/* concated harmony reexport rating */__webpack_require__.d(__webpack_exports__, "rating", function() { return rating_namespaceObject; });
/* concated harmony reexport data */__webpack_require__.d(__webpack_exports__, "data", function() { return data_namespaceObject; });
/* concated harmony reexport contestInformation */__webpack_require__.d(__webpack_exports__, "contestInformation", function() { return contestInformation_namespaceObject; });
/* concated harmony reexport global */__webpack_require__.d(__webpack_exports__, "global", function() { return global_namespaceObject; });
/***/ })
/******/ ]);