m3u8ts视频流下载插件(神器)油猴插件添加脚本即可
// ==UserScript==
// @name        m3u8视频下载
// @namespace    tampermonkey/
// @version      0.1
// @include      *
// @description  try to take over the world!
// @author      酷盖
// @match        vip.qidianla/
// @grant        none
// ==/UserScript==
(function () {
let _sourceBufferList = []
let $btnDownload = ateElement('div')
let $downloadNum = ateElement('div')
let $tenRate = ateElement('div') // ⼗倍速播放
// ⼗倍速播放
function _tenRatePlay () {
let $domList = ElementsByTagName('video')
for (let i = 0, length = $domList.length; i < length; i++) {
const $dom = $domList[i]
$dom.playbackRate = 10
}
}
// 下载资源
function _download () {
_sourceBufferList.forEach((target) => {
const mime = target.mime.split(';')[0]
const type = mime.split('/')[1]
const fileBlob = new Blob(target.bufferList, { type: mime }) // 创建⼀个Blob对象,并设置⽂件的 MIME 类型
const a = ateElement('a')
a.download = `${document.title}.${type}`
a.href = ateObjectURL(fileBlob)
a.style.display = 'none'
document.body.appendChild(a)
a.click()
})
}
// 监听资源全部录取成功
let _endOfStream = window.dOfStream
tampermonkeywindow.dOfStream = function () {
alert('资源全部捕获成功,即将下载!')
_download()
_endOfStream.call(this)
}
// 录取资源
let _addSourceBuffer = window.MediaSource.prototype.addSourceBuffer
window.MediaSource.prototype.addSourceBuffer = function (mime) {
console.log(mime)
let sourceBuffer = _addSourceBuffer.call(this, mime)
let _append = sourceBuffer.appendBuffer
let bufferList = []
_sourceBufferList.push({
mime,
bufferList,
bufferList,
})
sourceBuffer.appendBuffer = function (buffer) {
$downloadNum.innerHTML = `已捕获 ${_sourceBufferList[0].bufferList.length} 个⽚段`
bufferList.push(buffer)
_append.call(this, buffer)
}
return sourceBuffer
}
// 添加操作的 dom
function _appendDom () {
const baseStyle = `
position: fixed;
top: 50px;
right: 50px;
height: 40px;
padding: 0 20px;
z-index: 9999;
color: white;
cursor: pointer;
font-size: 16px;
font-weight: bold;
line-height: 40px;
text-align: center;
border-radius: 4px;
background-color: #3498db;
box-shadow: 0 3px 6px 0 rgba(0, 0, 0, 0.3);
`
$tenRate.innerHTML = '⼗倍速捕获'
$downloadNum.innerHTML = '已捕获 0 个⽚段'
$btnDownload.innerHTML = '下载已捕获⽚段'
$tenRate.style = baseStyle + `top: 150px;`
$btnDownload.style = baseStyle + `top: 100px;`
$downloadNum.style = baseStyle
$btnDownload.addEventListener('click', _download)
$tenRate.addEventListener('click', _tenRatePlay)
_appendDom()
})()

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。