כתבתי [AI] גרסה שעובדת מעולה
אבל לוקח קצת זמן עד שהיא מסיימת, ממש כמה דקות [לעשרות קבצים]
הסימניה מבקשת הרשאת גישה ליצירת קבצים, ויוצרת תיקיות ומורידה את כל הקבצים באותו סדר עץ התיקיות שהם באתר.
javascript:(async()=>{if(document.querySelector("html").className.includes("translated"))return alert("⚠ בטל תרגום דפדפן.");const sleep=ms=>new Promise(r=>setTimeout(r,ms));const nav=document.querySelector('nav.flex-1.overflow-y-auto');if(!nav)return alert("❌ לא נמצא עץ קבצים. ודא שאתה בלשונית 'Code'.");let root;try{root=await window.showDirectoryPicker({mode:"readwrite"})}catch{return}const panel=document.createElement("div");panel.style="position:fixed;top:12px;left:50%;transform:translateX(-50%);width:450px;background:#111;color:#fff;font:13px system-ui;padding:16px;border-radius:14px;z-index:999999;direction:rtl;box-shadow:0 10px 30px rgba(0,0,0,0.8);border:1px solid #333";panel.innerHTML=%60<div style="display:flex;gap:10px;align-items:center;margin-bottom:12px"><div style="width:16px;height:16px;border:3px solid #444;border-top-color:#4caf50;border-radius:50%;animation:spin 1s linear infinite"></div><b style="font-size:15px">Base44 Extractor V13</b></div><div id="stg" style="color:#aaa;margin-bottom:8px">מאתחל...</div><div style="background:#222;height:12px;border-radius:6px;overflow:hidden"><div id="bar" style="height:100%;width:0%;background:#4caf50;transition:width 0.3s"></div></div><div id="pct" style="margin-top:6px;color:#888;font-size:12px">0%</div><div id="logArea" style="margin-top:10px;height:150px;background:#000;border:1px solid #444;border-radius:6px;overflow-y:auto;font-family:monospace;font-size:11px;padding:6px;text-align:left;direction:ltr;white-space:nowrap;color:#0f0;"></div><style>@keyframes spin{to{transform:rotate(360deg)}}</style>%60;document.body.appendChild(panel);const stage=t=>{panel.querySelector("#stg").textContent=t;};let fullLog="";const logFn=m=>{console.log(m);fullLog+=m+"\r\n";const l=panel.querySelector("#logArea");if(l){l.innerHTML+='<div>> '+m+'</div>';l.scrollTop=l.scrollHeight;}};const progress=(d,t)=>{const p=Math.floor((d/t)*100);panel.querySelector("#bar").style.width=p+"%";panel.querySelector("#pct").textContent=%60${p}% (${d} מתוך ${t} קבצים)%60;};logFn("System Initialized V13 - Base44 Native Engine.");const getNodes=()=>{return Array.from(nav.querySelectorAll("button")).map(btn=>{const span=btn.querySelector("span.truncate");if(!span)return null;const text=span.innerText.trim();const pl=parseInt(btn.style.paddingLeft||"8");const chevron=btn.querySelector("svg.lucide-chevron-down");const isFolder=!!chevron;const isClosed=isFolder&&chevron.classList.contains("-rotate-90");return{btn,text,depth:pl,isFolder,isClosed,isFile:!isFolder}}).filter(Boolean);};const scrollTop=async()=>{logFn("Scrolling tree to top...");nav.scrollTop=0;await sleep(300);};stage("פותח תיקיות (Native)...");await scrollTop();let expStable=0,attempts=new Map();while(expStable<5){const nodes=getNodes();let expanded=!1;for(const n of nodes){if(n.isClosed){const tries=attempts.get(n.text)||0;if(tries<3){attempts.set(n.text,tries+1);logFn(%60Expanding folder: ${n.text}%60);n.btn.scrollIntoView({block:"center"});await sleep(200);n.btn.click();await sleep(500);expanded=!0;expStable=0;break;}}}if(!expanded){const oldScroll=nav.scrollTop;nav.scrollTop+=300;await sleep(300);if(nav.scrollTop===oldScroll)expStable++;else expStable=0;}}stage("ממפה פרויקט...");await scrollTop();let cStk=[],mappedFiles=new Map(),mapStable=0;while(mapStable<5){const nodes=getNodes();for(const n of nodes){while(cStk.length>0&&cStk[cStk.length-1].depth>=n.depth)cStk.pop();cStk.push(n);if(n.isFile){const fullPath=cStk.map(p=>p.text).join("/");if(!mappedFiles.has(fullPath)){const saveName=n.text.includes(".")?n.text:n.text+".js";mappedFiles.set(fullPath,{name:saveName,path:fullPath,dir:cStk.slice(0,-1).map(p=>p.text)});logFn(%60Mapped: ${fullPath}%60);}}}const oldScroll=nav.scrollTop;nav.scrollTop+=300;await sleep(300);if(nav.scrollTop===oldScroll)mapStable++;else mapStable=0;}const fList=Array.from(mappedFiles.values());logFn(%60Mapping complete. Found ${fList.length} files.%60);if(!fList.length){panel.remove();return alert("לא נמצאו קבצים. נסה לרענן את העמוד.");}const sanitize=s=>s.replace(/[<>:"\/\\|?*]/g,"_");let saved=0,failed=[];for(let i=0;i<fList.length;i++){const file=fList[i];stage(%60מוריד: ${file.name}%60);progress(i,fList.length);logFn(%60--- Target: ${file.path} ---%60);await scrollTop();let tgt=null,sStable=0;cStk=[];while(sStable<5&&!tgt){const nodes=getNodes();for(const n of nodes){while(cStk.length>0&&cStk[cStk.length-1].depth>=n.depth)cStk.pop();cStk.push(n);const cp=cStk.map(p=>p.text).join("/");if(cp===file.path){tgt=n.btn;break;}}if(tgt)break;const oldScroll=nav.scrollTop;nav.scrollTop+=300;await sleep(300);if(nav.scrollTop===oldScroll)sStable++;else sStable=0;}if(tgt){tgt.scrollIntoView({block:"center"});await sleep(200);logFn(%60Clicking file...%60);tgt.click();await sleep(2000);let content="";try{if(window.monaco?.editor){const m=window.monaco.editor.getModels();if(m.length){const md=m.find(x=>x.uri.path.toLowerCase().endsWith(file.name.toLowerCase()))||m[0];content=md.getValue();if(content)logFn(%60Read from Monaco API.%60);}}}catch(e){logFn(%60Monaco error: ${e.message}%60);}if(content){try{let dH=root;for(const p of file.dir)dH=await dH.getDirectoryHandle(sanitize(p),{create:true});const fH=await dH.getFileHandle(sanitize(file.name),{create:true});const w=await fH.createWritable();await w.write(content);await w.close();saved++;logFn(%60Saved: ${file.name}%60);}catch(e){logFn(%60Save error: ${e.message}%60);failed.push(file.path);}}else{logFn(%60ERROR: No content.%60);failed.push(file.path);}}else{logFn(%60ERROR: Node not found in tree.%60);failed.push(file.path);}}progress(fList.length,fList.length);stage("הושלם ✅");logFn(%60Done! Saved ${saved}/${fList.length}%60);try{const logFH=await root.getFileHandle("extraction_log.txt",{create:true});const logW=await logFH.createWritable();await logW.write(fullLog);await logW.close();}catch(e){}setTimeout(()=>{panel.remove();alert(%60✅ החילוץ הסתיים!\nנשמרו ${saved}/${fList.length} קבצים.\n${failed.length?"נכשלו:\n"+failed.join("\n"):""}%60);},1500);})();