diff --git a/javascript/main.js b/javascript/main.js index 6e1df25a..81015936 100644 --- a/javascript/main.js +++ b/javascript/main.js @@ -1738,7 +1738,7 @@ const se=2; } `,container:e` height: calc(100vh - ${n}px); - `}))),Zoe=["txt2img","img2img"],eae=["textual_inversion","hypernetworks","checkpoints","lora","lycoris"],tae={checkpoints:"ckp",hypernetworks:"hyper",lora:"lora",lycoris:"lycoris",textual_inversion:"ti"},nae=new Set(["🌐","💡","🏷️"]),rae="lobeDone",oae=(e,t)=>{t?(e.style.display="inline",e.style.fontSize="100%",e.style.position="static",e.style.backgroundImage="none"):(e.style.fontSize="15px",e.style.margin="0")};function aae(e){return null==e}const iae=()=>{let e,t,n=0;const r=()=>{setTimeout(t,2e3)};return t=()=>{let t=0;const o=setInterval((()=>{var a;console.debug("🤯 [civitai helper] update card for civitai");const i=document.querySelector("#txt2img_lora_cards");if(i||t>10){if(e!==i){n=0,e=i;for(const e of Zoe){const t=document.querySelectorAll(`#${e}_extra_tabs .tab-nav button`);if(t)for(const e of t)e.removeEventListener("click",r),e.addEventListener("click",r)}}const s=null==(a=(()=>{var e;if(!document.querySelector("#tab_civitai_helper"))return;const t=getTranslation("replace preview")||"replace preview",n=document.querySelector("#ch_always_display_ckb input"),r=document.querySelector("#ch_show_btn_on_thumb_ckb input"),o=(null==n?void 0:n.checked)||!1,a=(null==r?void 0:r.checked)||!1;let i,s,l,c,u,d,f,p,h,g="",m=!1,b=!1;const v=[];for(const y of Zoe)for(const n of eae){if(p=tae[n],i=`${y}_${n}_cards`,s=document.querySelector(`#${i}`),aae(s))continue;b=s.classList.contains("extra-network-thumbs"),h=s.querySelectorAll(".card");const r=!!document.querySelector(`#${i}_html .pending`);if((null==h?void 0:h.length)&&!r){v.push(n);for(const n of h){if("1"===n.dataset[rae])break;if(n.dataset[rae]="1",n.querySelectorAll(".actions .additional a").length>2)continue;if(l=n.querySelector(".metadata-button"),c=n.querySelector(".actions .additional"),d=n.querySelector(".actions .additional ul"),aae(d)&&(d=document.createElement("ul"),c.append(d)),u=n.querySelector(".actions .additional a"),aae(u)&&(u=document.createElement("a"),c.append(u)),null==(e=d.querySelector("br"))||e.remove(),b&&c){if(c.style.display=void 0,!a){d.style.background=void 0;const e=d.querySelectorAll("a");if(!(null==e?void 0:e.length))continue;for(const n of e)n.style.display=void 0,nae.has(n.innerHTML)?n.remove():(n.innerHTML=t,n.style.display=void 0,n.style.fontSize=void 0,n.style.position=void 0,n.style.backgroundImage=void 0);continue}d.style.background="rgba(0, 0, 0, 0.8)"}else c.style.display=o?"block":void 0;if("🖼️"!==u.innerHTML&&(m=!0,u.innerHTML="🖼️",oae(u,b)),!m)continue;if(f=n.querySelector(".actions .additional .search_term"),!f)return;if(g=f.innerHTML,!g)continue;const r=document.createElement("a");r.href="#",r.innerHTML="🌐",oae(r,b),r.title="Open this model's civitai url",r.setAttribute("onclick",`open_model_url(event, '${p}', '${g}')`);const i=document.createElement("a");i.href="#",i.innerHTML="💡",oae(i,b),i.title="Add trigger words to prompt",i.setAttribute("onclick",`add_trigger_words(event, '${p}', ', ${g}')`);const s=document.createElement("a");s.href="#",s.innerHTML="🏷️",oae(s,b),s.title="Use prompt from preview image",s.setAttribute("onclick",`use_preview_prompt(event, '${p}', '${g}')`),d.append(r),b&&l&&d.append(document.createElement("br")),d.append(i),d.append(s)}}else!r&&s.querySelector(".nocards")&&v.push(n)}return v})())?void 0:a.length;"number"==typeof s&&s10||!i||s>=eae.length||s>n)&&(clearInterval(o),n=s??n)}t++}),2e3)},t()},sae=B.memo((()=>{const e=B.useRef(null),t=B.useRef(null),[n,r]=B.useState(!0),o=p4(u4,sJ),a=p4(d4,Af),[i,s]=B.useState(o.extraNetworkCardSize||86),{styles:l}=Joe({size:i});return B.useEffect((()=>{var n,a;if(console.time("🤯 [layout] inject - ExtraNetworkSidebar"),o.enableExtraNetworkSidebar){const o=gradioApp().querySelectorAll("#txt2img_extra_tabs > .tab-nav > button")[1],i=gradioApp().querySelectorAll("#img2img_extra_tabs > .tab-nav > button")[1];o&&o.click(),i&&i.click();const s=gradioApp().querySelector("div#tab_txt2img"),l=gradioApp().querySelector("div#txt2img_extra_tabs"),c=l.querySelectorAll("div.tabitem.gradio-tabitem")[0],u=gradioApp().querySelector("div#tab_img2img"),d=gradioApp().querySelector("div#img2img_extra_tabs"),f=d.querySelectorAll("div.tabitem.gradio-tabitem")[0];if(l&&d&&(null==(n=e.current)||n.append(l),c.id="txt2img_render",null==s||s.append(c),null==(a=t.current)||a.append(d),f.id="img2img_render",null==u||u.append(f)),document.querySelector(".extra-network-cards"))return iae(),void r(!1)}console.timeEnd("🤯 [layout] inject - ExtraNetworkSidebar")}),[]),VX((()=>{var e,t;console.time("🤯 [extranetwork] force reload");const n=document.querySelector("#txt2img_extra_refresh"),o=document.querySelector("#img2img_extra_refresh");n.click(),o.click(),r(!1);try{const n=null==(e=document.querySelector("#txt2img_extra_refresh"))?void 0:e.nextSibling;n&&(n.onclick=iae);const r=null==(t=document.querySelector("#img2img_extra_refresh"))?void 0:t.nextSibling;r&&(r.onclick=iae),iae()}catch(a){console.debug(a)}console.timeEnd("🤯 [extranetwork] force reload")}),2e3),Q.jsxs(Q.Fragment,{children:[Q.jsxs(qQ,{className:l.body,children:[n&&Q.jsx(IR,{active:!0}),Q.jsxs("div",{style:n?{display:"none"}:{},children:[Q.jsx("div",{id:"txt2img-extra-network-sidebar",ref:e,style:"tab_img2img"===a?{display:"none"}:{}}),Q.jsx("div",{id:"img2img-extra-network-sidebar",ref:t,style:"tab_img2img"===a?{}:{display:"none"}})]})]}),Q.jsxs(tJ,{children:[Q.jsx(KH,{icon:o.extraNetworkCardSizes(o.extraNetworkCardSize),size:{blockSize:24,fontSize:16}}),Q.jsx(Jz,{defaultValue:i,max:256,min:64,onChange:s,step:8,style:{flex:1},value:i})]})]})})),lae=B.memo((({headerHeight:e})=>{const{mobile:t}=WB(),n=p4(u4,sJ),[r,o]=B.useState(!t&&n.extraNetworkSidebarExpand),[a,i]=B.useState("fixed"===n.extraNetworkFixedMode),{styles:s,theme:l}=Joe({headerHeight:e}),{t:c}=H1();B.useEffect((()=>{t&&o(!1)}),[t]);const u=t||a?"fixed":"float";return Q.jsx(MQ,{defaultSize:{width:n.extraNetworkSidebarWidth},expand:r,minWidth:n.extraNetworkSidebarWidth,mode:u,onExpandChange:o,pin:a,placement:"right",children:Q.jsx(ZZ,{children:Q.jsxs(QQ,{className:s.container,style:"float"===u?{background:l.colorBgContainer,minWidth:n.extraNetworkSidebarWidth}:{minWidth:n.extraNetworkSidebarWidth},children:[Q.jsx(aJ,{pin:a,position:"right",setExpand:o,setPin:i,title:c("extraNetwork")}),Q.jsx(sae,{})]})})})})),cae=lae,uae=[{description:"AUTOMATIC111",openExternal:!0,title:"Stable Diffusion Webui",url:"https://github.com/AUTOMATIC1111/stable-diffusion-webui"},{description:"WebUI extension",openExternal:!0,title:"Controlnet",url:"https://github.com/Mikubill/sd-webui-controlnet"},{description:"Art models",openExternal:!0,title:"Civitai",url:"https://civitai.com/"},{description:"Artist Inspired Styles",openExternal:!0,title:"Cheat Sheet",url:"https://supagruen.github.io/StableDiffusion-CheatSheet"},{description:"Image Resizing",openExternal:!0,title:"Birme",url:"https://www.birme.net/?target_width=512&target_height=512"}],dae=[{icon:Q.jsx(PH,{icon:Uf,size:"small"}),openExternal:!0,title:"Report Bug",url:`${W1}/issues/new/choose`},{icon:Q.jsx(PH,{icon:Yf,size:"small"}),openExternal:!0,title:"Request Feature",url:`${W1}/issues/new/choose`}],fae=[{icon:Q.jsx(PH,{icon:Qf,size:"small"}),openExternal:!0,title:"GitHub",url:W1},{icon:Q.jsx(PH,{icon:Xf,size:"small"}),openExternal:!0,title:"Changelog",url:`${W1}/blob/main/CHANGELOG.md`}],pae=[{description:"Minifier ExtraNetwrok Covers",openExternal:!0,title:"✂️ Cover Minifier",url:"https://github.com/canisminor1990/sd-webui-cover-minifier"},{description:"OpenAI Chat Bot",openExternal:!0,title:"🤖 Lobe Chat",url:"https://chat.lobehub.com"},{description:"AIGC Components",openExternal:!0,title:"🍭 Lobe UI",url:"https://ui.lobehub.com"},{description:"AI Commit CLI",openExternal:!0,title:"💌 Lobe Commit",url:"https://github.com/lobehub/lobe-commit"}],hae=vH((({css:e})=>({footer:e` + `}))),Zoe=["txt2img","img2img"],eae=["textual_inversion","hypernetworks","checkpoints","lora","lycoris"],tae={checkpoints:"ckp",hypernetworks:"hyper",lora:"lora",lycoris:"lycoris",textual_inversion:"ti"},nae=new Set(["🌐","💡","🏷️"]),rae="lobeDone",oae=(e,t)=>{t?(e.style.display="inline",e.style.fontSize="100%",e.style.position="static",e.style.backgroundImage="none"):(e.style.fontSize="15px",e.style.margin="0")};function aae(e){return null==e}const iae=()=>{let e,t,n=0;const r=()=>{setTimeout(t,2e3)};return t=()=>{let t=0;const o=setInterval((()=>{var a;console.debug("🤯 [civitai helper] update card for civitai");const i=document.querySelector("#txt2img_lora_cards");if(i||t>10){if(e!==i){n=0,e=i;for(const e of Zoe){const t=document.querySelectorAll(`#${e}_extra_tabs .tab-nav button`);if(t)for(const e of t)e.removeEventListener("click",r),e.addEventListener("click",r)}}const s=null==(a=(()=>{var e;if(!document.querySelector("#tab_civitai_helper"))return;const t=getTranslation("replace preview")||"replace preview",n=document.querySelector("#ch_always_display_ckb input"),r=document.querySelector("#ch_show_btn_on_thumb_ckb input"),o=(null==n?void 0:n.checked)||!1,a=(null==r?void 0:r.checked)||!1;let i,s,l,c,u,d,f,p,h,g="",m=!1,b=!1;const v=[];for(const y of Zoe)for(const n of eae){if(p=tae[n],i=`${y}_${n}_cards`,s=document.querySelector(`#${i}`),aae(s))continue;b=s.classList.contains("extra-network-thumbs"),h=s.querySelectorAll(".card");const r=!!document.querySelector(`#${i}_html .pending`);if((null==h?void 0:h.length)&&!r){v.push(n);for(const n of h){if("1"===n.dataset[rae])break;if(n.dataset[rae]="1",n.querySelectorAll(".actions .additional a").length>2)continue;if(l=n.querySelector(".metadata-button"),c=n.querySelector(".actions .additional"),d=n.querySelector(".actions .additional ul"),aae(d)&&(d=document.createElement("ul"),c.append(d)),u=n.querySelector(".actions .additional a"),aae(u)&&(u=document.createElement("a"),c.append(u)),null==(e=d.querySelector("br"))||e.remove(),b&&c){if(c.style.display=void 0,!a){d.style.background=void 0;const e=d.querySelectorAll("a");if(!(null==e?void 0:e.length))continue;for(const n of e)n.style.display=void 0,nae.has(n.innerHTML)?n.remove():(n.innerHTML=t,n.style.display=void 0,n.style.fontSize=void 0,n.style.position=void 0,n.style.backgroundImage=void 0);continue}d.style.background="rgba(0, 0, 0, 0.8)"}else c.style.display=o?"block":void 0;if("🖼️"!==u.innerHTML&&(m=!0,u.innerHTML="🖼️",oae(u,b)),!m)continue;if(f=n.querySelector(".actions .additional .search_term"),!f)return;if(g=f.innerHTML,!g)continue;const r=document.createElement("a");r.href="#",r.innerHTML="🌐",oae(r,b),r.title="Open this model's civitai url",r.setAttribute("onclick",`open_model_url(event, '${p}', '${g}')`);const i=document.createElement("a");i.href="#",i.innerHTML="💡",oae(i,b),i.title="Add trigger words to prompt",i.setAttribute("onclick",`add_trigger_words(event, '${p}', '${g}')`);const s=document.createElement("a");s.href="#",s.innerHTML="🏷️",oae(s,b),s.title="Use prompt from preview image",s.setAttribute("onclick",`use_preview_prompt(event, '${p}', '${g}')`),d.append(r),b&&l&&d.append(document.createElement("br")),d.append(i),d.append(s)}}else!r&&s.querySelector(".nocards")&&v.push(n)}return v})())?void 0:a.length;"number"==typeof s&&s10||!i||s>=eae.length||s>n)&&(clearInterval(o),n=s??n)}t++}),2e3)},t()},sae=B.memo((()=>{const e=B.useRef(null),t=B.useRef(null),[n,r]=B.useState(!0),o=p4(u4,sJ),a=p4(d4,Af),[i,s]=B.useState(o.extraNetworkCardSize||86),{styles:l}=Joe({size:i});return B.useEffect((()=>{var n,a;if(console.time("🤯 [layout] inject - ExtraNetworkSidebar"),o.enableExtraNetworkSidebar){const o=gradioApp().querySelectorAll("#txt2img_extra_tabs > .tab-nav > button")[1],i=gradioApp().querySelectorAll("#img2img_extra_tabs > .tab-nav > button")[1];o&&o.click(),i&&i.click();const s=gradioApp().querySelector("div#tab_txt2img"),l=gradioApp().querySelector("div#txt2img_extra_tabs"),c=l.querySelectorAll("div.tabitem.gradio-tabitem")[0],u=gradioApp().querySelector("div#tab_img2img"),d=gradioApp().querySelector("div#img2img_extra_tabs"),f=d.querySelectorAll("div.tabitem.gradio-tabitem")[0];if(l&&d&&(null==(n=e.current)||n.append(l),c.id="txt2img_render",null==s||s.append(c),null==(a=t.current)||a.append(d),f.id="img2img_render",null==u||u.append(f)),document.querySelector(".extra-network-cards"))return iae(),void r(!1)}console.timeEnd("🤯 [layout] inject - ExtraNetworkSidebar")}),[]),VX((()=>{var e,t;console.time("🤯 [extranetwork] force reload");const n=document.querySelector("#txt2img_extra_refresh"),o=document.querySelector("#img2img_extra_refresh");n.click(),o.click(),r(!1);try{const n=null==(e=document.querySelector("#txt2img_extra_refresh"))?void 0:e.nextSibling;n&&(n.onclick=iae);const r=null==(t=document.querySelector("#img2img_extra_refresh"))?void 0:t.nextSibling;r&&(r.onclick=iae),iae()}catch(a){console.debug(a)}console.timeEnd("🤯 [extranetwork] force reload")}),2e3),Q.jsxs(Q.Fragment,{children:[Q.jsxs(qQ,{className:l.body,children:[n&&Q.jsx(IR,{active:!0}),Q.jsxs("div",{style:n?{display:"none"}:{},children:[Q.jsx("div",{id:"txt2img-extra-network-sidebar",ref:e,style:"tab_img2img"===a?{display:"none"}:{}}),Q.jsx("div",{id:"img2img-extra-network-sidebar",ref:t,style:"tab_img2img"===a?{}:{display:"none"}})]})]}),Q.jsxs(tJ,{children:[Q.jsx(KH,{icon:o.extraNetworkCardSizes(o.extraNetworkCardSize),size:{blockSize:24,fontSize:16}}),Q.jsx(Jz,{defaultValue:i,max:256,min:64,onChange:s,step:8,style:{flex:1},value:i})]})]})})),lae=B.memo((({headerHeight:e})=>{const{mobile:t}=WB(),n=p4(u4,sJ),[r,o]=B.useState(!t&&n.extraNetworkSidebarExpand),[a,i]=B.useState("fixed"===n.extraNetworkFixedMode),{styles:s,theme:l}=Joe({headerHeight:e}),{t:c}=H1();B.useEffect((()=>{t&&o(!1)}),[t]);const u=t||a?"fixed":"float";return Q.jsx(MQ,{defaultSize:{width:n.extraNetworkSidebarWidth},expand:r,minWidth:n.extraNetworkSidebarWidth,mode:u,onExpandChange:o,pin:a,placement:"right",children:Q.jsx(ZZ,{children:Q.jsxs(QQ,{className:s.container,style:"float"===u?{background:l.colorBgContainer,minWidth:n.extraNetworkSidebarWidth}:{minWidth:n.extraNetworkSidebarWidth},children:[Q.jsx(aJ,{pin:a,position:"right",setExpand:o,setPin:i,title:c("extraNetwork")}),Q.jsx(sae,{})]})})})})),cae=lae,uae=[{description:"AUTOMATIC111",openExternal:!0,title:"Stable Diffusion Webui",url:"https://github.com/AUTOMATIC1111/stable-diffusion-webui"},{description:"WebUI extension",openExternal:!0,title:"Controlnet",url:"https://github.com/Mikubill/sd-webui-controlnet"},{description:"Art models",openExternal:!0,title:"Civitai",url:"https://civitai.com/"},{description:"Artist Inspired Styles",openExternal:!0,title:"Cheat Sheet",url:"https://supagruen.github.io/StableDiffusion-CheatSheet"},{description:"Image Resizing",openExternal:!0,title:"Birme",url:"https://www.birme.net/?target_width=512&target_height=512"}],dae=[{icon:Q.jsx(PH,{icon:Uf,size:"small"}),openExternal:!0,title:"Report Bug",url:`${W1}/issues/new/choose`},{icon:Q.jsx(PH,{icon:Yf,size:"small"}),openExternal:!0,title:"Request Feature",url:`${W1}/issues/new/choose`}],fae=[{icon:Q.jsx(PH,{icon:Qf,size:"small"}),openExternal:!0,title:"GitHub",url:W1},{icon:Q.jsx(PH,{icon:Xf,size:"small"}),openExternal:!0,title:"Changelog",url:`${W1}/blob/main/CHANGELOG.md`}],pae=[{description:"Minifier ExtraNetwrok Covers",openExternal:!0,title:"✂️ Cover Minifier",url:"https://github.com/canisminor1990/sd-webui-cover-minifier"},{description:"OpenAI Chat Bot",openExternal:!0,title:"🤖 Lobe Chat",url:"https://chat.lobehub.com"},{description:"AIGC Components",openExternal:!0,title:"🍭 Lobe UI",url:"https://ui.lobehub.com"},{description:"AI Commit CLI",openExternal:!0,title:"💌 Lobe Commit",url:"https://github.com/lobehub/lobe-commit"}],hae=vH((({css:e})=>({footer:e` footer { display: block !important; } diff --git a/src/script/civitaiHelperFix.ts b/src/script/civitaiHelperFix.ts index ba3e3234..faf5a726 100644 --- a/src/script/civitaiHelperFix.ts +++ b/src/script/civitaiHelperFix.ts @@ -214,7 +214,7 @@ const updateCardForCivitai = () => { addTriggerWordsNode.title = 'Add trigger words to prompt'; addTriggerWordsNode.setAttribute( 'onclick', - `add_trigger_words(event, '${modelType}', ', ${searchTerm}')`, + `add_trigger_words(event, '${modelType}', '${searchTerm}')`, ); const usePreviewPromptNode = document.createElement('a');