This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greasyfork.org/scripts/542296/1622837/TriX%20Addons%20Library.js
// ==UserScript==
// @name TriX Addons Library
// @namespace https://github.com/YourUsername/TriX-Executor
// @version 1.1.1
// @description The Add-on Store UI and logic for the TriX Executor.
// @author You
// @license MIT
// ==/UserScript==
const TriX_Addons = (function() {
'use strict';
let _GM;
const ADDON_MANIFEST_URL = 'https://raw.githubusercontent.com/COURTESYCOIL/TrixScripts/refs/heads/main/trix%20addons';
const AddonStore={isInitialized:!1,manifestCache:null,init(gmFunctions){_GM=gmFunctions,this.fetchAndCacheManifest()},fetchAndCacheManifest(){if(!ADDON_MANIFEST_URL.startsWith("https://"))return console.error("[TriX Addons] Manifest URL not set."),void(this.manifestCache={error:!0,message:"Manifest URL not configured by developer."});_GM["GM.xmlHttpRequest"]({method:"GET",url:ADDON_MANIFEST_URL,onload:e=>{try{this.manifestCache=JSON.parse(e.responseText),console.log("[TriX Addons] Manifest pre-loaded and cached.")}catch(e){this.manifestCache={error:!0,message:"Could not parse addon manifest."}}},onerror:()=>{this.manifestCache={error:!0,message:"Could not fetch addon manifest."}}})},show(){this.isInitialized||(this.injectCSS(),this.injectHTML(),this.attachEventListeners(),this.isInitialized=!0);const e=document.getElementById("trix-addons-modal-overlay");e.style.display="flex",setTimeout(()=>e.classList.add("visible"),10),this.buildUI()},buildUI(){const e=document.getElementById("addons-list");this.manifestCache?this.manifestCache.error?e.innerHTML=`<p style="color:#f7768e;">Error: ${this.manifestCache.message}</p>`:this.buildCards(this.manifestCache):(e.innerHTML="<p>Fetching latest addons...</p>",this.fetchAndCacheManifest(),setTimeout(()=>this.buildUI(),1e3))},buildCards(e){const t=document.getElementById("addons-list");t.innerHTML="",e.addons.forEach(e=>{const i=document.createElement("div");i.className="addon-card",i.innerHTML=`<h4>${e.name}</h4><p>${e.description}</p><div class="addon-controls"><select class="addon-version-select" id="select-${e.id}"><option value="">Select a version...</option></select><button class="addon-install-btn" id="install-${e.id}" disabled>Install</button></div>`,t.appendChild(i);const s=document.getElementById(`select-${e.id}`),o=document.getElementById(`install-${e.id}`);e.versions.forEach(e=>{const t=document.createElement("option");t.value=e.url,t.textContent=e.version,s.appendChild(t)}),s.onchange=()=>{o.disabled=!s.value},o.onclick=()=>{this.install(e.name,s.value,o)}})},injectCSS:function(){_GM.GM_addStyle(`#trix-addons-modal-overlay{position:fixed;top:0;left:0;width:100%;height:100%;background-color:rgba(0,0,0,.7);z-index:1000001;display:none;align-items:center;justify-content:center;backdrop-filter:blur(5px);animation:fadeIn .3s ease}@keyframes fadeIn{from{opacity:0}to{opacity:1}}#trix-addons-modal{background-color:var(--trix-bg-secondary,#2d2d2d);width:700px;max-width:90vw;max-height:80vh;border-radius:8px;box-shadow:0 8px 32px rgba(0,0,0,.5);display:flex;flex-direction:column;transform:scale(.95);opacity:0;transition:transform .3s ease,opacity .3s ease}#trix-addons-modal-overlay.visible #trix-addons-modal{transform:scale(1);opacity:1}.addons-header{padding:15px 20px;font-size:20px;font-weight:700;border-bottom:1px solid var(--trix-border-color,#4a4a4a);display:flex;justify-content:space-between;align-items:center;color:var(--trix-text-primary,#d4d4d4)}.addons-header .close-btn{font-size:24px;cursor:pointer;color:var(--trix-text-secondary,#8c8c8c);transition:color .2s}.addons-header .close-btn:hover{color:var(--trix-accent-color,#00aeff)}#addons-list{padding:20px;overflow-y:auto;display:flex;flex-direction:column;gap:15px}.addon-card{background-color:var(--trix-bg-primary,#1e1e1e);border:1px solid var(--trix-border-color,#4a4a4a);border-radius:6px;padding:15px;display:flex;flex-direction:column;gap:10px}.addon-card h4{margin:0;color:var(--trix-accent-color,#00aeff)}.addon-card p{margin:0;font-size:14px;color:var(--trix-text-secondary,#8c8c8c)}.addon-controls{display:flex;gap:10px;margin-top:10px}.addon-version-select{flex-grow:1;background-color:var(--trix-bg-tertiary,#3c3c3c);border:1px solid var(--trix-border-color,#4a4a4a);color:var(--trix-text-primary,#d4d4d4);padding:8px 12px;border-radius:5px}.addon-install-btn{background-color:#28a745;border:1px solid #1c7430;font-weight:700;color:#fff;padding:8px 15px;cursor:pointer;border-radius:5px}.addon-install-btn:disabled{background-color:#414868;border-color:#414868;color:#8c8c8c;cursor:not-allowed}`)},
injectHTML:function(){const e=`<div id="trix-addons-modal-overlay"><div id="trix-addons-modal"><div class="addons-header"><span>Add-on Store</span><span class="close-btn">✕</span></div><div id="addons-list"><p>Loading addons...</p></div></div></div>`;document.body.insertAdjacentHTML("beforeend",e)},
attachEventListeners:function(){document.querySelector("#trix-addons-modal .close-btn").addEventListener("click",()=>this.hide())},
hide:function(){const e=document.getElementById("trix-addons-modal-overlay");e.classList.remove("visible"),setTimeout(()=>{e.style.display="none"},300)},
install:function(e,t,i){TriX_Core.Executor.log(`Installing addon "${e}"...`,"info"),i.disabled=!0,i.textContent="Installing...",_GM["GM.xmlHttpRequest"]({method:"GET",url:t,onload:t=>{TriX_Core.Executor.execute(t.responseText),TriX_Core.Executor.log(`Successfully installed "${e}"!`,"info"),this.hide()},onerror:()=>{TriX_Core.Executor.log(`Failed to install "${e}". Could not fetch script.`,"error"),i.disabled=!1,i.textContent="Install"}})}
};
return AddonStore;
})();