eroak / Download Openload Video

// ==UserScript==
// @name         Download Openload Video
// @namespace    http://tampermonkey.net/
// @version      0.13.3
// @description  Displays a download link that allows you to download the Openload videos
// @author       Eroak
// @match        https://openload.co/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    
    var linkIsAdded = false;
    
    var interval = setInterval(function() {
        var videoURL = getVideoURL();
        if (videoURL && !linkIsAdded) {
            displayDownloadVideoLink(videoURL);
            clearInterval(interval);
        }
    }, 500);
    
    function displayDownloadVideoLink(videoURL) {
        var link = createDownloadVideoLink(videoURL);
        document.body.appendChild(link);
        linkIsAdded = true;
    }
    
    function getVideoURL() {
        
        var fileid = document.querySelector("#streamurj").innerText;
        return ['https://openload.co/stream/', fileid, '?mime=true'].join('');
        return document.querySelector('video').src || null;
    }
    
    function createDownloadVideoLink(url) {
        var link = document.createElement('a');
        link.innerText = 'Télécharger ⭳';
        link.classList.add('btn-download-video');
        link.target = '_blank';
        link.href = url;
        link.setAttribute('download', 'video');
        
        Object.assign(link.style, {
          position: 'fixed',
          top: 0,
          right: 0,
          background: '#73859f',
          color: 'white',
          margin: '10px',
          padding: '5px',
          borderRadius: '10px',
          textDecoration: 'none',
          fontFamily: 'sans-serif',
          fontSize: '12px',
          zIndex: 99999999
        });
        
        return link;
    }
    
})();