您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Video downloader for theworldwatch.com
当前为
// ==UserScript== // @name theworldwatch downloader // @namespace Violentmonkey Scripts // @match https://theworldwatch.com/* // @grant GM.xmlHttpRequest // @grant GM_addElement // @grant GM_addStyle // @grant GM_download // @grant GM_openInTab // @grant GM_log // @version 2.2 // @author https://gf.qytechs.cn/en/users/1409235-paywalldespiser // @description Video downloader for theworldwatch.com // @license MIT // @require https://update.gf.qytechs.cn/scripts/523012/1516081/WaitForKeyElement.js // @require https://cdn.jsdelivr.net/npm/[email protected]/dist/FileSaver.min.js // @require https://cdn.jsdelivr.net/npm/@trim21/[email protected]/dist/gm_fetch.min.js // @connect theworldwatch.com // ==/UserScript== /** * Gets filename from theworldwatch.com video URL * * @param {string} url * @returns {string} */ function getFilenameFromURL(url) { const title = document.title; for (const [, videoURL] of url.matchAll(/\/get_file\/.*\/(.*?)\.mp4/gm)) { if (videoURL) { return `${title} [${videoURL}].mp4`; } } return `${title}.mp4`; } (function () { GM_addStyle(` .loader { border: 0.25em solid #f3f3f3; border-top: 0.25em solid rgba(0, 0, 0, 0); border-radius: 50%; width: 1em; height: 1em; animation: spin 2s linear infinite; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } .kt-player .fp-controls .fp-download { display: inline-flex; float: right; height: 100%; justify-content: center; align-items: center; margin: 2px 4px 4px 10px; } `); waitForKeyElement('.player video').then((video) => { const fullScreenButton = video.nextElementSibling.querySelector( '.fp-controls > .fp-screen' ); const downloadButtonContainer = GM_addElement('div'); downloadButtonContainer.classList.add('fp-download'); const downloadButton = GM_addElement('a'); downloadButton.style.fontSize = '1.4em'; downloadButton.textContent = '⬇'; downloadButtonContainer.appendChild(downloadButton); const loadingElement = GM_addElement('div'); loadingElement.classList.add('loader'); downloadButton.addEventListener('click', () => { downloadButtonContainer.removeChild(downloadButton); downloadButtonContainer.appendChild(loadingElement); GM_fetch(video.src, { method: 'GET', withCredentials: true, credentials: 'include', }) .then((resp) => { if (!resp.ok) { return Promise.reject(); } return resp; }) .then( (resp) => resp.blob(), (e) => { GM_log(`error: ${e}`); console.error(e); downloadButtonContainer.appendChild(downloadButton); downloadButtonContainer.removeChild(loadingElement); downloadButton.textContent = '⮿'; } ) .then((blob) => { saveAs(blob, getFilenameFromURL(video.src)); downloadButtonContainer.appendChild(downloadButton); downloadButtonContainer.removeChild(loadingElement); downloadButton.textContent = '✓'; }); }); fullScreenButton.parentNode?.insertBefore( downloadButtonContainer, fullScreenButton.nextSibling ); }); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址