学习通返回旧版

创建超星学习通返回旧版的按钮

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         学习通返回旧版
// @namespace    http://tampermonkey.net/
// @version      1.4
// @description  创建超星学习通返回旧版的按钮
// @author       Ray&ChatGPT
// @match        https://mooc2-ans.chaoxing.com/mooc2-ans/mycourse/stu*
// @grant        none
// @license MIT

// ==/UserScript==

(function() {
    'use strict';


   var button = document.createElement('button');
button.innerHTML = '回到旧版';
button.style.position = 'absolute'; // 或者 'absolute' 如果您想要相对于某个容器定位
button.style.top = '10px'; // 距离顶部 10px
button.style.left = '50%'; // 居中
button.style.zIndex = '9999';
button.style.padding = '10px';
button.style.backgroundColor = '#008CBA';
button.style.color = 'white';
button.style.border = 'none';
button.style.borderRadius = '5px';
button.style.cursor = 'pointer';

document.body.appendChild(button);



    // 点击按钮时的处理函数
    button.onclick = function() {
        var currentUrl = window.location.href;
        var urlParams = new URLSearchParams(window.location.search);
        var courseid = urlParams.get('courseid');
        var clazzid = urlParams.get('clazzid');
        var cpi = urlParams.get('cpi');

        if (courseid && clazzid && cpi) {
            var newUrl = `https://mooc1.chaoxing.com/visit/stucoursemiddle?courseid=${courseid}&clazzid=${clazzid}&cpi=${cpi}&ismooc2=0`;
            window.location.href = newUrl;
        } else {
            alert('请进入课程后再点击');
        }
    };
})();