// ==UserScript==
// @name Tabbed AtCoder Editorial
// @version 0.4
// @description display atcoder editorial in tabs
// @match https://atcoder.jp/contests/*/editorial
// @match https://atcoder.jp/contests/*/editorial?*
// @grant GM_addStyle
// @license MIT
// @namespace https://greasyfork.org/users/808669
// @downloadURL none
// ==/UserScript==
/* jshint esversion:8 */
(async function () {
'use strict';
const katexoption = {
delimiters: [
{ left: "$$", right: "$$", display: true },
{ left: "$", right: "$", display: false },
{ left: "\\(", right: "\\)", display: false },
{ left: "\\[", right: "\\]", display: true }
],
ignoredTags: ["script", "noscript", "style", "textarea", "code", "option"],
ignoredClasses: ["prettyprint", "source-code-for-copy"],
throwOnError: false
};
async function addScript(src) {
return new Promise((resolve) => {
const script = document.createElement("script");
script.type = "text/javascript";
script.src = src;
script.onload = resolve;
document.getElementsByTagName("head")[0].appendChild(script);
});
}
async function addLink(href) {
return new Promise((resolve) => {
const link = document.createElement("link");
link.rel = "stylesheet";
link.href = href;
link.onload = resolve;
document.getElementsByTagName("head")[0].appendChild(link);
});
}
async function getEditorial(link) {
return new Promise((resolve) => {
const xhr = new XMLHttpRequest();
xhr.responseType = "document";
xhr.onload = (response) => {
const editorial = response.target.responseXML.querySelector("#main-container > div.row > div:nth-child(2) > div:nth-child(3)");
if (editorial) {
renderMathInElement(editorial, katexoption);
link.parentNode.appendChild(editorial);
}
resolve();
};
xhr.open("GET", link.href);
xhr.send();
});
}
async function getTextResponse(href) {
return new Promise((resolve) => {
const xhr = new XMLHttpRequest();
xhr.onload = (response) => {
resolve(response.target.responseText);
};
xhr.open("GET", href);
xhr.overrideMimeType("text/plain; charset=Shift_JIS");
xhr.send();
});
}
async function typical90(id) {
const editorial = { "005": 3, "011": 2, "017": 3, "023": 4, "029": 2, "035": 3, "041": 3, "047": 2, "053": 4, "059": 3, "065": 3, "071": 3, "077": 3, "083": 4, "084": 2, "085": 2, "086": 2, "087": 2, "088": 2, "089": 4, "090": 6 };
const source = { "005": "005-03", "011": "011-03", "017": "017-03", "023": "023-04b", "029": "029-03", "035": "035-04", "041": "041-03", "047": "047-02", "053": "053-04", "059": "059-02", "061": "061-02", "065": "065-03", "071": "071-03", "077": "077-04b", "083": "083-02a", "084": "084-02", "089": "089-05", "090": "090-07b" };
let content = `問題文
${code}
`;
return `