Greasy Fork

Greasy Fork is available in English.

专业技术人员学习新干线

开始学习直接跳转到学习页,不用二次中转

当前为 2025-06-24 提交的版本,查看 最新版本

// ==UserScript==
// @name         专业技术人员学习新干线
// @namespace    https://learning.hzrs.hangzhou.gov.cn
// @version      2025-06-24
// @description  开始学习直接跳转到学习页,不用二次中转
// @author       NetFert
// @match        https://learning.hzrs.hangzhou.gov.cn/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    const load=()=>{
        fetch("https://learning.hzrs.hangzhou.gov.cn/api/index/Course/index", {
            "headers": {
                "accept": "application/json, text/plain, */*",
                "authorization": "Bearer "+localStorage.getItem("front_token"),
                "cache-control": "no-cache",
                "content-type": "application/json",
                "pragma": "no-cache",
                "sec-fetch-dest": "empty",
                "sec-fetch-mode": "cors",
                "sec-fetch-site": "same-origin"
            },
            "referrer": "https://learning.hzrs.hangzhou.gov.cn/",
            "referrerPolicy": "strict-origin-when-cross-origin",
            "body": "{\"limit\":10,\"page\":1}",
            "method": "POST",
            "mode": "cors",
            "credentials": "include"
        }).then((response) => response.json())
            .then((res) => {
            const tbodyChildren = document.getElementsByTagName("tbody")[0].children;

            for (let i = 0; i < tbodyChildren.length; i++) {
                const childElement = tbodyChildren[i];
                childElement.childNodes[4].children[0].children[0].children[0].addEventListener('click', function(e) {
                    e.stopPropagation();
                    e.preventDefault();
                    window.open("https://learning.hzrs.hangzhou.gov.cn/#/class?courseId="+res.data.data[i].courseid+"&coursetitle="+res.data.data[i].coursename)
                }, true);
            }
        })}

    window.addEventListener('load', function() {
        if (window.location.hash.includes('#/learn')) {
            load();
        }
    });
})();