CJXXX AUTO DOWNLOAD

Downloads CJXXX videos when the video is opened into a tab

  1. // ==UserScript==
  2. // @name CJXXX AUTO DOWNLOAD
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Downloads CJXXX videos when the video is opened into a tab
  6. // @author GP Downloads
  7. // @match https://asia-pass.com/newcms/members/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=asia-pass.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. window.hasDownloadedVideo=false
  16. function StartVideo(){
  17. document.querySelector('.fp-play.fp-visible').click()
  18. }
  19.  
  20. function downloadVideo(vTitle, tries=0){
  21. if(tries > 3){
  22. alert("DOWNLOAD FAIL");
  23. return;
  24. }
  25.  
  26. StartVideo();
  27. setTimeout(()=>{
  28. const src = document.querySelector('video').src;
  29. if(!src){
  30. setTimeout(()=>{
  31. downloadVideo(vTitle, tries+1)
  32. }, 1000);
  33. return;
  34. }
  35.  
  36. let newelement = document.createElement('a');
  37. newelement.setAttribute('href', src);
  38. newelement.setAttribute('download', vTitle+'.mp4');
  39. newelement.click();
  40. }, 1500);
  41. }
  42.  
  43. function start(){
  44. setTimeout(()=>{
  45. const vTitle = document.querySelector('.video_title').innerText;
  46. downloadVideo(vTitle);
  47. }, 500);
  48. }
  49. // Your code here...
  50. window.onfocus = function(){
  51. if(window.hasDownloadedVideo) return;
  52. window.hasDownloadedVideo=true
  53. start();
  54. }
  55.  
  56. if(document.hasFocus()){
  57. start();
  58. }
  59. })();