MCPcopy Create free account
hub / github.com/altic-dev/Pilot / getInjectionScript

Method getInjectionScript

src/lib/picker-injector.ts:100–131  ·  view source on GitHub ↗

* Get the injection script that should be added to the iframe * * This returns an HTML script tag that will load the picker when inserted * into the iframe document.

(baseUrl: string = '')

Source from the content-addressed store, hash-verified

98 * into the iframe document.
99 */
100 static getInjectionScript(baseUrl: string = ''): string {
101 return `
102 <script id="__pilot-picker-injector">
103 (function() {
104 if (window.__pilotPickerInjected) {
105 console.log('[Pilot] Picker already injected');
106 return;
107 }
108
109 window.__pilotPickerInjected = true;
110
111 const script = document.createElement('script');
112 script.src = '${baseUrl}/picker/react-component-picker.js';
113 script.id = '__pilot-picker-script';
114
115 script.onload = function() {
116 console.log('[Pilot] React component picker loaded successfully');
117 };
118
119 script.onerror = function(error) {
120 console.error('[Pilot] Failed to load picker script:', error);
121 window.parent.postMessage({
122 type: 'picker-load-error',
123 error: 'Failed to load picker script'
124 }, '*');
125 };
126
127 document.head.appendChild(script);
128 })();
129 </script>
130 `;
131 }
132
133 /**
134 * Get the inline script content for direct injection

Callers 1

POSTFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected