Add Solution To GMOJ

添加一份 solution 到 GMOJ

目前为 2024-08-01 提交的版本。查看 最新版本

// ==UserScript==
// @name         Add Solution To GMOJ
// @namespace    https://gf.qytechs.cn/zh-CN/users/1342573-lnw143
// @version      1.0
// @description  添加一份 solution 到 GMOJ
// @author       lnw143
// @match        https://gmoj.net/senior/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=gmoj.net
// @grant        none
// @connect      lnw143.github.io
// @license      MIT
// ==/UserScript==

function waitElement(selector, callback) {
  if ($(selector).length) {
    callback();
  } else {
    setTimeout(() => {
      waitElement(selector, callback);
    }, 100);
  }
}

waitElement(
    '#sidebar .well:contains("题解") .sidebar_fieldset_rows:last-child',
    function() {
        'use strict';
        console.log("running");
        let urls = location.href.split('/');
        const pid = urls[urls.length-1];
        if(pid.length != 4){
            console.error('pid is not 4 digits');
            return;
        }
        console.log('pid is ' + pid);
        $(`<div class="sidebar_fieldset_rows">
		<div class="link_solution" data-toggle="tooltip" title="" data-original-title="By lnw143">
		<a href="https://lnw143.github.io/blog/gmoj/p` + pid + `/">solution</a>
		</div> </div>`)
            .insertAfter('#sidebar .well:contains("题解") .sidebar_fieldset_rows:last-child');
        $('.link_solution').tooltip();
        console.log('finished');
    }
);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址