SHARE
TWEET

Untitled

a guest Oct 13th, 2019 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         ManyVids - Stream Only video downloader
  3. // @homepage     https://www.empornium.me/forums.php?action=viewthread&threadid=98925
  4. // @icon         https://www.manyvids.com/favicon.png
  5. // @version      1.5
  6. // @description  ManyVids' devs could easily patch this! So please be careful where you share this! Adds a download button to stream only videos. It downloads the original video file as if downloading was enabled.
  7. // @author       You-should-own-what-you-purchase
  8. // @match        https://www.manyvids.com/Video/*
  9. // @grant        none
  10. // @license      MIT
  11. // ==/UserScript==
  12. (function () {
  13.    'use strict'
  14.  
  15.    async function error(parameter) {
  16.        let error_message = `ManyVids - Stream Only video downloader
  17. Error getting the ${parameter}.
  18. If you want this to get fixed,
  19. please tell the developer the video link,
  20. browser and userscript manager you use.`
  21.        await alert(error_message)
  22.        console.error(error_message)
  23.    }
  24.  
  25.    // If there is no 'Stream Only' string in the video details, that means the video is not stream only.
  26.    var video_details = document.querySelector('[class="mb-1"]').innerText
  27.    var video_details_regex = /Stream Only$/
  28.    if (!video_details_regex.test(video_details)) {
  29.        return
  30.    }
  31.  
  32.    // If there is a 'Login' button that means you are not logged in.
  33.    var login_button = document.getElementById('mvts-nav-login-btn')
  34.    if (login_button) {
  35.        return
  36.    }
  37.  
  38.    // If there is a 'Add to Cart' button that means the video is not purchased and can't be downloaded.
  39.    var add_to_cart_button = document.getElementsByClassName('btn btn-primary add-cart cart-trigger js-video-cart-btn')[0]
  40.    if (add_to_cart_button) {
  41.        return
  42.    }
  43.  
  44.    // Tries to find the id parameter. The source is from the video URL pathname.
  45.    var id_parameter_source = window.location.pathname
  46.    var id_parameter_regex = /\/Video\/([0-9]+)\//
  47.    var id_parameter = id_parameter_source.match(id_parameter_regex)
  48.    if (id_parameter === null) {
  49.        error('id parameter')
  50.        return
  51.    } else {
  52.        id_parameter = id_parameter[1]
  53.    }
  54.  
  55.    // Tries to find the c or etag parameter. The source is from the webpage source code.
  56.    var c_or_etag_parameter_source = document.getElementById('pageMetaDetails').getAttribute('data-meta-image')
  57.    var c_parameter_regex = /cloudfront\.net\/php_uploads\/video_images\/.+?\/thumbs\/thumb_([0-9a-zA-Z]+)_screenshot_/
  58.    var etag_parameter_regex = /cloudfront\.net\/[0-9]+\/([0-9a-z]+)\/screenshots\//
  59.    var c_parameter = ''
  60.    var etag_parameter = c_or_etag_parameter_source.match(etag_parameter_regex)
  61.    if (etag_parameter === null) {
  62.        etag_parameter = ''
  63.        c_parameter = c_or_etag_parameter_source.match(c_parameter_regex)
  64.        if (c_parameter === null) {
  65.            error('c or etag parameters')
  66.            return
  67.        } else {
  68.            c_parameter = c_parameter[1]
  69.        }
  70.    } else {
  71.        etag_parameter = etag_parameter[1]
  72.    }
  73.  
  74.    // Adds the download button to its usual place.
  75.    var download_button = `<a class="js-download-btn btn btn-primary btn-sm"
  76.    href="/download.php?id=${id_parameter}&c=${c_parameter}&etag=${etag_parameter}"
  77.    target="_blank">Download</a>`
  78.    document.querySelector('.buy-wrapper.video-buy-wrapper > .text-right.mt-2').insertAdjacentHTML('beforeEnd', download_button)
  79. })()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top