// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-3.0-or-later /* CryptoJS v3.1.2 code.google.com/p/crypto-js (c) 2009-2013 by Jeff Mott. All rights reserved. code.google.com/p/crypto-js/wiki/License */ var CryptoJS=CryptoJS||function(h,s){var f={},t=f.lib={},g=function(){},j=t.Base={extend:function(a){g.prototype=this;var c=new g;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}}, q=t.WordArray=j.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=s?c:4*a.length},toString:function(a){return(a||u).stringify(this)},concat:function(a){var c=this.words,d=a.words,b=this.sigBytes;a=a.sigBytes;this.clamp();if(b%4)for(var e=0;e>>2]|=(d[e>>>2]>>>24-8*(e%4)&255)<<24-8*((b+e)%4);else if(65535>>2]=d[e>>>2];else c.push.apply(c,d);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<< 32-8*(c%4);a.length=h.ceil(c/4)},clone:function(){var a=j.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],d=0;d>>2]>>>24-8*(b%4)&255;d.push((e>>>4).toString(16));d.push((e&15).toString(16))}return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b>>3]|=parseInt(a.substr(b, 2),16)<<24-4*(b%8);return new q.init(d,c/2)}},k=v.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var d=[],b=0;b>>2]>>>24-8*(b%4)&255));return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b>>2]|=(a.charCodeAt(b)&255)<<24-8*(b%4);return new q.init(d,c)}},l=v.Utf8={stringify:function(a){try{return decodeURIComponent(escape(k.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return k.parse(unescape(encodeURIComponent(a)))}}, x=t.BufferedBlockAlgorithm=j.extend({reset:function(){this._data=new q.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=l.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,d=c.words,b=c.sigBytes,e=this.blockSize,f=b/(4*e),f=a?h.ceil(f):h.max((f|0)-this._minBufferSize,0);a=f*e;b=h.min(4*a,b);if(a){for(var m=0;mk;){var l;a:{l=u;for(var x=h.sqrt(l),w=2;w<=x;w++)if(!(l%w)){l=!1;break a}l=!0}l&&(8>k&&(j[k]=v(h.pow(u,0.5))),q[k]=v(h.pow(u,1/3)),k++);u++}var a=[],f=f.SHA256=g.extend({_doReset:function(){this._hash=new t.init(j.slice(0))},_doProcessBlock:function(c,d){for(var b=this._hash.words,e=b[0],f=b[1],m=b[2],h=b[3],p=b[4],j=b[5],k=b[6],l=b[7],n=0;64>n;n++){if(16>n)a[n]= c[d+n]|0;else{var r=a[n-15],g=a[n-2];a[n]=((r<<25|r>>>7)^(r<<14|r>>>18)^r>>>3)+a[n-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+a[n-16]}r=l+((p<<26|p>>>6)^(p<<21|p>>>11)^(p<<7|p>>>25))+(p&j^~p&k)+q[n]+a[n];g=((e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22))+(e&f^e&m^f&m);l=k;k=j;j=p;p=h+r|0;h=m;m=f;f=e;e=r+g|0}b[0]=b[0]+e|0;b[1]=b[1]+f|0;b[2]=b[2]+m|0;b[3]=b[3]+h|0;b[4]=b[4]+p|0;b[5]=b[5]+j|0;b[6]=b[6]+k|0;b[7]=b[7]+l|0},_doFinalize:function(){var a=this._data,d=a.words,b=8*this._nDataBytes,e=8*a.sigBytes; d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=h.floor(b/4294967296);d[(e+64>>>9<<4)+15]=b;a.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var a=g.clone.call(this);a._hash=this._hash.clone();return a}});s.SHA256=g._createHelper(f);s.HmacSHA256=g._createHmacHelper(f)})(Math); // Get the current URL const url = new URL(window.location.href); // Remove the 'fx' query parameter url.searchParams.delete('fx'); // Replace the current URL without the 'fx' parameter history.replaceState(null, '', url.toString()); // Retrieve volume from local storage or set to max if not available const initialVolume = localStorage.getItem('playerVolume') || 1; const video = document.getElementById('video'); video.volume = initialVolume; // Save volume to local storage whenever it changes video.addEventListener('volumechange', function() { localStorage.setItem('playerVolume', this.volume); }); // Get the progress bar and container elements const progressBar = document.querySelector(".progress-bar"); const progressContainer = document.querySelector(".progress-container"); // Set the initial width of the progress bar to 0% progressBar.style.width = "0%"; progressContainer.style.display = 'block'; // Attach an event listener to the window object to listen for the 'load' event window.addEventListener("load", () => { progressBar.style.width = "100%"; setTimeout(() => { progressContainer.style.display = 'none'; }, 500); }); // Lazy load background images document.addEventListener('DOMContentLoaded', function() { const bgs = document.querySelectorAll('[data-bg]'); let bgCount = bgs.length; function loadBg(index) { const bg = bgs[index]; const bgUrl = bg.getAttribute('data-bg'); bg.style.backgroundImage = `url(${bgUrl})`; bg.removeAttribute('data-bg'); bg.classList.add('loaded'); } function lazyLoadBg() { for (let i = 0; i < bgCount; i++) { const bg = bgs[i]; const bgRect = bg.getBoundingClientRect(); if (bgRect.top < window.innerHeight && bgRect.bottom > 0) { loadBg(i); } } } lazyLoadBg(); window.addEventListener('scroll', lazyLoadBg); window.addEventListener('resize', lazyLoadBg); }); // Fade in elements on scroll or fullscreen change function fadeInElements() { const elements = document.querySelectorAll('.fade-in'); const viewportHeight = window.innerHeight; elements.forEach(element => { const elementTop = element.getBoundingClientRect().top; const elementBottom = element.getBoundingClientRect().bottom; const isVisible = (elementTop < viewportHeight && elementBottom > 0); if (isVisible || document.fullscreenElement) { element.classList.add('fade-in-active'); } }); } window.addEventListener('scroll', fadeInElements); document.addEventListener('fullscreenchange', fadeInElements); setInterval(fadeInElements, 100); function jumpToTime(e) { e.preventDefault(); const link = e.target; const video = document.getElementById('video'); const time = link.dataset.jumpTime; video.currentTime = time; window.location.hash = 'top'; // Add #video to the URL setTimeout(() => { history.replaceState(null, null, ' '); // Remove #video after 1 second }, 250); } // Handle click events for time-based links const timeLinks = document.querySelectorAll('a[data-onclick="jump_to_time"]'); timeLinks.forEach(link => { const href = link.getAttribute('href'); if (link.dataset.jumpTime && href && href.includes('&t=')) { const params = new URLSearchParams(href.split('?')[1]); const time = params.get('t'); if (time) { link.dataset.jumpTime = time; link.addEventListener('click', jumpToTime); link.removeAttribute('href'); } } }); // Save and resume video progress const videoId = new URLSearchParams(window.location.search).get('v'); const localStorageKey = `progress-${videoId}`; function saveProgress() { localStorage.setItem(localStorageKey, video.currentTime); } function removeProgress() { localStorage.removeItem(localStorageKey); } function resumeProgress() { const progress = localStorage.getItem(localStorageKey); if (progress) { video.currentTime = progress; } } video.addEventListener('timeupdate', () => { if (Math.floor(video.currentTime) % 1 === 0) { saveProgress(); } }); video.addEventListener('ended', () => { removeProgress(); }); window.addEventListener('load', () => { resumeProgress(); }); // Adjust video element style on fullscreen change const videoElement = document.getElementById("video"); videoElement.addEventListener("fullscreenchange", () => { videoElement.style.borderRadius = document.fullscreenElement === videoElement ? "0em" : "16px"; }); function fetchUrls(urls) { let fetchedCount = 0; urls.forEach(link => { const url = new URL(link.href); if (url.host !== 'www.youtube.com' && url.host !== 'youtube.com' && url.host !== "redirect.poketube.fun") { console.log(`Fetching ${url.origin}`); fetch(url.href) .then(response => { if (response.status === 500) { // do nothing } console.log(`Fetched ${url.origin}`); fetchedCount++; console.clear(); if (fetchedCount === urls.length) { document.body.classList.remove('blur'); } }) .catch(error => { console.clear(); if (!(error instanceof TypeError && error.message.includes('Failed to fetch'))) { console.error(`Error fetching ${url.origin}: ${error}`); } }); } }); } /* // Fetch channel URLs const channelUrls = document.querySelectorAll('a[href*="/channel?id="]'); fetchUrls(channelUrls); // Fetch download URLs const downloadUrls = document.querySelectorAll('a[href*="/download?v="]'); fetchUrls(downloadUrls); // fetch videos urls const urls = document.querySelectorAll('a[href*="/watch?v="]'); fetchUrls(urls); */ var popupMenu = document.getElementById("popupMenu"); var loopOption = document.getElementById("loopOption"); var speedOption = document.getElementById("speedOption"); video.addEventListener("contextmenu", function(event) { event.preventDefault(); popupMenu.style.display = "block"; popupMenu.style.left = event.pageX + "px"; popupMenu.style.top = event.pageY + "px"; }); // Hide the popup menu when clicking outside of it window.addEventListener("click", function(event) { if (event.target !== video) { popupMenu.style.display = "none"; } }); loopOption.addEventListener("click", function() { video.loop = !video.loop; if (video.loop) { alert("Looped!"); } else { alert("unlooped!") } }); speedOption.addEventListener("click", function() { var currentSpeed = video.playbackRate; var newSpeed = getNextSpeed(currentSpeed); video.playbackRate = newSpeed; speedOption.innerHTML = " Speed: " + newSpeed.toFixed(2) + "x"; }); function getNextSpeed(currentSpeed) { if (currentSpeed === 2) { return 0.25; } else if (currentSpeed === 0.25) { return 0.5; } else if (currentSpeed === 0.5) { return 0.75; } else if (currentSpeed === 0.75) { return 1; } else { return 2; } } // @license-end