MENU

自动播放传智播客课程视频

June 22, 2020 • Read: 28902 • 默认分类

这学期还弄了个 1+web 的什么考核,天天让看视频做那个作业,打游戏的时候还要盯着时长,回来切视频
太麻烦了,干脆写了个脚本自动帮我切换,如果有习题就会播放语音提醒
(一点小提示,可以配合 tampermonkey 的 H5 播放器控制来实现 16 倍速播放,畅享极致丝滑,几秒一个视频,我也是听我朋友说的传智不计观看视频时长,如果计视频观看时长给分数的话就 GG 了,酌情使用)

使用方法:
在传智播客视频播放页按 F12, 将下面的代码粘贴到控制台里面,回车即可运行
(本项目已在 GitHub 开源,如果对你有用的话,顺路给个 starrrrrr 吧!)

自动播放传智播客视频Read More

Latest commit to the master branch on 6-27-2020
Download as zip

  • console.log("欢迎使用传智自动播放插件, 作者博客:https://www.nothamor.cn");
  • setTimeout(function() {
  • let url = window.location.href;
  • if(url.includes("http://stu.ityxb.com/lookPaper/busywork/")) {
  • auto_search();
  • console.log("检测到为测试页面, 开始自动查询题目");
  • } else if(url.includes("http://stu.ityxb.com/preview/detail/")) {
  • auto_play();
  • console.log("检测到为视频播放页面, 开始自动播放视频");
  • }
  • }, 5000);
  • function auto_play() {
  • const CLASS_LIST = document.getElementsByClassName("point-progress-box");
  • const CLASS_NAME = document.getElementsByClassName("point-text ellipsis");
  • let question_text = document.getElementsByTagName("pre")[0];
  • let player = document.getElementsByTagName("video")[0].id;
  • let question_text_value;
  • document.getElementById(player).click();
  • let counter = 0;
  • const TIMER = setInterval(function () {
  • let percent = CLASS_LIST[counter].innerHTML.replace(/\ +/g, "").replace(/[\r\n]/g, "");
  • let title_name = CLASS_NAME[counter].innerHTML.replace(/\ +/g, "").replace(/[\r\n]/g, "");
  • if (percent.includes("100%") && counter == (CLASS_LIST.length - 1)) {
  • clearInterval(TIMER);
  • alert("当前页所有视频均已播放完成");
  • } else if (percent.includes("100%")) {
  • CLASS_LIST[counter + 1].click();
  • player = document.getElementsByTagName("video")[0].id;
  • document.getElementById(player).click();
  • counter++;
  • }
  • if (title_name.includes("习题")) {
  • question_text = document.getElementsByTagName("pre")[0];
  • question_text_value = question_text.innerHTML;
  • console.log(" ");
  • GM_xmlhttpRequest({
  • method: 'GET',
  • url: 'http://jb.s759n.cn/chati.php?w=' + encodeURIComponent(QUESTION[counter].innerHTML),
  • headers: {
  • 'Content-type': 'application/x-www-form-urlencoded',
  • },
  • data: 'q=' + encodeURIComponent(QUESTION[counter].innerHTML),
  • onload: function (response) {
  • if (response.status == 200) {
  • let obj = $.parseJSON(response.responseText.replace(/^操作数据失败!/, '')) || {};
  • obj.answer = obj.data;
  • console.log("题目:" + QUESTION[counter].innerHTML + "的答案为:" + obj.answer);
  • if (obj.code) {
  • } else {
  • console.log('服务器繁忙,正在重试...');
  • }
  • } else if (response.status == 403) {
  • console.log('请求过于频繁,建议稍后再试');
  • } else {
  • console.log('服务器异常,正在重试...');
  • }
  • }
  • });
  • }
  • }, 1000);
  • }
  • function auto_search() {
  • const QUESTION = document.getElementsByTagName("pre");
  • let counter = 0;
  • const SEARCH = setInterval(function() {
  • GM_xmlhttpRequest({
  • method: 'GET',
  • url: 'http://jb.s759n.cn/chati.php?w=' + encodeURIComponent(QUESTION[counter].innerHTML),
  • headers: {
  • 'Content-type': 'application/x-www-form-urlencoded',
  • },
  • onload: function (response) {
  • if (response.status == 200) {
  • let obj = $.parseJSON(response.responseText.replace(/^操作数据失败!/, '')) || {};
  • console.log("第" + counter + "题" + "的答案为:" + obj.data);
  • if (obj.code) {
  • } else {
  • console.log('服务器繁忙,正在重试...');
  • }
  • } else if (response.status == 403) {
  • console.log('请求过于频繁,建议稍后再试');
  • } else {
  • console.log('服务器异常,正在重试...');
  • }
  • }
  • });
  • counter++;
  • if(counter == (QUESTION.length)) {
  • clearInterval(SEARCH);
  • console.log("题目搜索完成");
  • }
  • }, 1000);
  • }

