Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name New Userscript
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description try to take over the world!
- // @author You
- // @match http://*/*
- // @grant none
- // ==/UserScript==
- (function() {
- 'use strict';
- var getCommand = function() {
- var videoUrl = (document.getElementsByTagName('iframe')[0].contentDocument).getElementsByTagName('video')[0].src;
- if (videoUrl.match(/.*google.*\.mp4$/)) {
- alert(videoUrl);
- } else {
- alert('No se ha encontrado url de video descargable');
- }
- };
- // Si tengo al menos una opción que venga de google apis tiro palante
- var googleApiOption = Array.from(document.querySelectorAll('span.server'))
- .map(s => ({ node: s, text: s.innerText}))
- .filter(s => s.text.match(/googleapis/i));
- if (googleApiOption.length > 0) {
- // Me aseguro de primero seleccionar la opcion de google api
- googleApiOption[0].node.parentNode.click();
- // Pongo mi boton de descarga
- var container = document.getElementById('playcontainer');
- var downloadButton = document.createElement('button');
- downloadButton.type = 'button';
- downloadButton.innerText = 'Descargar';
- downloadButton.addEventListener('click', getCommand);
- container.appendChild(downloadButton);
- }
- // Your code here...
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement