Greasy Fork is available in English.
下载优酷视频
当前为
// ==UserScript==
// @name 优酷下载
// @namespace http://tampermonkey.net/
// @version 0.1.3
// @description 下载优酷视频
// @author silob59998
// @license MIT License
// @run-at document-start
// @grant GM_download
// @include *://*youku.com/*
// @include *://v.youku.com/v_show/*
// @require http://greasyfork.icu/scripts/440006-mono/code/mono.js?version=1021983
// ==/UserScript==
(function () {
var mono = window['mono-descargar'];
var $ = mono.jQuery;
var md5 = mono.md5;
var filename = mono.filename;
var onRequest = mono.onRequest;
var errCode = mono.FAIL_TO_DEFAULT;
var idKey = 'mono-dsg-id';
var metaCache = {}
onRequest(({url, resp, _body, method}) => {
if (!resp || !(url.includes('valipl.cp31.ott.cibntv.net/') && resp.indexOf('m3u8') !== -1)) return;
console.log('url, resp', url, resp)
metaCache.m3u8Data = resp;
metaCache.url = url;
});
var getItemByMeta = (meta, selector='', selClass='') => {
var id = `yk-${md5(meta.m3u8Data)}`
if ($(`[${idKey}=${id}]`).length > 0) return null;
var $el = null;
if (selector) $el = $(selector)
if ($el.length > 0 && selClass) {
var ps = $el.parentsUntil(selClass);
if (ps.length > 0) $el = $(ps[ps.length - 1])
}
if ($el.length <= 0) return null;
var container = $el[0];
return { id, url: meta.url, container, meta: meta }
}
var cc = () => {
var items = [];
var selector = `.module-playbox`;
var item = getItemByMeta(metaCache, selector, '.playbox')
if (!item) return items
if (item) items.push(item);
return items
}
var parser = async function () {
var url = window.location.href;
if (url.indexOf('v.youku.com/v_show/') !== -1) {
return await cc();
} else {
throw errCode;
}
}
if (mono?.init) mono.init({ parser });
})()