Greasy Fork is available in English.

在 CPE 歷屆試題網頁顯示難度星級及該題 vjudge 連結

難度星級取自官方資料

// ==UserScript==
// @name         在 CPE 歷屆試題網頁顯示難度星級及該題 vjudge 連結
// @namespace    https://github.com/zica87/self-made-userscipts
// @version      1.0
// @description  難度星級取自官方資料
// @author       zica
// @match        https://cpe.cse.nsysu.edu.tw/cpe/test_data/problems
// @grant        none
// @license      GPL-3.0
// ==/UserScript==

(function () {
    "use strict";

    // place main code above the long mapping
    // eliminate the trouble to scroll over it to view the main coden
    function main_code() {
        const tables = document.getElementsByTagName("tbody");
        for (const table of tables) {
            for (let i = 1; i < table.children.length; ++i) {
                const td = table.children[i].firstElementChild;
                if (td.tagName != "TD") {
                    continue;
                }
                const problem_title = td.firstElementChild;
                const number = problem_title.textContent.match(/\d+/)[0];
                const star = document.createElement("span");
                star.textContent =
                    star_table[number] === undefined
                        ? "❓"
                        : star_table[number] +
                          " " +
                          "🌟".repeat(star_table[number]);
                problem_title.before(star);

                const vjudge_a = document.createElement("a");
                Object.assign(vjudge_a, {
                    href: "https://vjudge.net/problem/UVA-" + number,
                    textContent: "vjudge",
                    target: "_blank",
                });
                // copied from the page
                td.append("\n\t\t\t\t\t/\n\t\t\t\t\t");
                td.append(vjudge_a);
            }
        }
    }
    const star_table = {
        100: "1",
        105: "1",
        108: "2",
        118: "1",
        122: "3",
        136: "1",
        141: "1",
        145: "1",
        147: "4",
        151: "2",
        160: "2",
        165: "4",
        166: "4",
        240: "4",
        242: "3",
        245: "2",
        255: "2",
        256: "1",
        263: "1",
        264: "1",
        272: "1",
        288: "4",
        294: "2",
        299: "1",
        300: "2",
        302: "4",
        305: "1",
        315: "3",
        337: "2",
        340: "2",
        374: "2",
        378: "2",
        380: "2",
        382: "1",
        386: "1",
        389: "1",
        397: "2",
        401: "1",
        406: "2",
        409: "1",
        437: "4",
        439: "2",
        455: "1",
        458: "1",
        476: "1",
        481: "4",
        482: "1",
        490: "1",
        494: "1",
        495: "2",
        496: "1",
        499: "1",
        501: "3",
        514: "2",
        516: "2",
        532: "3",
        534: "2",
        536: "2",
        540: "2",
        544: "3",
        572: "2",
        573: "1",
        579: "1",
        580: "3",
        591: "1",
        612: "2",
        615: "2",
        630: "1",
        657: "2",
        674: "3",
        679: "2",
        686: "2",
        696: "2",
        706: "1",
        709: "4",
        714: "4",
        719: "4",
        722: "2",
        725: "1",
        737: "1",
        748: "2",
        753: "4",
        763: "1",
        793: "3",
        798: "3",
        815: "2",
        820: "4",
        821: "2",
        855: "2",
        865: "1",
        900: "2",
        908: "3",
        913: "1",
        924: "2",
        926: "3",
        928: "3",
        929: "3",
        941: "3",
        948: "1",
        967: "2",
        991: "2",
        993: "2",
        997: "2",
        1101: "4",
        1118: "2",
        1200: "2",
        1208: "3",
        1210: "2",
        1225: "1",
        1237: "1",
        1260: "1",
        1262: "2",
        1292: "4",
        1316: "2",
        1339: "1",
        1366: "3",
        1368: "1",
        1513: "4",
        1585: "1",
        1587: "1",
        1632: "3",
        1640: "2",
        1644: "2",
        1650: "4",
        1730: "3",
        1746: "3",
        1753: "2",
        1757: "3",
        10000: "3",
        10001: "2",
        10002: "2",
        10003: "3",
        10004: "2",
        10005: "3",
        10006: "2",
        10007: "3",
        10008: "1",
        10009: "2",
        10010: "2",
        10011: "3",
        10012: "3",
        10013: "2",
        10014: "2",
        10015: "2",
        10016: "2",
        10017: "2",
        10018: "1",
        10019: "1",
        10020: "2",
        10021: "5",
        10022: "3",
        10023: "3",
        10024: "3",
        10025: "3",
        10026: "3",
        10027: "3",
        10028: "2",
        10029: "4",
        10030: "2",
        10031: "3",
        10032: "4",
        10033: "3",
        10034: "2",
        10035: "1",
        10036: "3",
        10037: "3",
        10038: "1",
        10039: "2",
        10040: "2",
        10041: "1",
        10042: "3",
        10043: "3",
        10044: "3",
        10045: "3",
        10047: "3",
        10048: "3",
        10049: "3",
        10050: "1",
        10051: "4",
        10052: "3",
        10053: "3",
        10054: "3",
        10055: "1",
        10056: "1",
        10057: "1",
        10058: "3",
        10059: "5",
        10060: "2",
        10061: "3",
        10062: "1",
        10063: "2",
        10064: "2",
        10065: "4",
        10066: "2",
        10067: "4",
        10068: "4",
        10069: "3",
        10070: "2",
        10071: "1",
        10072: "3",
        10073: "4",
        10074: "3",
        10075: "4",
        10076: "3",
        10077: "2",
        10078: "2",
        10079: "1",
        10080: "4",
        10081: "3",
        10082: "1",
        10083: "3",
        10084: "5",
        10085: "4",
        10086: "4",
        10087: "4",
        10088: "3",
        10089: "4",
        10090: "4",
        10091: "4",
        10092: "4",
        10093: "1",
        10094: "4",
        10095: "4",
        10096: "3",
        10097: "3",
        10098: "2",
        10099: "3",
        10100: "2",
        10101: "1",
        10102: "2",
        10103: "4",
        10104: "2",
        10105: "3",
        10106: "2",
        10107: "1",
        10108: "3",
        10109: "3",
        10110: "2",
        10111: "4",
        10112: "3",
        10113: "3",
        10114: "2",
        10115: "2",
        10116: "2",
        10117: "3",
        10118: "4",
        10119: "5",
        10120: "5",
        10121: "4",
        10123: "3",
        10124: "3",
        10125: "2",
        10126: "1",
        10127: "2",
        10128: "4",
        10129: "3",
        10130: "3",
        10131: "3",
        10132: "3",
        10133: "4",
        10134: "3",
        10135: "3",
        10136: "3",
        10137: "2",
        10138: "2",
        10139: "3",
        10140: "2",
        10141: "2",
        10142: "2",
        10143: "4",
        10144: "3",
        10145: "2",
        10146: "2",
        10147: "3",
        10148: "3",
        10149: "5",
        10150: "3",
        10151: "3",
        10152: "2",
        10153: "3",
        10154: "4",
        10155: "3",
        10156: "1",
        10157: "3",
        10158: "3",
        10159: "3",
        10160: "2",
        10161: "2",
        10162: "4",
        10163: "4",
        10164: "3",
        10165: "3",
        10166: "4",
        10167: "2",
        10168: "4",
        10169: "3",
        10170: "1",
        10171: "3",
        10172: "2",
        10173: "4",
        10174: "2",
        10175: "3",
        10176: "2",
        10177: "3",
        10178: "3",
        10179: "3",
        10180: "2",
        10181: "3",
        10182: "2",
        10183: "3",
        10184: "3",
        10185: "4",
        10186: "3",
        10187: "3",
        10188: "1",
        10189: "1",
        10190: "1",
        10191: "1",
        10192: "2",
        10193: "2",
        10194: "2",
        10195: "2",
        10196: "2",
        10197: "2",
        10198: "3",
        10199: "3",
        10200: "2",
        10201: "3",
        10202: "3",
        10203: "2",
        10204: "4",
        10205: "2",
        10206: "5",
        10207: "3",
        10208: "4",
        10209: "1",
        10210: "3",
        10211: "4",
        10212: "3",
        10213: "3",
        10214: "3",
        10215: "1",
        10216: "3",
        10217: "3",
        10218: "4",
        10219: "3",
        10220: "2",
        10221: "1",
        10222: "1",
        10223: "2",
        10224: "4",
        10225: "2",
        10226: "1",
        10227: "2",
        10228: "3",
        10229: "4",
        10230: "3",
        10231: "3",
        10232: "3",
        10233: "2",
        10234: "3",
        10235: "1",
        10236: "2",
        10237: "4",
        10238: "2",
        10239: "4",
        10240: "3",
        10241: "3",
        10242: "1",
        10243: "3",
        10244: "4",
        10245: "3",
        10246: "3",
        10247: "3",
        10248: "3",
        10249: "4",
        10250: "3",
        10251: "3",
        10252: "2",
        10253: "4",
        10254: "4",
        10255: "3",
        10256: "2",
        10257: "1",
        10258: "1",
        10259: "3",
        10260: "1",
        10261: "3",
        10262: "3",
        10263: "2",
        10264: "2",
        10265: "3",
        10266: "2",
        10267: "2",
        10268: "1",
        10269: "3",
        10270: "5",
        10271: "3",
        10272: "4",
        10273: "3",
        10274: "4",
        10275: "4",
        10276: "3",
        10277: "3",
        10278: "3",
        10279: "1",
        10280: "3",
        10281: "1",
        10282: "1",
        10283: "2",
        10284: "2",
        10285: "3",
        10286: "2",
        10287: "2",
        10288: "3",
        10289: "2",
        10290: "4",
        10291: "4",
        10292: "4",
        10293: "2",
        10294: "4",
        10295: "2",
        10296: "4",
        10297: "2",
        10298: "2",
        10299: "2",
        10300: "1",
        10301: "2",
        10302: "2",
        10303: "3",
        10304: "3",
        10305: "2",
        10306: "3",
        10307: "3",
        10308: "3",
        10309: "4",
        10310: "1",
        10311: "2",
        10312: "3",
        10313: "3",
        10314: "4",
        10315: "2",
        10316: "3",
        10317: "3",
        10318: "4",
        10319: "4",
        10320: "3",
        10321: "4",
        10322: "2",
        10323: "1",
        10324: "1",
        10325: "2",
        10326: "2",
        10327: "2",
        10328: "3",
        10329: "3",
        10330: "5",
        10331: "3",
        10332: "3",
        10333: "2",
        10334: "2",
        10335: "3",
        10336: "2",
        10337: "3",
        10338: "2",
        10339: "2",
        10340: "1",
        10341: "2",
        10342: "3",
        10343: "2",
        10344: "2",
        10345: "2",
        10346: "1",
        10347: "2",
        10348: "2",
        10349: "3",
        10350: "2",
        10351: "3",
        10352: "2",
        10353: "3",
        10354: "3",
        10356: "3",
        10360: "2",
        10364: "4",
        10368: "2",
        10369: "3",
        10370: "1",
        10371: "2",
        10372: "2",
        10373: "3",
        10382: "2",
        10393: "1",
        10394: "3",
        10396: "4",
        10397: "3",
        10400: "3",
        10401: "3",
        10404: "4",
        10405: "2",
        10406: "2",
        10407: "2",
        10408: "2",
        10409: "1",
        10415: "1",
        10418: "5",
        10419: "4",
        10420: "1",
        10424: "1",
        10427: "2",
        10429: "3",
        10432: "2",
        10433: "3",
        10439: "3",
        10440: "2",
        10443: "1",
        10450: "2",
        10465: "3",
        10466: "2",
        10468: "3",
        10469: "1",
        10473: "1",
        10474: "1",
        10478: "3",
        10482: "3",
        10487: "1",
        10489: "2",
        10494: "2",
        10496: "3",
        10497: "2",
        10499: "1",
        10502: "3",
        10504: "2",
        10508: "2",
        10515: "3",
        10520: "3",
        10523: "2",
        10527: "2",
        10533: "2",
        10534: "4",
        10535: "2",
        10539: "3",
        10541: "3",
        10550: "1",
        10555: "3",
        10563: "2",
        10571: "4",
        10573: "1",
        10574: "3",
        10579: "2",
        10583: "2",
        10585: "1",
        10591: "1",
        10596: "2",
        10599: "4",
        10600: "3",
        10606: "3",
        10608: "2",
        10611: "2",
        10615: "5",
        10625: "2",
        10626: "3",
        10627: "4",
        10633: "1",
        10635: "4",
        10637: "3",
        10642: "1",
        10664: "3",
        10666: "2",
        10670: "2",
        10672: "3",
        10673: "2",
        10678: "1",
        10679: "3",
        10684: "2",
        10696: "1",
        10699: "1",
        10700: "2",
        10701: "3",
        10702: "3",
        10703: "1",
        10710: "3",
        10714: "1",
        10718: "2",
        10721: "3",
        10724: "3",
        10730: "2",
        10738: "2",
        10739: "3",
        10763: "2",
        10783: "1",
        10789: "1",
        10791: "3",
        10793: "3",
        10800: "2",
        10801: "3",
        10802: "3",
        10810: "3",
        10812: "1",
        10813: "1",
        10815: "2",
        10819: "3",
        10820: "2",
        10821: "3",
        10856: "3",
        10858: "2",
        10859: "3",
        10862: "4",
        10871: "2",
        10879: "1",
        10881: "2",
        10887: "2",
        10888: "4",
        10891: "3",
        10898: "3",
        10900: "4",
        10901: "2",
        10902: "2",
        10903: "1",
        10904: "5",
        10905: "3",
        10908: "1",
        10909: "4",
        10910: "2",
        10911: "3",
        10912: "3",
        10913: "4",
        10914: "4",
        10915: "2",
        10916: "2",
        10917: "3",
        10918: "3",
        10919: "1",
        10920: "2",
        10921: "1",
        10922: "1",
        10923: "4",
        10924: "2",
        10925: "1",
        10926: "2",
        10927: "3",
        10929: "1",
        10930: "2",
        10931: "1",
        10934: "3",
        10935: "1",
        10936: "2",
        10938: "2",
        10940: "2",
        10942: "1",
        10944: "4",
        10945: "1",
        10949: "4",
        10954: "3",
        10959: "2",
        10963: "3",
        10968: "3",
        10970: "1",
        10978: "1",
        10981: "4",
        10985: "4",
        10986: "3",
        10990: "4",
        10994: "1",
        11000: "1",
        11001: "1",
        11002: "3",
        11003: "4",
        11004: "3",
        11005: "1",
        11006: "3",
        11007: "5",
        11008: "4",
        11010: "4",
        11011: "3",
        11012: "4",
        11013: "2",
        11014: "5",
        11015: "3",
        11018: "3",
        11019: "5",
        11020: "3",
        11021: "3",
        11022: "3",
        11023: "4",
        11024: "3",
        11025: "4",
        11026: "3",
        11027: "3",
        11029: "3",
        11030: "3",
        11031: "3",
        11032: "4",
        11033: "3",
        11034: "1",
        11035: "3",
        11036: "3",
        11037: "4",
        11038: "3",
        11039: "2",
        11040: "2",
        11041: "4",
        11042: "1",
        11043: "2",
        11044: "1",
        11045: "3",
        11046: "5",
        11047: "3",
        11048: "3",
        11049: "3",
        11050: "5",
        11051: "2",
        11052: "3",
        11053: "3",
        11054: "1",
        11055: "3",
        11056: "2",
        11057: "2",
        11058: "1",
        11059: "1",
        11060: "3",
        11061: "4",
        11063: "1",
        11064: "3",
        11066: "3",
        11067: "2",
        11069: "3",
        11071: "4",
        11072: "3",
        11073: "4",
        11076: "2",
        11077: "3",
        11078: "2",
        11080: "3",
        11081: "5",
        11082: "4",
        11083: "4",
        11084: "3",
        11085: "4",
        11086: "2",
        11088: "3",
        11089: "4",
        11092: "3",
        11093: "2",
        11094: "2",
        11095: "3",
        11096: "2",
        11097: "4",
        11098: "5",
        11099: "4",
        11115: "2",
        11121: "2",
        11149: "4",
        11150: "1",
        11151: "3",
        11157: "2",
        11159: "4",
        11166: "3",
        11172: "1",
        11185: "1",
        11192: "1",
        11198: "4",
        11200: "3",
        11204: "1",
        11212: "3",
        11218: "3",
        11219: "1",
        11228: "3",
        11233: "1",
        11235: "2",
        11237: "4",
        11240: "2",
        11241: "2",
        11258: "3",
        11259: "4",
        11264: "2",
        11284: "4",
        11286: "2",
        11287: "2",
        11297: "4",
        11307: "4",
        11308: "2",
        11309: "1",
        11310: "3",
        11311: "3",
        11312: "4",
        11313: "1",
        11314: "3",
        11316: "4",
        11317: "4",
        11319: "3",
        11321: "1",
        11324: "4",
        11326: "2",
        11327: "3",
        11330: "3",
        11331: "4",
        11332: "1",
        11335: "2",
        11336: "3",
        11340: "2",
        11341: "4",
        11342: "1",
        11343: "1",
        11344: "2",
        11345: "1",
        11346: "3",
        11347: "3",
        11348: "2",
        11349: "1",
        11350: "2",
        11351: "3",
        11352: "3",
        11353: "3",
        11354: "3",
        11360: "2",
        11364: "1",
        11367: "3",
        11368: "3",
        11369: "2",
        11377: "3",
        11387: "1",
        11388: "1",
        11389: "1",
        11396: "2",
        11400: "4",
        11401: "4",
        11402: "4",
        11403: "2",
        11404: "4",
        11405: "4",
        11407: "3",
        11408: "4",
        11410: "3",
        11411: "4",
        11412: "2",
        11413: "4",
        11414: "3",
        11415: "4",
        11417: "2",
        11418: "2",
        11419: "5",
        11420: "3",
        11421: "4",
        11422: "4",
        11424: "4",
        11426: "4",
        11427: "4",
        11428: "1",
        11430: "4",
        11436: "4",
        11450: "3",
        11455: "1",
        11456: "4",
        11461: "1",
        11462: "2",
        11463: "3",
        11464: "4",
        11465: "4",
        11466: "3",
        11467: "5",
        11470: "1",
        11471: "4",
        11472: "4",
        11475: "2",
        11479: "1",
        11480: "2",
        11481: "3",
        11482: "1",
        11483: "1",
        11484: "2",
        11485: "4",
        11486: "4",
        11487: "3",
        11488: "3",
        11489: "2",
        11490: "3",
        11494: "1",
        11495: "3",
        11498: "1",
        11502: "4",
        11503: "3",
        11504: "4",
        11505: "2",
        11506: "4",
        11507: "2",
        11508: "2",
        11512: "4",
        11513: "3",
        11515: "2",
        11516: "3",
        11517: "3",
        11518: "2",
        11519: "2",
        11520: "2",
        11523: "3",
        11534: "3",
        11536: "2",
        11538: "2",
        11541: "1",
        11547: "1",
        11550: "2",
        11583: "2",
        11584: "3",
        11585: "3",
        11586: "2",
        11597: "1",
        11603: "3",
        11608: "1",
        11609: "2",
        11614: "2",
        11615: "2",
        11616: "2",
        11617: "4",
        11621: "1",
        11624: "4",
        11629: "2",
        11631: "3",
        11632: "3",
        11633: "3",
        11634: "1",
        11635: "3",
        11636: "1",
        11639: "1",
        11650: "1",
        11654: "3",
        11655: "3",
        11658: "3",
        11659: "4",
        11660: "1",
        11661: "1",
        11677: "1",
        11678: "1",
        11683: "2",
        11689: "1",
        11690: "3",
        11691: "3",
        11692: "2",
        11696: "4",
        11703: "2",
        11713: "1",
        11714: "2",
        11716: "1",
        11726: "3",
        11727: "1",
        11728: "1",
        11729: "2",
        11730: "2",
        11732: "3",
        11733: "3",
        11734: "1",
        11742: "2",
        11743: "1",
        11747: "3",
        11748: "3",
        11764: "1",
        11770: "4",
        11777: "1",
        11782: "3",
        11792: "3",
        11799: "0",
        11824: "1",
        11827: "1",
        11830: "1",
        11838: "3",
        11841: "3",
        11847: "2",
        11849: "2",
        11850: "2",
        11854: "1",
        11871: "4",
        11875: "1",
        11879: "2",
        11898: "2",
        11900: "1",
        11908: "3",
        11909: "1",
        11917: "1",
        11922: "5",
        11933: "1",
        11934: "1",
        11936: "1",
        11942: "1",
        11945: "1",
        11946: "1",
        11953: "2",
        11957: "2",
        11960: "2",
        11965: "1",
        11984: "1",
        11985: "4",
        11987: "3",
        11988: "1",
        11991: "2",
        11995: "2",
        11997: "2",
        12015: "1",
        12019: "1",
        12030: "5",
        12034: "3",
        12041: "4",
        12075: "5",
        12092: "5",
        12136: "1",
        12149: "1",
        12160: "2",
        12195: "1",
        12207: "2",
        12208: "3",
        12218: "2",
        12223: "4",
        12289: "1",
        12293: "3",
        12296: "3",
        12299: "4",
        12319: "3",
        12335: "3",
        12372: "1",
        12376: "3",
        12382: "2",
        12385: "3",
        12390: "3",
        12403: "1",
        12405: "1",
        12406: "2",
        12416: "1",
        12439: "1",
        12455: "2",
        12468: "1",
        12478: "1",
        12503: "1",
        12507: "3",
        12532: "4",
        12544: "3",
        12545: "2",
        12546: "3",
        12578: "1",
        12582: "3",
        12592: "2",
        12602: "1",
        12611: "1",
        12621: "3",
        12626: "1",
        12627: "3",
        12640: "1",
        12650: "1",
        12654: "3",
        12694: "2",
        12705: "2",
        12797: "2",
        12820: "1",
        12821: "4",
        12844: "2",
        12869: "2",
        12875: "3",
        12908: "1",
        12911: "4",
        12918: "2",
        12959: "1",
        12970: "1",
        13055: "1",
        13171: "1",
        13185: "1",
        13190: "1",
        13194: "2",
        13257: "2",
    };
    main_code();
})();