帮朋友刷课,网页版视频课,不能拖动进度条,要刷 90 个学时,太尼玛变态了,所以想到刷课。
以前类似的需求我都是通过抓包工具 BurpSuite 改观看时长变量,然后放包实现的,也屡试不爽。但这次发现并不好使。。放包之后去课程页面看了,没有任何效果。看了源码也并没有研究清楚是哪里限制了,我都是按照 POST 数据的合法性放包的。
用扩展加速视频,发现也不好使,应该也是 js 禁止了视频加速
看了下网页源码发现是 js 控制禁用了许多功能,看来只有自己写 js 脚本 override 原有脚本了,可惜我 js 并不熟。前端大佬们帮忙看下,提供个思路。谢谢啦,我把源码贴出来,关键的地方应该也就是那几个。辛苦辛苦师傅们
$(function(){
var time = 0;
var is_hls = "1";
var storage = window.localStorage;
var learntime = 0,player_seek_time = 0,setLearntime = null;
var is_drag = parseInt("0"); // 控制拖动进度条 [ 1:可拖动,0:不可拖动]
var content = "成都 XX 科技有限公司所有权 ";
var learn_record = parseInt("40");
if(is_hls == 1){
var myPlayer = videojs('my-video',{
loop:false,
controlBar: {
LiveDisplay: false,
playbackRateMenuButton:{
// playbackRates:[0.5,1.0,1.5,2.0,2.5]
}
}
},function(){
$("#marquee_content").text(content);
});
//添加视频准备完成后的回调函数
myPlayer.on('loadedmetadata', function() {
//自动播放
if(learn_record){
myPlayer.currentTime(learn_record); //续播
myPlayer.play();
storage.setItem("play_time_155_1722_5091", learn_record);
}
// 初始化完成未播放时拖动进度
if(!is_drag){
var play_time = parseInt(storage.getItem("play_time_155_1722_5091"));
currentTime = parseInt(myPlayer.currentTime());
if( currentTime-play_time>1 ){
myPlayer.currentTime(play_time);
}
}
});
//监听进度条时间
time = myPlayer.duration();
myPlayer.on('timeupdate',videojstimeupdate);
}else{
var myPlayer = document.getElementById('my-video');
//添加视频准备完成后的回调函数
myPlayer.addEventListener('loadedmetadata', function() {
// 自动播放
$("#marquee_content").text(content); // 跑马灯
if(learn_record){
myPlayer.currentTime=learn_record; // 续播
myPlayer.play();
storage.setItem("play_time_155_1722_5091", learn_record);
}
// 初始化完成未播放时拖动进度
/* if(!is_drag){
var play_time = parseInt(storage.getItem("play_time_155_1722_5091"));
currentTime = parseInt(myPlayer.currentTime);
if( currentTime-play_time>1 ){
myPlayer.currentTime = play_time ;
}
} */
});
//监听进度条时间
time = myPlayer.duration;
myPlayer.addEventListener('timeupdate',videotimeupdate);
}
//监听播放时间
function setTime(){
learntime = learntime+1;
}
//播放
function videojsplay() {
if(learn_record){
myPlayer.currentTime(learn_record); //续播
myPlayer.play();
storage.setItem("play_time_155_1722_5091", learn_record);
}else{
setLearntime = setInterval(setTime, 1000);
}
}
if(is_hls == 1){
myPlayer.on('play', videojsplay);
myPlayer.on('pause',videojspause);
myPlayer.on('ended', videojsended);
//暂停
function videojspause() {
clearInterval(setLearntime);
var times = parseInt(myPlayer.currentTime());
var total_time = parseInt(myPlayer.duration());
if(times > 2){
addLearnLog(times , total_time,1);
}
}
//结束
function videojsended() {
clearInterval(setLearntime);
var times = parseInt(myPlayer.currentTime());
var total_time = parseInt(myPlayer.duration());
if(times > 2){
addLearnLog(times , total_time,1);
}
if( total_time != 0 && times >= total_time ){
// 获取下一解锁课时并跳转
$.ajax({
type: "POST",
url:"http://xbzj.masterol.cn/index.php?app=course&mod=Video&act=getNextSection",
data:{vid:"155",sid:"1722"},
dataType:"json",
success:function(data){
if(data){
var height = $('#vplayer').height();
var width = $('#vplayer').width();
var index = ui.open({
type:3,
icon:2,
shade: [0.7, '#fff'], //0.1 透明度的白色背景
offset: [height / 2+'px', width / 2+'px'],
});
setTimeout(function(){
window.location.href = data;
}, 800);
}
}
});
}
}
}else{
myPlayer.addEventListener('play',videojsplay);
myPlayer.addEventListener('pause',videojspause);
myPlayer.addEventListener('ended', videojsended);
//暂停
function videojspause() {
clearInterval(setLearntime);
var times = parseInt(myPlayer.currentTime);
var total_time = parseInt(myPlayer.duration);
if(times > 2){
addLearnLog(times , total_time,1);
}
}
//结束
function videojsended() {
clearInterval(setLearntime);
var times = parseInt(myPlayer.currentTime);
var total_time = parseInt(myPlayer.duration);
if(times > 2){
addLearnLog(times , total_time,1);
}
if( total_time != 0 && times >= total_time ){
// 获取下一解锁课时并跳转
$.ajax({
type: "POST",
url:"http://xbzj.masterol.cn/index.php?app=course&mod=Video&act=getNextSection",
data:{vid:"155",sid:"1722"},
dataType:"json",
success:function(data){
if(data){
var height = $('#vplayer').height();
var width = $('#vplayer').width();
var index = ui.open({
type:3,
icon:2,
shade: [0.7, '#fff'], //0.1 透明度的白色背景
offset: [height / 2+'px', width / 2+'px'],
});
setTimeout(function(){
window.location.href = data;
}, 800);
}
}
});
}
}
}
if(!is_drag){
var play_time = parseInt(storage.getItem("play_time_155_1722_5091"));
if(curr_times-times>1){
console.log('1307'+curr_times+'-'+play_time+'--'+times);
myPlayer.currentTime(play_time);
storage.setItem("play_time_155_1722_5091", play_time);
}
}
if( total_time != 0 && curr_times >= total_time ){
// 获取下一解锁课时并跳转
$.ajax({
type: "POST",
url:"http://xbzj.masterol.cn/index.php?app=course&mod=Video&act=getNextSection",
data:{vid:"155",sid:"1722"},
dataType:"json",
success:function(data){
if(data){
var height = $('#vplayer').height();
var width = $('#vplayer').width();
var index = ui.open({
type:3,
icon:2,
shade: [0.7, '#fff'], //0.1 透明度的白色背景
offset: [height / 2+'px', width / 2+'px'],
});
setTimeout(function(){
window.location.href = data;
}, 800);
}
}
});
}
if( times != parseInt(myPlayer.currentTime()) ){
times = parseInt(myPlayer.currentTime());
if(times > 0 && times % 4 == 0 ){
addLearnLog(times , total_time , 0); //0 表示不及时更新学习记录,即 4 秒一次
}
storage.setItem( 'learn_curr_time', times);
}
if(is_free == 0 && free == 0){
if (times > test_time){
myPlayer.pause();
$("#vplayer").html('');
$(".vedioPlay-msg").css("display","block");
}
}
}
//video 时间更新
function videotimeupdate() {
var test_time = 5;
var is_free = 1;//课程是否免费
var free = 0;//课时是否免费
var total_time = parseInt(myPlayer.duration);
var times = storage.getItem('learn_curr_time');
var curr_times = parseInt(myPlayer.currentTime);
// 拖动进度
if(!is_drag){
var play_time = parseInt(storage.getItem("play_time_155_1722_5091"));
if(curr_times-times>1){
console.log('1307'+curr_times+'-'+play_time+'--'+times);
myPlayer.currentTime = play_time;
storage.setItem("play_time_155_1722_5091", play_time);
}
}
if( total_time != 0 && curr_times >= total_time ){
// 获取下一解锁课时并跳转
$.ajax({
type: "POST",
url:"http://xbzj.masterol.cn/index.php?app=course&mod=Video&act=getNextSection",
data:{vid:"155",sid:"1722"},
dataType:"json",
success:function(data){
if(data){
var height = $('#vplayer').height();
var width = $('#vplayer').width();
var index = ui.open({
type:3,
icon:2,
shade: [0.7, '#fff'], //0.1 透明度的白色背景
offset: [height / 2+'px', width / 2+'px'],
});
setTimeout(function(){
window.location.href = data;
}, 800);
}
}
});
}
if( times != parseInt(myPlayer.currentTime) ){
times = parseInt(myPlayer.currentTime);
if(times > 0 && times % 4 == 0 ){
addLearnLog(times , total_time , 0); //0 表示不及时更新学习记录,即 4 秒一次
}
storage.setItem( 'learn_curr_time', times);
}
if(is_free == 0 && free == 0){
if (times > test_time){
myPlayer.pause();
$("#vplayer").html('');
$(".vedioPlay-msg").css("display","block");
}
}
}
//添加观看记录
function addLearnLog(timespan , total_time , is_true){
var t = parseInt(timespan);
var total_time = parseInt(total_time);
var video_type = "5";
if((t && (t % 4 == 0)) || is_true == 1){
$.ajax({
type: "POST",
url:"http://xbzj.masterol.cn/index.php?app=course&mod=Video&act=updateLearn",
data:{time:t,player_seek_time:learntime,vid:"155",sid:"1722",totaltime:total_time,is_true:is_true,type:video_type},
dataType:"json",
success:function(data){
if(data.status=='0'){
console.log('修正--'+t+'-'+data.time);
if(is_hls == 1){
myPlayer.currentTime(data.time);
}else{
myPlayer.currentTime = data.time;
}
storage.setItem("play_time_155_1722_5091", data.time);
ui.error('禁止多次拖动快进!');
return;
}else if(data.status=='-1'){
ui.error('您的登录已过期,请重新登录');
var callbacklogin = "location.href ='/login.html'";
setTimeout(callbacklogin,3000);
return false;
}else{
}
}
});
}
}
});
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.