`;
return f
}
suicidalInterval(callback, ms) {
function die() {
console.log("I'm ending myself!");
clearInterval(interval);
}
const interval = setInterval(() => {
callback(die);
}, ms);
}
}
/* harmony default export */ const ViewXtend = (ViewXtendAPI);
;// CONCATENATED MODULE: ./src/utils/Plugins.js
class Plugins {
constructor() {}
loadFromLocalStorage(key, defaultValue) {
// Check if the key exists in localStorage
if (localStorage.hasOwnProperty(key)) {
try {
// Parse the JSON data from localStorage
const data = JSON.parse(localStorage.getItem(key));
// Check if the parsed data is an object (JSON)
if (typeof data === 'object' && data !== null) {
return data;
} else {
// Handle the case where the data is not a valid JSON object
console.error('Data in localStorage is not a valid JSON object.');
}
} catch (error) {
// Handle any errors that occur during JSON parsing
console.error('Error parsing data from localStorage:', error);
}
}
return defaultValue;
}
load_plugins() {
const pluginsData = this.loadFromLocalStorage('plugins', {});
for (const key in pluginsData) {
if (pluginsData.hasOwnProperty(key)) {
const value = pluginsData[key];
// Check if the URL matches the regex pattern
const regex = new RegExp(value['runs_on']);
const currentURL = window.location.href;
if (regex.test(currentURL)) {
const script = document.createElement('script');
script.src = value['url'];
document.head.appendChild(script);
}
}
}
}
}
/* harmony default export */ const utils_Plugins = (Plugins);
;// CONCATENATED MODULE: ./src/web/index.html
// Module
var code = "
ViewXtend Plugins
<" + "script>const ld=()=>{let e=localStorage.getItem(\"plugins\");if(e){const t=JSON.parse(e);for(const e in t){t[e];const n=document.getElementById(`plugin-${e}`);n&&(n.checked=!0)}}};let container=document.getElementsByClassName(\"vxt-grid-container\")[0];var xhr=new XMLHttpRequest;xhr.onreadystatechange=function(){4===xhr.readyState&&200===xhr.status?(JSON.parse(xhr.responseText).forEach((function(e){const t=document.createElement(\"div\");t.className=\"vxt-card\";const n=document.createElement(\"div\");n.className=\"vxt-switch\";const s=document.createElement(\"input\");s.className=\"tgl tgl-skewed\",s.type=\"checkbox\",s.id=`plugin-${e.id}`,s.addEventListener(\"click\",(()=>{switch_click(e.id,e.url,e.runs_on)}));const a=document.createElement(\"label\");a.className=\"tgl-btn\",a.setAttribute(\"data-tg-off\",\"OFF\"),a.setAttribute(\"data-tg-on\",\"ON\"),a.setAttribute(\"for\",`plugin-${e.id}`);const c=document.createElement(\"div\");c.className=\"vxt-title\",c.textContent=e.name;const l=document.createElement(\"div\");l.className=\"vxt-description\",l.textContent=e.description,n.appendChild(s),n.appendChild(a),t.appendChild(n),t.appendChild(c),t.appendChild(l),container.appendChild(t)})),ld()):4===xhr.readyState&&200!==xhr.status&&console.error(\"Failed to load data.json\")},xhr.open(\"GET\",\"https://viewxtend.pages.dev/plugins/registry.json\",!0),xhr.send();const switch_click=(e,t,n)=>{if(document.getElementById(`plugin-${e}`).checked){const s=localStorage.getItem(\"plugins\"),a=s?JSON.parse(s):{};a[e]={url:t,runs_on:n},localStorage.setItem(\"plugins\",JSON.stringify(a))}else{const t=localStorage.getItem(\"plugins\"),n=t?JSON.parse(t):{};n.hasOwnProperty(e)&&(delete n[e],localStorage.setItem(\"plugins\",JSON.stringify(n)))}}<" + "/script> ";
// Exports
/* harmony default export */ const web = (code);
;// CONCATENATED MODULE: ./src/index.js
window.ViewXtendAPI_direct = ViewXtend;
window.ViewXtendAPI = new ViewXtend;
/*
get_premium_flag_logo(alpha2_code) {
return `
`
}
*/
const vx_main_fun = () => {
if (window.location.pathname == "/plugins") {
document.open();
document.write(web);
document.close();
return;
}
let API = new ViewXtend();
let PLG = new utils_Plugins();
PLG.load_plugins();
setInterval(() => {
try {
var parentElement = document.querySelector("#sections > yt-multi-page-menu-section-renderer:nth-child(1)").querySelector("#items");
if (parentElement.childNodes.length == 4) {
var firstItem = parentElement.firstElementChild;
parentElement.insertBefore(API.create_plugins_button(), firstItem.nextSibling);
var icon = document.querySelectorAll("#content-icon > yt-icon")[1];
icon.innerHTML = `