/** * Code Manager Loader Script * Version: 1.0.0 * Built by P&P Private Limited */ (function(window, document, userId) { 'use strict'; // Prevent double-loading if (window.PP_LOADED) return; window.PP_LOADED = true; var API_URL = 'https://live.ytprakash.in/api/snippets.php?id='; function injectCode(snippet) { if (!snippet.active) return; var target = snippet.location === 'head' ? document.head : document.body; var position = snippet.position || 'beforeend'; try { if (snippet.type === 'html') { target.insertAdjacentHTML(position, snippet.code); } else if (snippet.type === 'css') { var style = document.createElement('style'); style.textContent = snippet.code; target.appendChild(style); } else { var script = document.createElement('script'); script.textContent = snippet.code; target.appendChild(script); } console.log('✅ Code Manager: Loaded snippet - ' + snippet.name); } catch(e) { console.warn('âš ī¸ Code Manager: Error loading snippet - ' + snippet.name, e); } } function loadSnippets() { fetch(API_URL + userId, { method: 'GET', mode: 'cors', cache: 'no-cache', headers: { 'Accept': 'application/json' } }) .then(function(response) { if (!response.ok) { throw new Error('HTTP ' + response.status); } return response.json(); }) .then(function(data) { console.log('✅ Code Manager: Connected successfully'); console.log('đŸ“Ļ Loading ' + (data.count || 0) + ' snippets...'); if (data.snippets && data.snippets.length) { data.snippets.forEach(injectCode); console.log('✅ Code Manager: All snippets loaded!'); } else { console.log('â„šī¸ Code Manager: No active snippets found'); } }) .catch(function(err) { console.error('❌ Code Manager Error:', err.message); console.log('API URL:', API_URL + userId); }); } // Load when DOM is ready if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', loadSnippets); } else { loadSnippets(); } })(window, document, new URLSearchParams(document.currentScript.src.split('?')[1]).get('id'));