Initial curated chimera source from a8ae5b1db07fb49926c94585e2718e5130330974

This commit is contained in:
Public Source Publisher committed 2026-10-01 01:38:08 +02:00
commit c737a37f71
531 files changed
+119270

No files matched your search

+1
View File
@@ -0,0 +1 @@
!function(){"use strict";if(window.pork)return;let e=null;const t=fetch("/api/auth/status",{credentials:"same-origin"}).then(async t=>{const a=await t.json();if(!a.authenticated)throw location.replace("/server-login.html"),new Error("Authentication required");return e=a.csrfToken,a}),a=new Map;let o=null;function s(e){let t="";for(let a=0;a<e.length;a+=32768)t+=String.fromCharCode(...e.subarray(a,a+32768));return btoa(t)}function r(e){if(null==e)return e;if(e instanceof ArrayBuffer)return{__porkBinary:!0,base64:s(new Uint8Array(e))};if(ArrayBuffer.isView(e))return{__porkBinary:!0,base64:s(new Uint8Array(e.buffer,e.byteOffset,e.byteLength))};if(Array.isArray(e))return e.map(e=>r(e));if("object"==typeof e){const t={};for(const[a,o]of Object.entries(e))t[a]=r(o);return t}return e}function i(e){if(!e||"object"!=typeof e)return e;if(!0===e.__porkBinary&&"string"==typeof e.base64)return function(e){const t=atob(e),a=new Uint8Array(t.length);for(let e=0;e<t.length;e++)a[e]=t.charCodeAt(e);return a}(e.base64);if(Array.isArray(e))return e.map(e=>i(e));const t={};for(const[a,o]of Object.entries(e))t[a]=i(o);return t}async function n(a,...o){await t;const s=await fetch(`/api/commands/${encodeURIComponent(a)}`,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json","X-CSRF-Token":e},body:JSON.stringify({args:r(o)})});if(401===s.status)throw location.replace("/server-login.html"),new Error("Authentication required");const n=await s.json();if(!n.ok){const e=new Error(n.error||"IPC error");throw e.status=s.status,e.code=n.code||"COMMAND_FAILED",e.expected=["NOT_CONFIGURED","UNAVAILABLE","UPSTREAM_UNAVAILABLE"].includes(e.code),e}return i(n.result)}async function p(a,{method:o="GET",body:s}={}){await t;const r={"X-CSRF-Token":e};void 0!==s&&(r["Content-Type"]="application/json");const i=await fetch(a,{method:o,credentials:"same-origin",headers:r,body:void 0===s?void 0:JSON.stringify(s)});if(401===i.status)throw location.replace("/server-login.html"),new Error("Authentication required");const n=await i.json();if(!i.ok||!1===n.ok)throw new Error(n.error||`HTTP ${i.status}`);return n}function c(e){return"string"==typeof e&&e.startsWith("pork-cache://")?"/pork-cache/"+e.slice(13):e}async function l(e){const t=await e;if(t?.downloadUrl){const e=document.createElement("a");e.href=t.downloadUrl,e.download=t.filename||"",e.style.display="none",document.body.appendChild(e),e.click(),e.remove()}return t}async function m(e){const t=await l(e);return t?.filename||t}function d(e=""){return new Promise((t,a)=>{const o=document.createElement("input");o.type="file",o.accept=e,o.style.display="none",o.addEventListener("change",async()=>{try{const e=o.files?.[0];t(e?{filename:e.name,data:new Uint8Array(await e.arrayBuffer())}:null)}catch(e){a(e)}finally{o.remove()}},{once:!0}),o.addEventListener("cancel",()=>{o.remove(),t(null)},{once:!0}),document.body.appendChild(o),o.click()})}function u(e=""){return new Promise((t,a)=>{const o=document.createElement("input");o.type="file",o.multiple=!0,o.accept=e,o.style.display="none",o.addEventListener("change",async()=>{try{const e=[...o.files||[]];t(await Promise.all(e.map(async e=>({name:e.name,data:new Uint8Array(await e.arrayBuffer())}))))}catch(e){a(e)}finally{o.remove()}},{once:!0}),o.addEventListener("cancel",()=>{o.remove(),t([])},{once:!0}),document.body.appendChild(o),o.click()})}function y(e,t){const a=window.prompt(`${e}\n\nGebruik een pad dat als volume in de Chimera-container is gekoppeld.`,t||"/data");return Promise.resolve(null!=a&&String(a).trim()?String(a).trim():null)}function h(e){const t=Object.getOwnPropertyDescriptor(e,"src");if(!t||!t.set)return;const a=t.set;Object.defineProperty(e,"src",{...t,set(e){a.call(this,c(e))}})}!function e(){const t="https:"===location.protocol?"wss:":"ws:";o=new WebSocket(`${t}//${location.host}/ws`),o.onmessage=e=>{try{const{channel:t,args:o}=JSON.parse(e.data),s=a.get(t);if(s)for(const e of s)e(...o||[])}catch(e){}},o.onclose=()=>setTimeout(e,2e3),o.onerror=()=>{try{o.close()}catch(e){}}}(),h(HTMLVideoElement.prototype),h(HTMLImageElement.prototype);const g=Element.prototype.setAttribute;Element.prototype.setAttribute=function(e,t){return"src"===e&&(t=c(t)),g.call(this,e,t)},window.pork={isWebMode:!0,minimize:()=>{},maximize:()=>{},close:()=>{},getSettings:()=>n("settings:get"),setSettings:e=>n("settings:set",e),isAdmin:()=>Promise.resolve(!0),ftpConnect:e=>n("ftp:connect",e),ftpDisconnect:()=>n("ftp:disconnect"),ftpStatus:()=>n("ftp:status"),ftpScan:()=>n("ftp:scan"),ftpDownload:e=>n("ftp:download",e),ftpDownloadFolder:e=>n("ftp:download-folder",{game_id:e}),ftpUpload:e=>n("ftp:upload",e),ftpInstallPfs:e=>n("ftp:install-pfs",e),ftpListDir:e=>n("ftp:list-dir",{path:e}),ftpFindGame:e=>n("ftp:find-game",{game_id:e}),ftpDeleteGame:(e,t)=>n("ftp:delete-game",{game_id:e,confirmation:t}),ftpDownloadFile:e=>n("ftp:download-file",{remotePath:e}),ftpDeleteFile:(e,t)=>n("ftp:delete-file",{remotePath:e,confirmation:t}),listGamesLine truncated