invidious-redirect/build/static/js/main.min.js

2 lines
3.7 KiB
JavaScript

"use strict";function _createForOfIteratorHelper(o,allowArrayLike){var it;if(typeof Symbol==="undefined"||o[Symbol.iterator]==null){if(Array.isArray(o)||(it=_unsupportedIterableToArray(o))||allowArrayLike&&o&&typeof o.length==="number"){if(it)o=it;var i=0;var F=function F(){};return{s:F,n:function n(){if(i>=o.length)return{done:true};return{done:false,value:o[i++]}},e:function e(_e){throw _e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var normalCompletion=true,didErr=false,err;return{s:function s(){it=o[Symbol.iterator]()},n:function n(){var step=it.next();normalCompletion=step.done;return step},e:function e(_e2){didErr=true;err=_e2},f:function f(){try{if(!normalCompletion&&it.return!=null)it.return()}finally{if(didErr)throw err}}}}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i]}return arr2};(function(){var q=function q(s){return document.querySelector(s)};var qa=function qa(s){return document.querySelectorAll(s)};function createElement(tag){var properties=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var children=arguments.length>2&&arguments[2]!==undefined?arguments[2]:[];var e=document.createElement(tag);for(var _i=0,_Object$keys=Object.keys(properties);_i<_Object$keys.length;_i++){var key=_Object$keys[_i];e[key]=properties[key]}var _iterator=_createForOfIteratorHelper(children),_step;try{for(_iterator.s();!(_step=_iterator.n()).done;){var child=_step.value;e.appendChild(child)}}catch(err){_iterator.e(err)}finally{_iterator.f()}return e}function shuffle(array){for(var i=0;i<array.length;i++){var j=Math.floor(Math.random()*(array.length-i))+i;var _ref=[array[j],array[i]];array[i]=_ref[0];array[j]=_ref[1]}return array}function request(url){return new Promise(function(resolve,reject){var xhr=new XMLHttpRequest;xhr.addEventListener("readystatechange",function(){if(xhr.readyState===4){if(xhr.status===200){resolve(JSON.parse(xhr.response))}}});xhr.open("GET",url);xhr.send()})}var destinationPath=window.location.href.slice(window.location.origin.length);q("#watch-on-youtube").href="https://www.youtube.com"+destinationPath;qa("[data-loading-message]").forEach(function(e){return e.textContent=e.getAttribute("data-loading-message")});request("https://instances.invidio.us/instances.json?sort_by=type,health").then(function(root){shuffle(root);root.map(function(entry){var healthKnown=!!entry[1].monitor;return{name:entry[0],details:entry[1],health:+(healthKnown?entry[1].monitor.dailyRatios[0].ratio:95),healthKnown:healthKnown}}).filter(function(entry){return entry.details.type==="https"&&entry.health>0}).sort(function(a,b){return b.health-a.health}).forEach(function(entry){var target=entry.details.uri.replace(/\/*$/,"")+destinationPath;var healthUnknown=entry.healthKnown?"":"health-unknown ";var health=entry.healthKnown?entry.health.toFixed(0):"(unknown)";q("#instances-tbody").appendChild(createElement("tr",{},[createElement("td",{textContent:entry.name}),createElement("td",{className:"column-center "+healthUnknown,textContent:health}),createElement("td",{className:"column-center"},[createElement("a",{href:target,textContent:"Go \u2192"})])]))});qa(".loading").forEach(function(e){return e.remove()})})})();
//# sourceMappingURL=/static/js/main.min.js.map