当然还有另外一个版本,这个依赖于浏览器插件 tampermonkey, 不用每次都手动去输入脚本内容
可以手动添加,也可以直接在 greasy fork 上下载本脚本
greasy fork 下载链接:https://greasyfork.org/zh-CN/scripts/405920- 传智自动播放视频

  • // ==UserScript==
  • // @name 传智自动播放视频
  • // @namespace http://tampermonkey.net/
  • // @version 0.3
  • // @description 自动播放传智播客课程视频, 开发者博客:http://www.nothamor.cn
  • // @author nothamor
  • // @match *.ityxb.com/*
  • // @grant GM_xmlhttpRequest
  • // ==/UserScript==
  • (function() {
  • 'use strict';
  • console.log("欢迎使用传智自动播放插件, 作者博客:https://www.nothamor.cn");
  • setTimeout(function() {
  • let url = window.location.href;
  • if(url.includes("http://stu.ityxb.com/lookPaper/busywork/")) {
  • auto_search();
  • console.log("检测到为测试页面, 开始自动查询题目");
  • } else if(url.includes("http://stu.ityxb.com/preview/detail/")) {
  • auto_play();
  • console.log("检测到为视频播放页面, 开始自动播放视频");
  • }
  • }, 5000);
  • function auto_play() {
  • const CLASS_LIST = document.getElementsByClassName("point-progress-box");
  • const CLASS_NAME = document.getElementsByClassName("point-text ellipsis");
  • let question_text = document.getElementsByTagName("pre")[0];
  • let player = document.getElementsByTagName("video")[0].id;
  • let question_text_value;
  • document.getElementById(player).click();
  • let counter = 0;
  • const TIMER = setInterval(function () {
  • let percent = CLASS_LIST[counter].innerHTML.replace(/\ +/g, "").replace(/[\r\n]/g, "");
  • let title_name = CLASS_NAME[counter].innerHTML.replace(/\ +/g, "").replace(/[\r\n]/g, "");
  • if (percent.includes("100%") && counter == (CLASS_LIST.length - 1)) {
  • clearInterval(TIMER);
  • alert("当前页所有视频均已播放完成");
  • } else if (percent.includes("100%")) {
  • CLASS_LIST[counter + 1].click();
  • player = document.getElementsByTagName("video")[0].id;
  • document.getElementById(player).click();
  • counter++;
  • }
  • if (title_name.includes("习题")) {
  • question_text = document.getElementsByTagName("pre")[0];
  • question_text_value = question_text.innerHTML;
  • console.log(" ");
  • GM_xmlhttpRequest({
  • method: 'GET',
  • url: 'http://jb.s759n.cn/chati.php?w=' + encodeURIComponent(QUESTION[counter].innerHTML),
  • headers: {
  • 'Content-type': 'application/x-www-form-urlencoded',
  • },
  • data: 'q=' + encodeURIComponent(QUESTION[counter].innerHTML),
  • onload: function (response) {
  • if (response.status == 200) {
  • let obj = $.parseJSON(response.responseText.replace(/^操作数据失败!/, '')) || {};
  • obj.answer = obj.data;
  • console.log("题目:" + QUESTION[counter].innerHTML + "的答案为:" + obj.answer);
  • if (obj.code) {
  • } else {
  • console.log('服务器繁忙,正在重试...');
  • }
  • } else if (response.status == 403) {
  • console.log('请求过于频繁,建议稍后再试');
  • } else {
  • console.log('服务器异常,正在重试...');
  • }
  • }
  • });
  • }
  • }, 1000);
  • }
  • function auto_search() {
  • const QUESTION = document.getElementsByTagName("pre");
  • let counter = 0;
  • const SEARCH = setInterval(function() {
  • GM_xmlhttpRequest({
  • method: 'GET',
  • url: 'http://jb.s759n.cn/chati.php?w=' + encodeURIComponent(QUESTION[counter].innerHTML),
  • headers: {
  • 'Content-type': 'application/x-www-form-urlencoded',
  • },
  • onload: function (response) {
  • if (response.status == 200) {
  • let obj = $.parseJSON(response.responseText.replace(/^操作数据失败!/, '')) || {};
  • console.log("第" + counter + "题" + "的答案为:" + obj.data);
  • if (obj.code) {
  • } else {
  • console.log('服务器繁忙,正在重试...');
  • }
  • } else if (response.status == 403) {
  • console.log('请求过于频繁,建议稍后再试');
  • } else {
  • console.log('服务器异常,正在重试...');
  • }
  • }
  • });
  • counter++;
  • if(counter == (QUESTION.length)) {
  • clearInterval(SEARCH);
  • console.log("题目搜索完成");
  • }
  • }, 1000);
  • }
  • })();
