Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name ManyVids - Stream Only video downloader
- // @homepage https://www.empornium.me/forums.php?action=viewthread&threadid=98925
- // @icon https://www.manyvids.com/favicon.png
- // @version 1.5
- // @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.
- // @author You-should-own-what-you-purchase
- // @match https://www.manyvids.com/Video/*
- // @grant none
- // @license MIT
- // ==/UserScript==
- (function () {
- 'use strict'
- async function error(parameter) {
- let error_message = `ManyVids - Stream Only video downloader
- Error getting the ${parameter}.
- If you want this to get fixed,
- please tell the developer the video link,
- browser and userscript manager you use.`
- await alert(error_message)
- console.error(error_message)
- }
- // If there is no 'Stream Only' string in the video details, that means the video is not stream only.
- var video_details = document.querySelector('[class="mb-1"]').innerText
- var video_details_regex = /Stream Only$/
- if (!video_details_regex.test(video_details)) {
- return
- }
- // If there is a 'Login' button that means you are not logged in.
- var login_button = document.getElementById('mvts-nav-login-btn')
- if (login_button) {
- return
- }
- // If there is a 'Add to Cart' button that means the video is not purchased and can't be downloaded.
- var add_to_cart_button = document.getElementsByClassName('btn btn-primary add-cart cart-trigger js-video-cart-btn')[0]
- if (add_to_cart_button) {
- return
- }
- // Tries to find the id parameter. The source is from the video URL pathname.
- var id_parameter_source = window.location.pathname
- var id_parameter_regex = /\/Video\/([0-9]+)\//
- var id_parameter = id_parameter_source.match(id_parameter_regex)
- if (id_parameter === null) {
- error('id parameter')
- return
- } else {
- id_parameter = id_parameter[1]
- }
- // Tries to find the c or etag parameter. The source is from the webpage source code.
- var c_or_etag_parameter_source = document.getElementById('pageMetaDetails').getAttribute('data-meta-image')
- var c_parameter_regex = /cloudfront\.net\/php_uploads\/video_images\/.+?\/thumbs\/thumb_([0-9a-zA-Z]+)_screenshot_/
- var etag_parameter_regex = /cloudfront\.net\/[0-9]+\/([0-9a-z]+)\/screenshots\//
- var c_parameter = ''
- var etag_parameter = c_or_etag_parameter_source.match(etag_parameter_regex)
- if (etag_parameter === null) {
- etag_parameter = ''
- c_parameter = c_or_etag_parameter_source.match(c_parameter_regex)
- if (c_parameter === null) {
- error('c or etag parameters')
- return
- } else {
- c_parameter = c_parameter[1]
- }
- } else {
- etag_parameter = etag_parameter[1]
- }
- // Adds the download button to its usual place.
- var download_button = `<a class="js-download-btn btn btn-primary btn-sm"
- href="/download.php?id=${id_parameter}&c=${c_parameter}&etag=${etag_parameter}"
- target="_blank">Download</a>`
- document.querySelector('.buy-wrapper.video-buy-wrapper > .text-right.mt-2').insertAdjacentHTML('beforeEnd', download_button)
- })()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement