1document.addEventListener("DOMContentLoaded", function () { 2 var lazyloadImages; 3 4 if ("IntersectionObserver" in window) { 5 lazyloadImages = document.querySelectorAll(".lazy"); 6 var imageObserver = new IntersectionObserver(function (entries, observer) { 7 entries.forEach(function (entry) { 8 if (entry.isIntersecting) { 9 var image = entry.target; 10 image.src = image.dataset.src; 11 image.classList.remove("lazy"); 12 imageObserver.unobserve(image); 13 } 14 }); 15 }); 16 17 lazyloadImages.forEach(function (image) { 18 imageObserver.observe(image); 19 }); 20 } else { 21 var lazyloadThrottleTimeout; 22 lazyloadImages = document.querySelectorAll(".lazy"); 23 24 function lazyload() { 25 if (lazyloadThrottleTimeout) { 26 clearTimeout(lazyloadThrottleTimeout); 27 } 28 29 lazyloadThrottleTimeout = setTimeout(function () { 30 var scrollTop = window.pageYOffset; 31 lazyloadImages.forEach(function (img) { 32 if (img.offsetTop < (window.innerHeight + scrollTop)) { 33 img.src = img.dataset.src; 34 img.classList.remove('lazy'); 35 } 36 }); 37 if (lazyloadImages.length === 0) { 38 document.removeEventListener("scroll", lazyload); 39 window.removeEventListener("resize", lazyload); 40 window.removeEventListener("orientationChange", lazyload); 41 } 42 }, 20); 43 } 44 45 document.addEventListener("scroll", lazyload); 46 window.addEventListener("resize", lazyload); 47 window.addEventListener("orientationChange", lazyload); 48 } 49}) 50 51var siteUrl = WPURLS.siteurl; 52var translations = LANG_STRINGS; 53var autoFetch = false; 54var executed = false; 55let elm; 56 57if (document.getElementById("downloadBtn")) { 58 document.getElementById("downloadBtn").addEventListener("click", clickDownload); 59} 60window.addEventListener("hashchange", function () { 61 url(); 62}, false); 63url(); 64 65function calculateHash(url, salt) { 66 return btoa(url) + (url.length + 1_000) + btoa(salt); 67} 68 69function clickDownload(e) { 70 let url = document.getElementById("url").value; 71 let token = document.getElementById("token").value; 72 if (!isEmpty(url) && isValidURL(url)) { 73 executed = true; 74 hideAlert(); 75 let headers = new Headers(); 76 headers.append("Content-Type", "application/x-www-form-urlencoded"); 77 let urlencoded = new URLSearchParams(); 78 urlencoded.append("url", url); 79 urlencoded.append("token", token); 80 urlencoded.append("hash", calculateHash(url, 'aio-dl')); 81 let requestOptions = { 82 method: 'POST', 83 headers: headers, 84 body: urlencoded, 85 redirect: 'follow' 86 }; 87 showLoader(); 88 removeHash(); 89 window.location.replace("#url=" + url); 90 let statusCode; 91 fetch(siteUrl + "/wp-json/aio-dl/video-data/", requestOptions) 92 .then(response => { 93 if (response.status === 403) { 94 window.location.reload(); 95 } 96 statusCode = response.status; 97 return response.text(); 98 }).then(result => { 99 result = JSON.parse(result) 100 if (result.error === undefined) { 101 showResult(result) 102 } else { 103 showAlert(result.error) 104 } 105 }) 106 .catch(error => { 107 showAlert(statusCode + " " + error) 108 }); 109 } else { 110 showAlert(translations['enterValidUrl']); 111 } 112 e.preventDefault(); 113} 114 115var input = document.getElementById("url"); 116if (input) { 117 input.addEventListener("keyup", function (event) { 118 if (event.keyCode === 13) { 119 clickDownload(); 120 event.preventDefault(); 121 } 122 }); 123 124} 125 126 127function url() { 128 if (window.location.href.indexOf("#url=") > -1 && executed === false) { 129 let url = window.location.href.match(new RegExp("#url=(.+)", ""))[1]; 130 let token = document.getElementById("token").value; 131 document.getElementById("url").value = url; 132 document.getElementById("header").scrollIntoView(); 133 if (autoFetch && token !== "" && url !== "" && !executed) { 134 clickDownload(); 135 executed = true; 136 } 137 } 138} 139 140function isValidURL(url) { 141 if (!elm) { 142 elm = document.createElement('input'); 143 elm.setAttribute('type', 'url'); 144 } 145 elm.value = url; 146 return elm.validity.valid; 147} 148 149function isEmpty(str) { 150 return (!str || str.length === 0); 151} 152 153function showLoader() { 154 document.getElementById("url").style.display = "none"; 155 document.getElementById("downloadBtn").style.display = "none"; 156 document.getElementById("pasteBtn").style.display = "none"; 157 let loader = document.createElement("img"); 158 loader.src = siteUrl + "/wp-content/themes/aiodl-default/assets/loader.svg"; 159 loader.className = "img-fluid w-25 mx-auto"; 160 loader.id = "loader"; 161 document.getElementById("download-form").appendChild(loader); 162} 163 164function hideLoader() { 165 document.getElementById("url").style.display = ""; 166 document.getElementById("downloadBtn").style.display = ""; 167 document.getElementById("pasteBtn").style.display = ""; 168 if (document.getElementById("loader") !== null) { 169 document.getElementById("loader").remove(); 170 } 171} 172 173function showAlert(message) { 174 let alertDiv = document.getElementById("alert"); 175 alertDiv.innerHTML = message; 176 alertDiv.style.display = ""; 177 setTimeout(hideAlert, 5000); 178 hideLoader(); 179} 180 181function hideAlert() { 182 let alertDiv = document.getElementById("alert"); 183 alertDiv.innerHTML = ""; 184 alertDiv.style.display = "none"; 185} 186 187function removeHash() { 188 history.pushState("", document.title, window.location.pathname 189 + window.location.search); 190} 191 192function showResult(result) { 193 hideLoader(); 194 let template = '<div class="container"> <div class="row mb-0"> <div class="col-12 mb-10 mb-lg-0"> <h2 class="mt-8 mb-0 text-center">{{title}} <small class="text-muted" id="videoDuration">{{duration}}</small></h2> <div class="row text-center"> <div class="col-md-4 col-sm-12 mt-4"> <img class="position-relative img-fluid rounded w-100" style="object-fit: cover;z-index:-1" src="{{thumbnail}}" alt="{{title}}" title="{{title}}"> </div><div class="col-md-8 col-sm-12 mt-4 p-0">{{links}}</div> </div> </div> <div class="row mb-n6 py-6 d-flex align-items-start text-center"> <div id="share-buttons"> <p class="lead share-text">' + translations.share + '</p> <a title="Facebook" href="{{facebook_share_link}}" class="btn btn-social btn-fill btn-facebook mx-1" target="_blank">Facebook</a><a title="Twitter" href="{{twitter_share_link}}" class="btn btn-social btn-fill btn-twitter mx-1" target="_blank">Twitter</a><a title="Whatsapp" href="{{whatsapp_share_link}}" class="btn btn-social btn-fill btn-whatsapp mx-1" target="_blank">Whatsapp</a><a title="Pinterest" href="{{pinterest_share_link}}" class="btn btn-social btn-fill btn-pinterest mx-1" target="_blank">Pinterest</a><a title="Tumblr" href="{{tumblr_share_link}}" class="btn btn-social btn-fill btn-tumblr mx-1" target="_blank">Tumblr</a><a title="Reddit" href="{{reddit_share_link}}" class="btn btn-social btn-fill btn-reddit mx-1" target="_blank">Reddit</a><a title="QR Code" href="{{qr_share_link}}" class="btn btn-social btn-fill btn-qr mx-1" target="_blank">QR Code</a></div></div></div></div>' 195 let buttons = ""; 196 Â Â let buttonTemplate1 = '<a href="{{url}}" class="btn btn-success btn-sq btn-dl text-uppercase mx-1 my-1"><strong>{{quality}}</strong><br>{{icon}}{{type}}<br>({{size}}
196)</a>'; 197 Â Â let buttonTemplate2 = '<a href="{{url}}" class="btn btn-danger btn-sq btn-dl text-uppercase mx-1 my-1"><strong>{{quality}}</strong><br>{{icon}}{{type}}<br>({{size}})</a>'; 198 Â Â let buttonTemplate3 = '<a href="{{url}}" class="btn btn-info btn-sq btn-dl text-uppercase mx-1 my-1"><strong>{{quality}}</strong><br>{{icon}}{{type}}<br>({{size}})</a>'; 199 let audioIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="1rem" fill="white" viewBox="0 0 415.963 415.963"><path d="M328.712 264.539c12.928-21.632 21.504-48.992 23.168-76.064 1.056-17.376-2.816-35.616-11.2-52.768-13.152-26.944-35.744-42.08-57.568-56.704-16.288-10.912-31.68-21.216-42.56-35.936l-1.952-2.624c-6.432-8.64-13.696-18.432-14.848-26.656-1.152-8.32-8.704-14.24-16.96-13.76a15.957 15.957 0 00-14.88 15.936v285.12c-13.408-8.128-29.92-13.12-48-13.12-44.096 0-80 28.704-80 64s35.904 64 80 64 80-28.704 80-64V165.467c24.032 9.184 63.36 32.576 74.176 87.2-2.016 2.976-3.936 6.176-6.176 8.736-5.856 6.624-5.216 16.736 1.44 22.56 6.592 5.888 16.704 5.184 22.56-1.44 4.288-4.864 8.096-10.56 11.744-16.512.384-.448.737-.928 1.056-1.472z"/></svg> '; 200 let videoIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="1rem" fill="white" viewBox="0 0 467.968 467.968"><path d="M264.704 96.512H51.2c-28.16 0-51.2 23.04-51.2 51.2v172.544c0 28.16 23.04 51.2 51.2 51.2h213.504c28.16 0 51.2-23.04 51.2-51.2V147.712c0-28.672-23.04-51.2-51.2-51.2zM430.08 124.672c-3.072.512-6.144 2.048-8.704 3.584l-79.872 46.08V293.12l80.384 46.08c14.848 8.704 33.28 3.584 41.984-11.264 2.56-4.608 4.096-9.728 4.096-15.36V154.368c0-18.944-17.92-34.304-37.888-29.696z"/></svg> '; 201 let imageIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="1rem" fill="white" viewBox="0 0 550.801 550.8"><path d="M515.828 61.201H34.972C15.659 61.201 0 76.859 0 96.172V454.63c0 19.312 15.659 34.97 34.972 34.97h480.856c19.314 0 34.973-15.658 34.973-34.971V96.172c0-19.313-15.658-34.971-34.973-34.971zm0 34.971V350.51l-68.92-62.66c-10.359-9.416-26.289-9.04-36.186.866l-69.752 69.741-137.532-164.278c-10.396-12.415-29.438-12.537-39.99-.271L34.972 343.219V96.172h480.856zm-148.627 91.8c0-26.561 21.523-48.086 48.084-48.086 26.562 0 48.086 21.525 48.086 48.086s-21.523 48.085-48.086 48.085c-26.56.001-48.084-21.524-48.084
201-48.085z"/></svg> '; 202 let dashIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="1rem" fill="white" viewBox="0 0 448.075 448.075"><path d="M352.021 16.075c0-6.08-3.52-11.84-8.96-14.4-5.76-2.88-12.16-1.92-16.96 1.92l-141.76 112.96 167.68 167.68V16.075zM443.349 420.747l-416-416c-6.24-6.24-16.384-6.24-22.624 0s-6.24 16.384 0 22.624l100.672 100.704h-9.376c-9.92 0-18.56 4.48-24.32 11.52-4.8 5.44-7.68 12.8-7.68 20.48v128c0 17.6 14.4 32 32 32h74.24l155.84 124.48c2.88 2.24 6.4 3.52 9.92 3.52 2.24 0 4.8-.64 7.04-1.6 5.44-2.56 8.96-8.32 8.96-14.4v-57.376l68.672 68.672c3.136 3.136 7.232 4.704 11.328 4.704s8.192-1.568 11.328-4.672c6.24-6.272 6.24-16.384 0-22.656z"/></svg> '; 203 let i = 0; 204 if (typeof result.medias === "undefined") { 205 if (result.error) { 206 showAlert(result.error); 207 } else { 208 showAlert("No media found."); 209 } 210 211 return; 212 } 213 result.medias.forEach(function (media) { 214 let downloadUrl; 215 if (media.url !== null) { 216 let button; 217 let icon; 218 if (media.extension === "jpg" || (media.videoAvailable === true && media.audioAvailable === true)) { 219 button = buttonTemplate1; 220 } else if (media.quality.includes("kbps")) { 221 button = buttonTemplate2; 222 } else { 223 button = buttonTemplate3; 224 } 225 if (media.extension === "jpg") { 226 icon = imageIcon; 227 } else if (media.videoAvailable === true && media.audioAvailable === false) { 228 icon = dashIcon; 229 } else if (media.quality.includes("kbps")) { 230 icon = audioIcon; 231 } else { 232 icon = videoIcon; 233 } 234 button = button.replace(new RegExp("{{quality}}", "g"), media.quality); 235 button = button.replace(new RegExp("{{type}}", "g"), media.extension); 236 button = button.replace(new RegExp("{{icon}}", "g"), icon); 237 button = button.replace(new RegExp("{{size}}", "g"), media.formattedSize); 238 downloadUrl = siteUrl + "/wp-content/plugins/aio-video-downloader/download.php?source=" + result.source + "&media=" + btoa(i); 239 if (result.sid) { 240 downloadUrl += '&sid=' + result.sid; 241 } 242 button = button.replace(new RegExp("{{url}}", "g"), downloadUrl); 243 buttons = buttons.concat(button); 244 i++; 245 } 246 }); 247 template = template.replace(new RegExp("{{title}}", "g"), result.title); 248 template = template.replace(new RegExp("{{thumbnail}}", "g"), result.thumbnail); 249 template = template.replace(new RegExp("{{duration}}", "g"), result.duration); 250 template = template.replace(new RegExp("{{links}}", "g"), buttons); 251 //const sharingUrl = window.location.href.replace(new RegExp("#url=", "g"), "?u="); 252 const sharingUrl = window.location.href; 253 template = template.replace(new RegExp("{{facebook_share_link}}", "g"), encodeURI("https://www.facebook.com/sharer.php?u=" + sharingUrl)); 254 template = template.replace(new RegExp("{{twitter_share_link}}", "g"), encodeURI("https://twitter.com/intent/tweet?url=" + sharingUrl + "&text=Download " + result.title)); 255 template = template.replace(new RegExp("{{whatsapp_share_link}}", "g"), encodeURI("whatsapp://send?text=Download " + result.title + " " + sharingUrl)); 256 template = template.replace(new RegExp("{{pinterest_share_link}}", "g"), encodeURI("http://pinterest.com/pin/create/link/?url=" + sharingUrl)); 257 template = template.replace(new RegExp("{{tumblr_share_link}}", "g"), encodeURI("https://www.tumblr.com/widgets/share/tool?canonicalUrl=" + sharingUrl + "&title=" + result.title)); 258 template = template.replace(new RegExp("{{reddit_share_link}}", "g"), encodeURI("https://reddit.com/submit?url=" + sharingUrl + "&title=" + result.title)); 259 template = template.replace(new RegExp("{{qr_share_link}}", "g"), encodeURI("https://chart.googleapis.com/chart?cht=qr&chs=300x300&chl=" + sharingUrl)); 260 document.getElementById("result").innerHTML = template; 261 if (result.duration === null && document.getElementById("videoDuration") !== null) { 262 document.getElementById("videoDuration").remove(); 263 } 264 let resultDiv = document.getElementById("result"); 265 resultDiv.style.display = ""; 266 document.getElementById("ad-area-2").scrollIntoView(); 267} 268 269if (document.getElementById("pasteBtn")) { 270 document.getElementById("pasteBtn").addEventListener("click", (e) => { 271 let pasteBtn = document.getElementById("pasteBtn"); 272 let input = document.getElementById("url") 273 if (pasteBtn.innerHTML === translations.clear) { 274 input.value = ""; 275 pasteBtn.innerHTML = 'Paste from clipboard'; 276 } else { 277 navigator.clipboard.readText().then(clipText => 278 input.value = clipText, 279 pasteBtn.innerHTML = translations.clear); 280 } 281 }); 282} 283 284// Burger menus 285document.addEventListener('DOMContentLoaded', function () { 286 let i; 287// open 288 const burger = document.querySelectorAll('.navbar-burger'); 289 const menu = document.querySelectorAll('.navbar-menu'); 290 291 if (burger.length && menu.length) { 292 for (i = 0; i < burger.length; i++) { 293 burger[i].addEventListener('click', function () { 294 for (var j = 0; j < menu.length; j++) { 295 menu[j].classList.toggle('d-none'); 296 } 297 }); 298 } 299 } 300 301 // close 302 const close = document.querySelectorAll('.navbar-close'); 303 const backdrop = document.querySelectorAll('.navbar-backdrop'); 304 305 if (close.length) { 306 for (i = 0; i < close.length; i++) { 307 close[i].addEventListener('click', function () { 308 for (var j = 0; j < menu.length; j++) { 309 menu[j].classList.toggle('d-none'); 310 } 311 }); 312 } 313 } 314 315 if (backdrop.length) { 316 for (i = 0; i < backdrop.length; i++) { 317 backdrop[i].addEventListener('click', function () { 318 for (let j = 0; j < menu.length; j++) { 319 menu[j].classList.toggle('d-none'); 320 } 321 }); 322 } 323 } 324});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.