RTP Play Downloader

Userscript to download media from RTP Play

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        RTP Play Downloader
// @author      guicale <[email protected]>
// @namespace   rtpplaydl
// @description Userscript to download media from RTP Play
// @include     http://*rtp.pt/play/p*
// @version     2
// @grant       none
// @copyright   2016, Guilherme Calé
// @license     GPL 3, https://www.gnu.org/licenses/
// ==/UserScript==

(function() {
    'use strict';
    var flashvars = document.getElementById('obj_player_prog').getAttribute('flashvars');
    var regex = new RegExp("file=(mp3|mp4):(.*?)&");
    var file = flashvars.match(regex);
    var link = 'http://cdn-ondemand.rtp.pt' + file[2];
    var div = document.getElementsByClassName('col-sm-4 col-xs-12 padding-left-0')[0];
    var a = document.createElement('a');
    a.setAttribute('href',link);
    a.appendChild(document.createTextNode('Download'));
    div.appendChild(a);
})();