本帖最后由 闷骚小贱男 于 2021-6-7 20:28 编辑
就类似的吧....根据视频ID取到视频MP4地址并拼接(time和第几个视频)传值,然后setTimeout换下一个视频
// ==UserScript==
// @name 测试 脚本
// @namespace Violentmonkey Scripts
// @match *://haokan.baidu.com/*
// @match *://vd4.bdstatic.com/*
//
//
//
// @grant none
// @version 1.0
// @author -
// @description 2021/1/9 下午2:32:52
// @grant GM_xmlhttpRequest
// @grant GM_download
// ==/UserScript==
[JavaScript] 纯文本查看 复制代码
(function () {
'use strict';
var time = 0;
var sz_vid = ['9631057257739147552','4523941987622264346','15027326655618396681','8035610557487612877','5220052409357590207','5483192976575138141','16612745094804585524','8212697985514459708','4256221206703732476','7271168943953759336','8863059078166553570','5804605841205654798','14588707672798819502','11905686853846977570','4340610902573633723','11523111702311037968','9961557674945132008','2157728076464065106','1068506781903443284','12027298560095561504']
var id = 1;
var interval = setInterval(function () {
doIt();
clearInterval(interval);
}, 1000);
function doIt() {
if(window.location.href.indexOf("vd4.bdstatic.com")>0){
var URL = window.location.search;
URL = URL.split('?')[1]; //获取参数列表
var params = URL.split('&');
console.error(params);
for (var i = 0; i < params.length; i++) {
var ps = params[i].split('=');
console.error(ps[0],ps[1]);
if(ps[0] = 'id'){
id = ps[1];
}
if(ps[0] = 'time'){
time = ps[1];
setTimeout(取链接(id), time )//time处理下
}
}
}else{
取链接(id)
}
}
function 取链接(a) {
a = sz_vid [id];
console.log("请求成功," + a);
GM_xmlhttpRequest({
method: "POST",
url: "https://haokan.baidu.com/v?vid=" + a,
headers: {
"Content-Type": "application/x-www-form-urlencoded;charset=utf-8"
},
data: "content=erwer",
onload: function (response) {
console.log("请求成功");
var str1 = response.responseText
var str = getStr(str1,'u5149','=","videoBps')
str = str.substring(9);
str = str.replace(/\\/g,"")
console.log('播放地址:' + str);//视频mp4
//,"time_length":"06:30",
str = getStr(str1,'time_length','","dura')
str = str.substring(3);
console.log('视频时间:' + str);//视频mp4
if(str.indexOf(".mp4?") != -1 ){
location.href = str + '&time=' + str + '&id=' + id+1; //传视频时间和视频id进来 然后跳转
}
},
onerror: function (response) {
console.log("请求失败");
}
});
}
function getStr(str, start, end) {
let res = str.match(new RegExp(`${start}(.*?)${end}`))
return res ? res[1] : null
}
})();
|