/*
This script allow view and download private videos from ZX18.
If you looking for python version is on https://gist.github.com/ErikV7-official/7188d01efee99b1b5b3ce7ef6ca90eaa - (in this version you can view the videos on android)
Requirements:
- Tampermonkey (browser extension)
Instructions:
1- Install the Tampermonkey browser extension
2- Create new script, paste this code and save it
3- When you visit ZX18 it should be running
Notes:
- This code is open source and can be modified as such to meet working standards of "the site" this script is being used on
- You may release your own fixes as such
Paypal email: eiarandadebastiani@gmail.com
Have great day
*/
//ZXDL SCRIPT 2.0.0 - By ErikV7
//SCRIPT AS JAVASCRIPT CODE
// ==UserScript==
// @name ZXDL
// @namespace https://zoox18.com/
// @version 2.0.0
// @description View and download private videos from ZX18.
// @author Low & ErikV7
// @match https://*.zoox18.com/*
// @grant GM_listValues
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// @grant GM_xmlhttpRequest
// @grant GM_info
// @grant GM_openInTab
// @grant GM_setClipboard
// @grant GM_registerMenuCommand
// @grant GM_unregisterMenuCommand
// @grant GM_notification
// @grant GM_download
// @grant GM.info
// @grant GM.listValues
// @grant GM.setValue
// @grant GM.getValue
// @grant GM.deleteValue
// @grant GM.openInTab
// @grant GM.setClipboard
// @grant GM.xmlHttpRequest
// @require http://ajax.googleapis.com/ajax/libs/jquery/3.5.0/jquery.min.js
// @require https://cdn.plyr.io/3.6.3/plyr.js
// ==/UserScript==
// Inject
var downloading = false;
var found = false;
var isPrivateWindow = false;
var id = window.location.pathname.split("/")[2];
var vidUrl = '';
var uploader = 'Unknown';
var title = 'Unknown';
var $ = window.jQuery;
var Plyr = window.Plyr;
$('.navbar').after('
');
$('.top-menu > .pull-left').append('
ZXDL 2.0.0 - By Low & ErikV7
');
// Remove annoyances
document.querySelectorAll('.img-private').forEach(elm => (elm.style.filter = 'brightness(1)'));
document.querySelectorAll('.label-private').forEach(elm => (elm.style.filter = 'opacity(0.5)'));
// Functions
function formatBytes(a,b=2) {
if (0===a) return "0 bytes";
const c=0>b?0:b,d = Math.floor(Math.log(a) / Math.log(1024));
return parseFloat((a / Math.pow(1024, d)).toFixed(c)) + " " +["bytes","KB","MB","GB"][d];
}
function dl_progress(res) {
if (res.lengthComputable === false) return;
$('#dl-data').html(formatBytes(res.done) +' / '+ formatBytes(res.total));
$('#dl-bar').attr("aria-valuenow", Math.floor(res.done / res.total * 100));
$('#dl-bar').css("width", Math.floor(res.done / res.total * 100) + "%");
$('#dl-bar').html(Math.floor(res.done / res.total * 100) + "%");
}
function dl_load(res) {
if (res.lengthComputable === false) return;
$('#dl-data').html("Complete!");
$('#dl-bar').addClass("progress-bar-success");
}
function dl_error(res) {
if (res.lengthComputable === false) return;
$('#dl-data').html("Oops, there was an error. Refresh page to try again");
$('#dl-bar').addClass("progress-bar-danger");
}
// Path list
var key1 = "Afgf8121k";
var key2 = "Iu528sZA";
var key3 = "9asaGH4";
var paths =
[
'https://md.zoox18.com/'+key1+'/media/videos/h264/'+id+'.mp4',
'https://md1.zoox18.com/'+key1+'/media/videos/h264/'+id+'_SD.mp4',
'https://md2.zoox18.com/'+key1+'/media/videos/iphone/'+id+'.mp4',
'https://md.zoox18.com/'+key2+'/media/videos/h264/'+id+'.mp4',
'https://md1.zoox18.com/'+key2+'/media/videos/h264/'+id+'_SD.mp4',
'https://md2.zoox18.com/'+key2+'/media/videos/iphone/'+id+'.mp4',
'https://md.zoox18.com/'+key3+'/media/videos/h264/'+id+'.mp4',
'https://md1.zoox18.com/'+key3+'/media/videos/h264/'+id+'_SD.mp4',
'https://md2.zoox18.com/'+key3+'/media/videos/iphone/'+id+'.mp4'
];
function scan(url) {
if (found == false){
var v = document.createElement('VIDEO');
v.addEventListener('loadeddata', function () { // If video found
console.log('ZXDL: Video found! ' + url);
found = true;
vidUrl = url;
if (isPrivateWindow){
$('#rip-div').html('
');
var controls = ['play-large', 'play', 'progress', 'current-time', 'mute', 'volume', 'settings', 'fullscreen'];
var player = new Plyr('#rippedvid', { controls });
$('#zxdl_favorite').click(function() { // Favorite button for private videos
$('#status').html('Please wait...');
var http = new XMLHttpRequest();
var url = 'https://www.zoox18.com/ajax/favorite_video';
var form = 'video_id='+ id;
http.open('POST', url, true);
http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
http.onreadystatechange = function() {
if(http.readyState == 4 && http.status == 200) {
const response = http.responseText;
if (response.includes('alert-danger')) {
$('#status').html('Couldn\'t favorite video. Are you logged in? Is this video already in your favorites?');
} else if (response.includes('alert-success')) {
$('#status').html('Added to favorites!');
} else {
$('#status').html('The site returned unknown data.');
}
}
};
http.send(form);
});
} else {
// Replace download button on public videos
$('div#share_video').append('');
$('#response_message').after('');
$('button.btn.btn-default.dropdown-toggle').remove();
}
$('#zxdl_download').click(function() {
if (downloading === false){
downloading = true;
$('#dl-progress').css('display','block');
$('#dl-progress').html('This feature is still being worked on! Not all videos or browsers may support this method.
Progress
Loading...
');
GM_download({
url: url,
name: id + ".mp4",
onprogress: dl_progress,
onload: dl_load,
onerror: dl_error
});
} else {
alert('You\'ve already initiated a download. Refresh the page to try again.');
}
});
});
v.src = url;
}
}
// On load
function init() {
if ($('#wrapper .container .row .col-xs-12').length > 0) { // If private video page active
isPrivateWindow = true;
uploader = $('.text-danger a').text();
title = $("meta[property='og:title']").attr("content");
if (window.location.pathname.split("/")[1] == "video") {
$('.well.well-sm').remove(); // Remove notice
$('.well.ad-body').remove(); // Remove sponsor block for non-ad-blockers
$('#rip-div').html('
Scanning for video '+id+'...
This can take up to a minute. If it takes longer, please check your browser\'s console for errors.
');
paths.forEach(scan);
}
}
else if($('#wrapper .container .row .col-md-8 .vcontainer ').length > 0) { // If public video page active
paths.forEach(scan);
}
}
window.addEventListener('load', init, false);