学习通返回旧版

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

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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('请进入课程后再点击');
        }
    };
})();