// ==UserScript== // @name 爱奇艺海外版字幕自动下载 // @namespace http://tampermonkey.net/ // @version 0.1 // @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 // @downloadURL none // ==/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 = GM_openInTab(document.getElementsByClassName('intl-episodes-list')[0].getElementsByTagName('li')[0].getElementsByTagName('a')[0].href+'&download_subtitles=true'); if (params.download_subtitles) { var selected = document.getElementsByClassName('intl-episodes-list')[0].getElementsByClassName('selected')[0]; var subUrl = download(); if (subUrl) GM_openInTab(selected.nextSibling.getElementsByTagName('a')[0].href+'&download_subtitles=true'); else alert('字幕下载终止'); } }, false); })();