您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Rewrites variable names in AtCoder problem statements.
当前为
- // ==UserScript==
- // @name atcoder-refactor
- // @namespace https://github.com/yoshrc
- // @version 0.1
- // @description Rewrites variable names in AtCoder problem statements.
- // @author yoshrc
- // @match https://atcoder.jp/contests/*/tasks/*
- // @grant none
- // ==/UserScript==
- // TODO
- // - Inline edit like IDE's multiselection instead of popup
- // - Save variable name mapping in localStorage
- (function() {
- 'use strict';
- const ID_ATTR = 'data-atcoder-refactor-id';
- const isAlpha = str => str.match(/^[A-Za-z]+$/);
- const rewriteVariables = id => {
- // TODO: Use current variable name instead of id
- const newName = prompt('Variable Name', id);
- document.querySelectorAll(`[${ID_ATTR}=${id}]`).forEach(varElem => {
- varElem.textContent = newName;
- })
- }
- // TODO: Use MathJax hook instead of wait 1000ms
- setTimeout(() => {
- document.querySelectorAll('.mjx-char').forEach(varElem => {
- const varId = varElem.textContent;
- if (!isAlpha(varId)) {
- return;
- }
- varElem.setAttribute(ID_ATTR, varId);
- varElem.onclick = () => rewriteVariables(varId);
- });
- }, 1000);
- })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址