您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
This script allows you to watch and download videos on Rai Play.
当前为
// ==UserScript== // @name Rai Play video download // @namespace http://andrealazzarotto.com // @version 10.0 // @description This script allows you to watch and download videos on Rai Play. // @author Andrea Lazzarotto // @match https://www.raiplay.it/* // @require http://code.jquery.com/jquery-latest.min.js // @grant none // @license GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html // ==/UserScript== (function() { 'use strict'; var $ = window.jQuery; var Foundation = window.Foundation; var download_icon = '<svg viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"><path d="M42 40v4H6v-4h36zM20 24v-8h8v8h7L24 37 13 24h7zm8-14v4h-8v-4h8zm0-6v4h-8V4h8z" /></svg>'; var showModal = (title, content) => { var modal = $(` <div id="video-download-modal" class="small reveal" data-reveal aria-labelledby="Download video"> <h2 id="modal-title">${title}</h2> <div id="modal-content"></div> <button class="close-button" data-close aria-label="Chiudi finestrella" type="button"> <span aria-hidden="true">×</span> </button> </div> `); modal.css({ 'background-color': '#001623', }); modal.find('#modal-content').append(content); var instance = new Foundation.Reveal(modal); instance.open(); modal.find('.close-button').css({ 'color': 'white', }).click(() => instance.close()); }; var getVideo = () => { var path = location.href.replace(/.html$/, '.json'); $.getJSON(path).then((data) => { return $.ajax({ 'url': 'https://video.lazza.dk/rai?r=' + data.video.content_url, 'method': 'GET', }).promise(); }).then((response) => { if (!response) { showModal('Niente da fare...', "<p>Non è stato possibile trovare un link del video in formato MP4. Il video potrebbe essere protetto da DRM.</p>"); } else { showModal('Link diretto', ` <p>Clicca il bottone per aprire il video in formato MP4. Usa il tasto destro per salvarlo.</p> <p><strong>Per i video lunghi è raccomandato l'uso di un download manager.</strong></p> <p><a href="${response}" class="button" target="_blank">Video MP4</a></p> `); } }).fail(() => { showModal('Errore di rete', "<p>Si è verificato un errore di rete. Riprova più tardi.</p>"); }); }; var downloadButton = () => { if ($('#video-download-button').length) { return; } $('.rai-player-infobutton').before(` <button id="video-download-button" class="vjs-control vjs-button" aria-disabled="false"> <span aria-hidden="true" class="vjs-icon-placeholder">${download_icon}</span> <span class="vjs-control-text" aria-live="polite">Download</span> </button> `); $('#video-download-button').click(getVideo) .find('svg').css({ 'fill': '#039cf9', 'height': '3.5em', }); }; var observer = new MutationObserver(downloadButton); var player = document.querySelector('rai-player'); if (player) { observer.observe(player, { attributeFilter: ["id"], attributes: true, subtree: true }); } $('.highlight__more-info').removeClass('small-offset-2').after(` <a id="inline-download-button" class="cell small-4 medium-shrink highlight__more-info" aria-label="Download"> <div class="highlight__more-info__button button button--light-ghost button--circle float-center">${download_icon}</div> <span class="button-label">Download</span> </a> `); $('#inline-download-button').click(getVideo); var anonymous = !!$('#accountPanelLoginPanel').is(':visible'); if (anonymous) { $('body').on('touchstart mousedown', 'a.card-item__link', (event) => { location.href = $(event.currentTarget).attr('href'); }); } })();