Greasy Fork

Greasy Fork is available in English.

华南师范大学砺儒云课堂辅助工具

自动登录砺儒云课堂,左侧边栏可自定义跳转课堂。

目前为 2024-04-18 提交的版本,查看 最新版本

// ==UserScript==
// @name         华南师范大学砺儒云课堂辅助工具
// @namespace    http://tampermonkey.net/
// @version      0.9
// @author       Yakraii, Luo
// @description  自动登录砺儒云课堂,左侧边栏可自定义跳转课堂。
// @license      GPL-3.0
// @match        https://moodle.scnu.edu.cn/
// @match        https://sso.scnu.edu.cn/AccountService/user/login.html
// @match        https://moodle.scnu.edu.cn/login/index.php
// @match        https://sso.scnu.edu.cn/AccountService/openapi/*
// @match        https://jwxt.scnu.edu.cn/xtgl/login_slogin.html
// @match        https://jwxt.scnu.edu.cn/xtgl/index_initMenu.html?jsdm=*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    //填入账密:
    var accountInput = "账号";
    var passwordInput = "密码";
    // 按钮信息
        var buttonsInfo = [
            { text: "计算机组成", url: "https://moodle.scnu.edu.cn/course/view.php?id=12357" },
            { text: "Android", url: "https://moodle.scnu.edu.cn/course/view.php?id=15560" },
            { text: "Java框架", url: "https://moodle.scnu.edu.cn/course/view.php?id=15409" },
            { text: "VR", url: "https://moodle.scnu.edu.cn/course/view.php?id=12776" },
            { text: "数学之美", url: "https://moodle.scnu.edu.cn/course/view.php?id=15530" },
            { text: "人机交互", url: "https://moodle.scnu.edu.cn/course/view.php?id=14137" },
            { text: "数据库", url: "https://moodle.scnu.edu.cn/course/view.php?id=15416" },
            { text: "马克思", url: "https://moodle.scnu.edu.cn/course/view.php?id=12416" },
            { text: "软件需求", url: "https://moodle.scnu.edu.cn/course/view.php?id=11796" }
        ];

    if(window.location.href == "https://moodle.scnu.edu.cn/"){
        var div = document.createElement("div"); //创建一个标签
        div.style.opacity = 0.95;
        div.style.backgroundColor = '#f0f0f0';
        div.style.borderRadius = '10px';
        div.style.boxShadow = '0 2px 4px rgba(0, 0, 0, 0.1)';
        div.style.position = 'absolute';
        div.style.top = '7%';
        div.style.paddingTop = '5px'; // 设置 div 顶部内边距
        div.className = "box"; //给创建的 div 设置 class;
        document.body.appendChild(div); //向刚获取的标签中添加创建的标签

      //添加课程名称、网址到buttonsInfo中
		var child = document.createElement("button");
        for (var i = 0; i < buttonsInfo.length; i++) {
            var buttonInfo = buttonsInfo[i];
            var button = document.createElement("button");
            button.innerHTML = buttonInfo.text;
            button.className = "button";
            (function(info) {
                button.onclick = function() {
                    window.location.href = info.url;
                };
            })(buttonInfo);
            div.appendChild(button);
        }


// 添加按钮样式
        var style = document.createElement("style");
        style.innerHTML = `
    .button {
        width: 130px;
        height: 30px;
        background-color: #4CAF50;
        border: none;
        color: white;
        text-align: left;
        text-decoration: none;
        display: inline-block;
        font-size: 16px;
        border-radius: 5px;
        cursor: pointer;
        transition-duration: 0.4s;
    }

    .button:hover {
        background-color: #45a049;
    }
`;
        document.head.appendChild(style);


        // 设置 div 的大小
        div.style.width =  '140px';
        div.style.height = (buttonsInfo.length*40)+5 + 'px';

        //未登录砺儒云则点击登录跳转
        if (document.querySelector(".forgotpass") === null) {
            return;
            }
        else{
            document.querySelector("#page-header > div > div > div.span6.login-header > div > form > div.forgotpass > a").click();
        }

    }

    if(window.location.href == "https://moodle.scnu.edu.cn/login/index.php"){
        setTimeout(function() {
          document.querySelector("#ssobtn").click();
        }, 300);
     }
    //登录界面填账号密码
    if(window.location.href == "https://sso.scnu.edu.cn/AccountService/user/login.html"){
       document.getElementById("account").value = accountInput;
       document.getElementById("password").value = passwordInput;
       var loginButton = document.getElementById('btn-login').click();
       //调用网页函数登录.
       //unsafeWindow.loginAction();
    }

    //通配符登录
    var urlPattern = /^https:\/\/sso\.scnu\.edu\.cn\/AccountService\/openapi\/.*/;
    if(urlPattern.test(window.location.href)){
       var linkElement = document.querySelector("#wrapper > div > div > div > div > div.card-footer > span.float-right.login-check-comfirm > a").click();
    }


    //教学管理信息平台跳转统一身份
    if(window.location.href == "https://jwxt.scnu.edu.cn/xtgl/login_slogin.html"){
        var RegistButton = document.querySelector("#tysfyzdl").click();
    }

    //教学管理信息平台
    if(window.location.href.includes("https://jwxt.scnu.edu.cn/xtgl/index_initMenu.html?jsdm=")){
       //等待5s点击
        /*setTimeout(function() {
          var element = document.querySelector("#btn_yd");
          element.click();
        }, 6500);*/
       //直接跳转教学管理信息平台
        window.location.href = "https://jwxt.scnu.edu.cn/xtgl/index_initMenu.html"
    }
})();