Greasy Fork is available in English.
爱奇艺海外版字幕自动下载,自动下载字幕
当前为
// ==UserScript==
// @name 爱奇艺海外版字幕自动下载
// @namespace http://tampermonkey.net/
// @version 0.3
// @description 爱奇艺海外版字幕自动下载,自动下载字幕
// @author XGCM
// @match https://www.iq.com/play/*
// @icon https://www.iqiyipic.com/common/images/logo.ico
// @grant GM_addElement
// @grant GM_openInTab
// @grant GM_download
// @grant window.close
// ==/UserScript==
function download() {
var tvid=playerObject._player.package.engine.adproxy.engine.movieinfo.tvid;
var oData=playerObject._player.package.engine.adproxy.engine.episode.EpisodeStore[tvid].movieInfo.originalData;
var prefix=oData.data.dstl;
var subUrl=oData.data.program.stl[0].webvtt;
var title=(document.title.indexOf("-")!=-1?document.title.substring(0,document.title.indexOf("-")):document.title.replace(/\s/,""));
GM_download(prefix+subUrl, title);
return subUrl;
}
(function() {
'use strict';
window.addEventListener('load', function() {
var urlSearchParams = new URLSearchParams(window.location.search);
var params = Object.fromEntries(urlSearchParams.entries());
var button = GM_addElement(document.getElementsByClassName('episodes-filter-wrap')[0], 'button', {
id: 'download-all-subtitles',
});
button.innerHTML = '下载字幕!';
button.onclick = function () {
GM_openInTab(document.getElementsByClassName('intl-episodes-list')[0].getElementsByTagName('li')[0].getElementsByTagName('a')[0].href+'&download_all=true&download_subtitles=true');
}
if (params.download_all) {
var lis = document.getElementsByClassName('intl-episodes-list')[0].getElementsByTagName('li')
var i = 0;
var ref = setInterval(function(){
GM_openInTab(lis[i].getElementsByTagName('a')[0].href+'&download_subtitles=true');
i++;
if (i >= lis.length) {
clearInterval(ref);
}
}, 1000);
} else if (params.download_subtitles) {
var selected = document.getElementsByClassName('intl-episodes-list')[0].getElementsByClassName('selected')[0];
var subUrl = download();
if (!subUrl) alert('字幕下载终止');
window.close();
}
}, false);
})();