Last Modified: September 17, 2023
Leave a Comment

57 Comments
  1. Rudy Rudy

    dgdvdsf

  2. 风过无期 风过无期

    脚本识别不出来是怎么回事呢,

    1. @风过无期 sorry for late reply, 请问是什么页面

  3. 艮卦- 艮卦-

    请问在油猴上你上传的插件题库貌似不是很全,挺多题搜不到的,一直提示
    李恒雅提醒大家:考试千万场,诚信第一场。一朝弄舞弊,十年挂南墙(未搜索到答案)
    大佬考虑更新一下题库接口吗?

    1. @艮卦 - 是的,这个题库的确并不是很齐全,我明天看看有没有题库更全的接口,进行更换

    2. 艮卦- 艮卦-

      @欧尼酱那就麻烦了,谢谢了

  4. 谢谢分享,日常打卡~滴滴~@(汗)

  5. okc okc

    好像不能用了
    GET http://s19.cnzz.com/z_stat.php?id=1273545537&show=pic1 net::ERR_BLOCKED_BY_CLIENT
    net::ERR_BLOCKED_BY_CLIENT
    出现这个错误

    1. @okc 这个错误貌似是 tampermonkey 弹出窗口的时候你没点击允许导致的吧

    2. okc okc

      @欧尼酱也没有弹出窗口

    3. okc okc

      @欧尼酱关闭拦截了,但也没看到搜题提示

    4. okc okc

      @欧尼酱 userscript.html?id=9de44702-145d-4139-9445-213763cf096f:88 Uncaught TypeError: Cannot read property 'innerHTML' of undefined

      at Window.eval (userscript.html?id=9de44702-145d-4139-9445-213763cf096f:88) at <anonymous>:2:494 at c.<computed> (eval at exec_fn
    5. okc okc

      @欧尼酱 Uncaught TypeError: Cannot read property 'innerHTML' of undefined

    6. @okc 查题的时候出现的错误么

    7. okc okc

      @欧尼酱是的,出现这个代码错误就执行不下去了

    8. anonymous anonymous

      @okc 同该错误

    9. zharly zharly

      @okc 我也出现这个错误了