上一主题 下一主题
ScriptCat,新一代的脚本管理器脚本站,与全世界分享你的用户脚本油猴脚本开发指南教程目录
返回列表 发新帖

网页代码可否利用脚本拦截替换

[复制链接]
  • TA的每日心情

    2023-9-8 10:16
  • 签到天数: 1 天

    [LV.1]初来乍到

    2

    主题

    0

    回帖

    7

    积分

    助理工程师

    积分
    7
    发表于 2023-9-8 10:30:26 | 显示全部楼层 | 阅读模式
    悬赏2油猫币未解决

    本帖最后由 Tandent 于 2023-9-8 10:58 编辑

    最近在自己学习编写刷课的学习脚本,同查找网页代码发现课程学习是利用按钮跳转到Javascript代码来进行的。
    image.png
    但是该代码利用账号权限设置了屏蔽。
    image.png
    因为发现点击课程学习后会打开一个全屏弹窗,通过查找找到了这个弹窗代码
    `

        /* 打开一个可设置滚动条的全屏窗口 可以回调刷新窗口*/
        function _openFullWindowCenter(url, winName, scrollbars, title, lessonId, type) {
            if (typeof (classroomWin) != 'undefined') {
                classroomWin.close();
            }
            var width = window.screen.availWidth;
            var height = window.screen.availHeight;
            var xposition = 0;
            var yposition = 0;
            xposition = (window.screen.availWidth - width) / 2;
            yposition = (window.screen.availHeight - height) / 2;
            if (yposition > 30) yposition = 30;
            theproperty = "width=" + width + ","
                + "height=" + height + ","
                + "location=no,"
                + "menubar=0,"
                + "resizable=no,"
                + "status=0,"
                + "titlebar=0,"
                + "toolbar=no,"
                + "hotkeys=0,Direction=no,Resizeable=no"
                + "screenx=" + xposition + ","
                + "screeny=" + yposition + ","
                + "left=" + xposition + ","
                + "top=" + yposition;
            if (scrollbars == 'false')
                theproperty += ",scrollbars=no";
            else
                theproperty += ",scrollbars=yes";
            classroomWin = window.open(url, winName, theproperty);
            if (typeof (title) != 'undefined') {
                $.confirm({
                    'title': '请确认',
                    'message': title,
                    'buttons': {
                        '确定': {
                            'class': 'blue',
                            'action': function () {
                                if (type == 1) {
                                    $.ajax({
                                        type: "get",
                                        async: false,
                                        url: "https://www.***.***.cn:443/app/zwy/api/Api/updateLearnProgress.do?lessonId=" + lessonId,
                                        success: function (res) {
                                            if (res.success) {
                                                //alert(res.msg);
                                            } else {
                                                //alert(res.msg);
                                            }
                                        },
                                        error: function () {
    
                                        }
                                    });
                                }
    
                                window.location.reload();
                            }
                        }
                    }
                });
            }
        }
    
        function startLesson(lessonId, coursewareId, lessonkey, tclessonId, type) {
            if (type == 0 || type == 1) {
                $.ajax({
                    type: "post",
                    url: 'https://www.***.***.cn:443/app/tms/tclesson/Tclesson/learnOrder.do',
                    async: false, // 同步调用
                    dataType: 'json',
                    data: {'tclessonId': tclessonId, 'trainclassId':29101},
                    success: function (data) {
    
                        if (data["success"] == 1) {
                            alert('请先学习' + data["lessonName"] + '后再学习该门课程');
                        } else {
                            var winName = 'classroomWin';
                            var url = "https://www.***a.***.cn:443/app/lms/student/Learn/enter.do?lessonId=" + lessonId + "&coursewareId=" + coursewareId + "&lessonGkey=" + lessonkey + "&tclessonId=" + tclessonId + "&lessonOrigin=trainclass";
                            _openFullWindowCenter(url, winName, 'true', '您正在学习,请在学习结束后,点击[确认]按钮,刷新本页面', lessonId, type);
                        }
                    },
                    error: function () {
                        $.unblockUI();
                        alert('error');
                    }
                });
            } else if (type == 2) {
                $.ajax({
                    type: "get",
                    url: "https://www.***.***.cn:443/app/zwy/api/Api/takeZwyLessonUrl.do?lessonId=" + lessonId + "&trainclassId=" + trainclassId4Ajax,
                    success: function (res) {
                        if (res.success) {
                            //window.open(res.url, "_blank");
                            _openFullWindowCenter(res.url, 'classroomWin', 'true', '您正在学习,请在学习结束后,点击[确认]按钮,刷新本页面', lessonId, type);
                        } else {
                            //alert(res.msg);
                        }
                    },
                    error: function () {
                        alert('error');
                    }
                });
            }
        }
    
        function _submitexperience(o) {
            //document.forms.xiangqing.action="https://www.***.***.cn:443/app/tms/trainexperience/Trainexperience/insertexperience.do";
            //document.forms.xiangqing.submit();
            var trainexperienceId = document.forms.form1.trainexperienceId.value;
            var experience = document.forms.form1.experience.value;
            $.blockUI({message: "正在保存..."});
            $.ajax({
                type: "post",
                url: 'https://www.***.***.cn:443/app/tms/trainexperience/Trainexperience/insertexperience.do',
                async: false, // 同步调用
                dataType: 'json',
                data: {
                    'trainexperienceId': trainexperienceId,
                    'experience': experience,
                    'trainclassId':29101
                },
                success: function (data) {
                    var flag = data["success"];
                    if (flag == "true") {
                        $.unblockUI();
                        $(o).attr("disabled", true);
                    }
                },
                error: function () {
                    $.unblockUI();
                    alert('error');
                }
            });
        }
    
        function showLesson(lessonId, tclessonId) {
            document.forms.form1.lessonId.value = lessonId;
            document.forms.form1.tclessonId.value = tclessonId;
            document.forms.form1.action = "https://www.***.***.cn:443/app/lms/student/Userselectlesson/tclessonshow.do"
            document.forms.form1.target = "_content";
            document.forms.form1.submit();
            document.forms.form1.target = "";
        }
    
        function _showtrainclassuser(tclessonId) {
            window.open("https://www.***.***.cn:443/app/tms/tcuser/Tcuser/showtrainclassuser.do?trainclassId=" + tclessonId);
        }
    
        function lookOrPrint(param1, param2) {
            if(false){
                window.open("https://www.***.***.cn:443//app/cert/certificate/CertCertificate/show.do?certId=");
            }else if(false){
                window.open("https://www.***.***.cn:443//app/cert/certificate/CertCertificate/show.do?certId=");
            }else if(false){
                window.open("https://www.***.***.cn:443//app/cert/certificate/CertCertificate/show.do?certId=");
            }else{
                window.open("https://www.***.***.cn:443/app/ctf/certificate/Certifimangr/print.do?stuFlag=1&certificateId=&stuHour=" + param1 + "&flag=" + param2);
            }
    
        }
        function printcert() {
                window.open("https://www.***.***.cn:443/app/cert/award/CertAwarduser/printshow.do?awarduserId=");
        }
    
        function certPrint(exa_batch) {
            if (exa_batch == '' || exa_batch == null) {
                return;
            }
            window.open("https://www.***.***.cn:443/app/ctf/certificate/Certifimangr/cert.do?exa_batch=" + exa_batch + "&flag=1");
        }
    
        function _enterspecialclass(param) {
            var temp = true;
            var urlAction = "https://www.***.***.cn:443/portal/j_spring_security_check";
            var j_username = "1100977";
            var j_password = "123456";
            var newWin = window.open();
    
            newWin.location = "http://202.103.252.140/portal/j_spring_security_check?j_username=" + j_username + "&j_password=" + j_password + "&j_page=/portal/student/practice-list?fieldId=" + param;
    
            /**
             $.ajax({
          type: "post", //提交的类型 
          url: urlAction, //提交地址 
          dataType: "json",
          data:{j_username:j_username,j_password:j_password},
          success: function(data){},
          complete: function(event,xhr,options){
              if(temp == true){
                  //window.location.reload();
                  //window.location.;
                  newWin.location="https://www.***.***.cn:443/portal/student/practice-list?fieldId="+param;
              }
        }
      })
             */
        }
    
        function _updatePracticeTime() {
            var temp = true;
            var urlAction = "https://www.***.***.cn:443/app/tms/trainclass/Trainclass/updatePracticeTime.do?";
            $.ajax({
                type: "post", //提交的类型
                url: urlAction, //提交地址
                dataType: "json",
                data: {'trainclassId':29101},
                success: function (data) {
                },
                complete: function (event, xhr, options) {
                }
            })
        }
    
        function _updateEvaluate(e, tcId, url) {
            var trainclassId = tcId;
            var urlAction = "https://www.***.***.cn:443/app/tms/trainclass/Trainclass/updateEvaluate.do?evl=" + e + "&classid=" + trainclassId;
            $.ajax({
                type: "post", //提交的类型
                url: urlAction, //提交地址
                dataType: "json",


    `
    想问可否通过脚本对上面的代码进行拦截替换,实现在新标签页打开弹窗,以及实现多开?

  • TA的每日心情
    开心
    2023-2-28 23:59
  • 签到天数: 191 天

    [LV.7]常住居民III

    637

    主题

    5228

    回帖

    6098

    积分

    管理员

    非物质文化遗产社会摇传承人

    积分
    6098

    荣誉开发者管理员油中2周年生态建设者喜迎中秋

    发表于 2023-9-8 11:40:16 | 显示全部楼层
    油猴脚本是没法拦截函数的
    如果追寻自动化的话应该追寻CDP
    油猴的角度来说可以做xhr拦截或者自己实现xhr然后直接打开窗口

    关于多账号的问题可以考虑nodejs或者油猴自己写xhr做封包通信
    然后使用cookies-jar做cookie隔离操作
    混的人。
    ------------------------------------------
    進撃!永遠の帝国の破壊虎---李恒道

    入驻了爱发电https://afdian.net/a/lihengdao666
    个人宣言:この世界で私に胜てる人とコードはまだ生まれていません。死ぬのが怖くなければ来てください。
    回复

    使用道具 举报

  • TA的每日心情
    奋斗
    2 小时前
  • 签到天数: 11 天

    [LV.3]偶尔看看II

    5

    主题

    21

    回帖

    30

    积分

    助理工程师

    积分
    30
    发表于 2023-11-11 21:21:07 | 显示全部楼层
    绝了,我感觉好多刷课都是用的这一套jq
    回复

    使用道具 举报

    发表回复

    本版积分规则

    快速回复 返回顶部 返回列表