├── LICENSE
├── README.md
├── SDAtom-WebUi-us.user.js
├── docs
└── bookmarklet.html
└── screenshot.png
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SDAtom-WebUi-us
2 |
3 | This is a [user script](https://en.wikipedia.org/wiki/Userscript) that adds a processing queue to the web ui of [AUTOMATIC1111/stable-diffusion-webui](https://github.com/AUTOMATIC1111/stable-diffusion-webui). There is also an option to save one or more sets of settings for quickly loading them again later.
4 |
5 | 
6 |
7 | # Installation
8 |
9 | 1. [Install as an WebUi extension](https://github.com/Kryptortio/SDAtom-WebUi-client-queue-ext#installation), Open the webui and go to the **Extensions** tab, you can find the extension under **Available** > **Web UI client queue**. You can also use **Install from URL** and enter the url to the extension repo (https://github.com/Kryptortio/SDAtom-WebUi-client-queue-ext) and then click install.
10 |
11 | 2. [Run script without installing](https://kryptortio.github.io/SDAtom-WebUi-us/bookmarklet.html)
12 |
13 | 3. To install the user script **I recommend installing an addon** where you that let's you add user scripts
14 |
15 | * Tampermonkey [Chrome](https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo) [Firefox](https://addons.mozilla.org/en-US/firefox/addon/tampermonkey/)
16 | * Greasemonkey [Firefox](https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/)
17 | * Violentmonkey [Chrome](https://chrome.google.com/webstore/detail/violentmonkey/jinjaccalgkegednnccohejagnlnfdag) [Firefox](https://addons.mozilla.org/en-US/firefox/addon/violentmonkey/)
18 |
19 | After you have installed an extension simply [open the script](https://raw.githubusercontent.com/Kryptortio/SDAtom-WebUi-us/main/SDAtom-WebUi-us.user.js) and you will be asked if you want to install it.
20 |
21 | The script assumes you are running the web interface on the url http://127.0.0.1:7860/ if you are using another url you can open the script yourself and just copy or modify the //match row to match the url you are using.
22 |
23 | # Updating
24 |
25 | Hopefully the script will update automatically but if the script doesn't have [the latest version](https://github.com/Kryptortio/SDAtom-WebUi-us/blob/main/SDAtom-WebUi-us.user.js#L4) then it can be updated manually.
26 |
27 | 1. (Extension for AUTOMATIC1111) click `Extensions` > `Check for updates` > `Apply and restart UI`.
28 |
29 | 2. (Bookmarklet) Clear browser cache.
30 |
31 | 3. (Userscript) Click this [script link](https://raw.githubusercontent.com/Kryptortio/SDAtom-WebUi-us/main/SDAtom-WebUi-us.user.js) and reinstall it.
32 |
33 | # Usage
34 |
35 | * Change the prompt and other settings to your liking
36 | * Click the add to queue button (top right corner), adjust how many times it should run (default is 1)
37 | * Keep adding as many as you like
38 | * Click process queue to start running through the queue. You can keep adding to while it's working but when each item finishes current settings will be replaced with the ones in the queued item.
39 |
40 | The interface is added below the normal interface with one floating button in the top right. If you are confused about what any button or field is for hold the mouse over it for a description. Settings and the queue are saved in your browser if you clear browser data it will be removed. The queue can be edited directly while it's being processed (maybe just avoid changing it just as it's finishing an item).
41 |
42 | ## Prompt filter
43 |
44 | Prompt filters can be used to process your prompts before they get added to the queue (textbox after the import/export text box). To add a filter you add a regular expression on the format `[{"desc":"description/name","pattern":"regex pattern","replace":"replacement string/regex","flags":"regex flags"}]` multiple regex can be added within the [] separated by commas. For experimenting with regex, this is a good site https://regex101.com/
45 |
46 | Example pattern filters:
47 | * `{"desc":"Remove multiple spaces","pattern":"\\s{2,}","replace":" ","flags":"g"}`
48 | * `{"desc":"Always \", \" (space after , not before)","pattern":"\\s*,\\s*","replace":", ","flags":"g"}`
49 | * `{"desc":"Add the prefix banana to all prompt","pattern":"^","replace":"banana, ","flags":"g"}`
50 | * `{"desc":"Add the postfix banana to all prompt","pattern":"$","replace":", banana","flags":"g"}`
51 |
52 | *Feel free to share more in the discussions tab*
53 |
54 | ## Script extensions
55 |
56 | This text field is where you can add your own script that gets executed after the ui has loaded. This can be used to make your own changes to the script without having to modify the script itself (and having to do it each time you update the script). Some examples of what you could add to the box (several are possible separated with ; and a new line):
57 |
58 | * Make the add to queue button orange `conf.ui.addToQueueButton.style.background = '#CE6400';`
59 | * Make the add to queue button text white `conf.ui.addToQueueButton.style.color = 'white';`
60 | * Move the add to queue button inside the main ui and remove the opacity
61 | ```
62 | conf.shadowDOM.root.querySelector('#quicksettings').appendChild(conf.ui.addToQueueButton);
63 | conf.ui.addToQueueButton.style.position = 'unset';
64 | conf.ui.addToQueueButton.style.opacity = '1';
65 | ```
66 | *Feel free to share more in the discussions tab (note that scripts has some security risks so some care should be taken when adding scripts)*
67 |
68 | # Known issues
69 |
70 | Since version 1.6.0 of [the web ui](https://github.com/AUTOMATIC1111/stable-diffusion-webui/), restore face and tiling options are now hidden by default. This will cause the script to complain but besides those not working the rest should work fine. To restore those two options go to `Settings > User interface > Options in main UI - txt2img` there you can add them back by typing `tiling` and `face_restoration`. After adding the two of them to both txt2img and img2img save and reload the UI.
71 |
72 | # Troubleshooting
73 |
74 | Steps to try to fix issues
75 |
76 | * Check that you are running the latest version of [the script](https://raw.githubusercontent.com/Kryptortio/SDAtom-WebUi-us/main/SDAtom-WebUi-us.user.js) and an updated version of [the web ui](https://github.com/AUTOMATIC1111/stable-diffusion-webui/).
77 | * To update the script [click here](https://raw.githubusercontent.com/Kryptortio/SDAtom-WebUi-us/main/SDAtom-WebUi-us.user.js).
78 | * To update AUTOMATIC1111 Stable Diffusion web UI you run the command `git pull origin master` in the same folder as webui.bat. Optionall you can note what version you have now first if you want the option to try going back later, to do that the command is `git rev-parse HEAD`
79 | * Check the [Limitations section](https://github.com/Kryptortio/SDAtom-WebUi-us#limitations) to see if your version matches the commit listed there, so that you haven't updated to a new version that is not yet supported. Newer versions of AUTOMATIC1111 might work fine but sometimes they change something that breaks the script.
80 | * If you want to try to go to a specific version of AUTOMATIC1111 you can use the command `git checkout ` followed by the id you want to use (e.g. the one listed under [limitations](https://github.com/Kryptortio/SDAtom-WebUi-us#limitations))
81 | * When updating the script your old queue entries might not work fully anymore (if the gui has changed). Then you need to load the entry manually and check that every setting gets loaded, manually set any that won't load anymore and then readd it to the queue.
82 | * If nothing else works **to reset the script/extension** press F12 to open the developer tools, then go to the Console tab and paste this `delete localStorage.awqSavedSetting; delete localStorage.awqCurrentQueue;` then press enter and reload the page. If you want you can copy the data first with the commands `localStorage.awqSavedSetting` and `localStorage.awqCurrentQueue` after each command you can copy the output.
83 |
84 | Steps to try to find the cause of issues
85 |
86 | * Check the for errors in the output console (big white box at the bottom).
87 | * Activate verbose by clicking `Script settings` and then the `Verbose console` checkbox, reload the page and try again, are you seeing any errors in the optput console now?
88 | * Press F12 then go to the console tab and reload the page, do you see any errors in there?
89 |
90 |
91 | # Limitations
92 |
93 | Latest commit (version of AUTOMATIC1111) confirmed to be working (1.6.0.2 [5ef669de080814067961f28357256e8fe27544f4](https://github.com/AUTOMATIC1111/stable-diffusion-webui/commit/5ef669de080814067961f28357256e8fe27544f4))
94 |
95 | * Only txt2img, img2img and extras are supported
96 | * For img2img/extras loading a new image is not supported
97 | * Settings for "Prompts from file or textbox" is not supported
98 |
--------------------------------------------------------------------------------
/SDAtom-WebUi-us.user.js:
--------------------------------------------------------------------------------
1 | // ==UserScript==
2 | // @name SDAtom-WebUi-us
3 | // @namespace SDAtom-WebUi-us
4 | // @version 1.4.1
5 | // @description Queue for AUTOMATIC1111 WebUi and an option to saving settings
6 | // @author Kryptortio
7 | // @homepage https://github.com/Kryptortio/SDAtom-WebUi-us
8 | // @match http://127.0.0.1:7860/*
9 | // @updateURL https://raw.githubusercontent.com/Kryptortio/SDAtom-WebUi-us/main/SDAtom-WebUi-us.user.js
10 | // @downloadURL https://raw.githubusercontent.com/Kryptortio/SDAtom-WebUi-us/main/SDAtom-WebUi-us.user.js
11 | // @grant none
12 | // ==/UserScript==
13 | (function() {
14 | 'use strict';
15 |
16 | const c_scriptVersion = typeof GM_info == 'undefined' ? '1.3.2' : GM_info.script.version;
17 | const c_scriptHandeler = typeof GM_info == 'undefined' ? '(not user script)' : GM_info.scriptHandler;
18 |
19 | // ----------------------------------------------------------------------------- Config
20 | let conf = {
21 | shadowDOM:{sel:"gradio-app"},
22 | commonData: {
23 | t2iContainer:{sel:"#tab_txt2img"},
24 | i2iContainer:{sel:"#tab_img2img"},
25 | extContainer:{sel:"#tab_extras"},
26 | sdModelCheckpoint:{grad:"setting_sd_model_checkpoint"},
27 | versionContainer:{sel:"#footer .versions"},
28 |
29 | working:false,
30 | processing:false,
31 | waiting:false,
32 | },
33 | t2i: {
34 | controls:{
35 | tabButton: {sel:"#tabs > div:nth-child(1) > button:nth-child(1)"},
36 | genrateButton: {sel:"#txt2img_generate"},
37 | skipButton: {sel:"#txt2img_skip"},
38 | },
39 |
40 | prompt: {sel:"#txt2img_prompt textarea"},
41 | negPrompt: {sel:"#txt2img_neg_prompt textarea"},
42 |
43 | sample: {sel:"#txt2img_steps [id^=range_id]",sel2:"#txt2img_steps input"},
44 | sampleMethod: {grad:"txt2img_sampling"},
45 |
46 | width: {sel:"#txt2img_width [id^=range_id]",sel2:"#txt2img_width input"},
47 | height: {sel:"#txt2img_height [id^=range_id]",sel2:"#txt2img_height input"},
48 |
49 | restoreFace: {sel:"#txt2img_settings #setting_face_restoration input"},
50 | tiling: {sel:"#txt2img_settings #setting_tiling input"},
51 |
52 | highresFix: {sel:"#txt2img_hr"},
53 | hrFixUpscaler: {grad:"txt2img_hr_upscaler"},
54 | hrFixSteps: {sel:"#txt2img_hires_steps [id^=range_id]",sel2:"#txt2img_hires_steps input"},
55 | hrFixdenoise: {sel:"#txt2img_denoising_strength [id^=range_id]",sel2:"#txt2img_denoising_strength input"},
56 | hrFixUpscaleBy: {sel:"#txt2img_hr_scale [id^=range_id]",sel2:"#txt2img_hr_scale input"},
57 | hrFixWidth: {sel:"#txt2img_hr_resize_x [id^=range_id]",sel2:"#txt2img_hr_resize_x input"},
58 | hrFixHeight: {sel:"#txt2img_hr_resize_y [id^=range_id]",sel2:"#txt2img_hr_resize_y input"},
59 |
60 | batchCount: {sel:"#txt2img_batch_count [id^=range_id]",sel2:"#txt2img_batch_count input"},
61 | batchSize: {sel:"#txt2img_batch_size [id^=range_id]",sel2:"#txt2img_batch_size input"},
62 |
63 | cfg: {sel:"#txt2img_cfg_scale [id^=range_id]",se2:"#txt2img_cfg_scale input"},
64 |
65 | seed: {sel:"#txt2img_seed input"},
66 |
67 | extra: {sel:"#txt2img_subseed_show input"},
68 | varSeed: {sel:"#txt2img_subseed input"},
69 | varStr: {sel:"#txt2img_subseed_strength [id^=range_id]",sel2:"#txt2img_subseed_strength input"},
70 | varRSFWidth: {sel:"#txt2img_seed_resize_from_w [id^=range_id]",sel2:"#txt2img_seed_resize_from_w input"},
71 | varRSFHeight: {sel:"#txt2img_seed_resize_from_h [id^=range_id]",sel2:"#txt2img_seed_resize_from_h input"},
72 |
73 | script: {grad:"script_list",gradIndex:0},
74 |
75 | scriptPromptMatrixPutVar: {sel:"#script_txt2img_prompt_matrix_put_at_start input"},
76 | scriptPromptMatrixUseDiff: {sel:"#script_txt2img_prompt_matrix_different_seeds input"},
77 |
78 | scriptXYZXtype:{grad:"script_txt2img_xyz_plot_x_type"},
79 | scriptXYZXVals:{sel:"#script_txt2img_xyz_plot_x_values textarea"},
80 | scriptXYZYtype:{grad:"script_txt2img_xyz_plot_y_type"},
81 | scriptXYZYVals:{sel:"#script_txt2img_xyz_plot_y_values textarea"},
82 | scriptXYZZtype:{grad:"script_txt2img_xyz_plot_z_type"},
83 | scriptXYZZVals:{sel:"#script_txt2img_xyz_plot_z_values textarea"},
84 | scriptXYZDrawLeg:{sel:"#script_txt2img_xyz_plot_draw_legend input"},
85 | scriptXYZIncludeSubImg:{sel:"#script_txt2img_xyz_plot_include_lone_images input"},
86 | scriptXYZIncludeSubGrid:{sel:"#script_txt2img_xyz_plot_include_sub_grids input"},
87 | scriptXYZKeepMOne:{sel:"#script_txt2img_xyz_plot_no_fixed_seeds input"},
88 | scriptXYZGridMargin: {sel:"#script_txt2img_xyz_plot_margin_size [id^=range_id]",sel2:"#script_txt2img_xyz_plot_margin_size input"},
89 | },
90 | i2i:{
91 | controls:{
92 | tabButton: {sel:"#tabs > div:nth-child(1) > button:nth-child(2)"},
93 | genrateButton: {sel:"#img2img_generate"},
94 | skipButton: {sel:"#img2img_skip"},
95 | i2iMode:[
96 | {name:"i2i", buttonSel:"#mode_img2img button:nth-child(1)", containerSel:"#img2img_img2img_tab"},
97 | {name:"sketch", buttonSel:"#mode_img2img button:nth-child(2)", containerSel:"#img2img_img2img_sketch_tab"},
98 | {name:"inpaint", buttonSel:"#mode_img2img button:nth-child(3)", containerSel:"#img2img_inpaint_tab"},
99 | {name:"inpaintSketch", buttonSel:"#mode_img2img button:nth-child(4)", containerSel:"#img2img_inpaint_sketch_tab"},
100 | {name:"inpaintUpload", buttonSel:"#mode_img2img button:nth-child(5)", containerSel:"#img2img_inpaint_upload_tab"},
101 | {name:"batch", buttonSel:"#mode_img2img button:nth-child(6)", containerSel:"#img2img_batch_tab"},
102 | ],
103 | },
104 |
105 | prompt: {sel:"#img2img_prompt textarea"},
106 | negPrompt: {sel:"#img2img_neg_prompt textarea"},
107 |
108 | resizeMode: {sel:"#resize_mode"},
109 |
110 | inpaintBlur: {sel:"#img2img_mask_blur [id^=range_id]",sel2:"#img2img_mask_blur"},
111 | inpaintMaskMode: {sel:"#img2img_mask_mode"},
112 | inpaintMaskContent: {sel:"#img2img_inpainting_fill"},
113 | inpaintArea: {sel:"#img2img_inpaint_full_res"},
114 | inpaintPadding: {sel:"#img2img_inpaint_full_res_padding [id^=range_id]",sel2:"#img2img_inpaint_full_res_padding"},
115 |
116 |
117 | i2iBatchInputDir: {sel:"#img2img_batch_input_dir textarea"},
118 | i2iBatchOutputDir: {sel:"#img2img_batch_output_dir textarea"},
119 | i2iBatchMaskDir: {sel:"#img2img_batch_inpaint_mask_dir textarea"},
120 |
121 | sample: {sel:"#img2img_steps [id^=range_id]",sel2:"#img2img_steps input"},
122 | sampleMethod: {grad:"img2img_sampling"},
123 |
124 | width: {sel:"#img2img_width [id^=range_id]",sel2:"#img2img_width input"},
125 | height: {sel:"#img2img_height [id^=range_id]",sel2:"#img2img_height input"},
126 |
127 | restoreFace: {sel:"#img2img_settings #setting_face_restoration input"},
128 | tiling: {sel:"#img2img_settings #setting_tiling input"},
129 |
130 | batchCount: {sel:"#img2img_batch_count [id^=range_id]",sel2:"#img2img_batch_count input"},
131 | batchSize: {sel:"#img2img_batch_size [id^=range_id]",sel2:"#img2img_batch_size input"},
132 |
133 | cfg: {sel:"#img2img_cfg_scale [id^=range_id]",se2:"#img2img_cfg_scale input"},
134 |
135 | denoise: {sel:"#img2img_denoising_strength [id^=range_id]",se2:"#img2img_denoising_strength input"},
136 |
137 | seed: {sel:"#img2img_seed input"},
138 |
139 | extra: {sel:"#txt2img_subseed_show input"},
140 | varSeed: {sel:"#img2img_subseed input"},
141 | varStr: {sel:"#img2img_subseed_strength input",sel2:"#img2img_subseed_strength [id^=range_id]"},
142 | varRSFWidth: {sel:"#img2img_seed_resize_from_w input",sel2:"#img2img_seed_resize_from_w [id^=range_id]"},
143 | varRSFHeight: {sel:"#img2img_seed_resize_from_h input",sel2:"#img2img_seed_resize_from_h [id^=range_id]"},
144 |
145 | script: {grad:"script_list",gradIndex:1},
146 |
147 | scriptPromptMatrixPutVar: {sel:"#script_img2img_prompt_matrix_put_at_start input"},
148 | scriptPromptMatrixUseDiff: {sel:"#script_img2img_prompt_matrix_different_seeds input"},
149 |
150 | scriptXYZXtype:{grad:"script_img2img_xyz_plot_x_type"},
151 | scriptXYZXVals:{sel:"#script_img2img_xyz_plot_x_values textarea"},
152 | scriptXYZYtype:{grad:"script_img2img_xyz_plot_y_type"},
153 | scriptXYZYVals:{sel:"#script_img2img_xyz_plot_y_values textarea"},
154 | scriptXYZZtype:{grad:"script_img2img_xyz_plot_z_type"},
155 | scriptXYZZVals:{sel:"#script_img2img_xyz_plot_z_values textarea"},
156 | scriptXYZDrawLeg:{sel:"#script_img2img_xyz_plot_draw_legend input"},
157 | scriptXYZIncludeSubImg:{sel:"#script_img2img_xyz_plot_include_lone_images input"},
158 | scriptXYZIncludeSubGrid:{sel:"#script_img2img_xyz_plot_include_sub_grids input"},
159 | scriptXYZKeepMOne:{sel:"#script_img2img_xyz_plot_no_fixed_seeds input"},
160 | scriptXYZGridMargin: {sel:"#script_img2img_xyz_plot_margin_size [id^=range_id]",sel2:"#script_img2img_xyz_plot_margin_size input"},
161 |
162 | scripti2iAltTestOverrideSampM:{sel:"#script_img2img_alternative_test_override_sampler input"},
163 | scripti2iAltTestOverrideProm:{sel:"#script_img2img_alternative_test_override_prompt input"},
164 | scripti2iAltTestOrigProm:{sel:"#script_img2img_alternative_test_original_prompt textarea"},
165 | scripti2iAltTestOrigNProm:{sel:"#script_img2img_alternative_test_original_negative_prompt textarea"},
166 | scripti2iAltTestOverrideSampS:{sel:"#script_img2img_alternative_test_override_steps input"},
167 | scripti2iAltTestDecStep:{sel:"#script_img2img_alternative_test_st input",sel2:"#script_img2img_alternative_test_st [id^=range_id]"},
168 | scripti2iAltTestOverrideDenoi:{sel:"#script_img2img_alternative_test_override_strength input"},
169 | scripti2iAltTestDecCFG:{sel:"#script_img2img_alternative_test_cfg input",sel2:"#script_img2img_alternative_test_cfg [id^=range_id]"},
170 | scripti2iAltTestRand:{sel:"#script_img2img_alternative_test_randomness input",sel2:"#script_img2img_alternative_test_randomness [id^=range_id]"},
171 | scripti2iAltTestSigma:{sel:"#script_img2img_alternative_test_sigma_adjustment input"},
172 |
173 | scriptLoopbackLoops:{sel:"#script_loopback_loops input",sel2:"#script_loopback_loops [id^=range_id]"},
174 | scriptLoopbackDenoStr:{sel:"#script_loopback_final_denoising_strength input",sel2:"#script_loopback_final_denoising_strength [id^=range_id]"},
175 | scriptLoopbackDenoStrCurve:{gradLab:"Denoising strength curve"},
176 | scriptLoopbackAppend:{gradLab:"Append interrogated prompt at each iteration"},
177 |
178 | scriptOutPMK2Pixels:{sel:"#script_outpainting_mk2_pixels input",sel2:"#script_outpainting_mk2_pixels [id^=range_id]"},
179 | scriptOutPMK2MaskBlur:{sel:"#script_outpainting_mk2_mask_blur input",sel2:"#script_outpainting_mk2_mask_blur [id^=range_id]"},
180 | scriptOutPMK2Left:{sel:"#script_outpainting_mk2_direction label:nth-child(1) input"},
181 | scriptOutPMK2Right:{sel:"#script_outpainting_mk2_direction label:nth-child(2) input"},
182 | scriptOutPMK2Up:{sel:"#script_outpainting_mk2_direction label:nth-child(3) input"},
183 | scriptOutPMK2Down:{sel:"#script_outpainting_mk2_direction label:nth-child(4) input"},
184 | scriptOutPMK2FallOff:{sel:"#script_outpainting_mk2_noise_q input",sel2:"#script_outpainting_mk2_noise_q [id^=range_id]"},
185 | scriptOutPMK2ColorVar:{sel:"#script_outpainting_mk2_color_variation input",sel2:"#script_outpainting_mk2_color_variation [id^=range_id]"},
186 |
187 | scriptPoorManPixels:{sel:"#script_poor_mans_outpainting_pixels input",sel2:"#script_poor_mans_outpainting_pixels [id^=range_id]"},
188 | scriptPoorManMaskBlur:{sel:"#script_poor_mans_outpainting_mask_blur input",sel2:"#script_poor_mans_outpainting_mask_blur [id^=range_id]"},
189 | scriptPoorManMaskCont:{sel:"#script_poor_mans_outpainting_inpainting_fill"},
190 | scriptPoorManLeft:{sel:"#script_poor_mans_outpainting_direction label:nth-child(1) input"},
191 | scriptPoorManRight:{sel:"#script_poor_mans_outpainting_direction label:nth-child(2) input"},
192 | scriptPoorManUp:{sel:"#script_poor_mans_outpainting_direction label:nth-child(3) input"},
193 | scriptPoorManDown:{sel:"#script_poor_mans_outpainting_direction label:nth-child(4) input"},
194 |
195 | scriptSDUpTile:{sel:"#script_sd_upscale_overlap input",sel2:"#script_sd_upscale_overlap [id^=range_id]"},
196 | scriptSDUpScale:{sel:"#script_sd_upscale_scale_factor input",sel2:"#script_sd_upscale_scale_factor [id^=range_id]"},
197 | scriptSDUpUpcaler:{sel:"#script_sd_upscale_upscaler_index"},
198 |
199 | },
200 | ext:{
201 | controls:{
202 | tabButton: {sel:"#tabs > div:nth-child(1) > button:nth-child(3)"},
203 | genrateButton: {sel:"#extras_generate"},
204 | loadingElement:{sel:"#html_info_x_extras .wrap"},
205 | extrasResizeMode:[
206 | {name:"scaleBy",buttonSel:"#extras_resize_mode button:nth-child(1)",containerSel:"#extras_scale_by_tab"},
207 | {name:"scaleTo",buttonSel:"#extras_resize_mode button:nth-child(2)",containerSel:"#extras_scale_to_tab"},
208 | ],
209 | extrasMode:[
210 | {name:"singleImg",buttonSel:"#mode_extras button:nth-child(1)",containerSel:"#extras_single_tab"},
211 | {name:"batchProcess",buttonSel:"#mode_extras button:nth-child(2)",containerSel:"#extras_batch_process_tab"},
212 | {name:"batchDir",buttonSel:"#mode_extras button:nth-child(3)",containerSel:"#extras_batch_directory_tab"},
213 | ],
214 | },
215 |
216 |
217 | scaleByResize:{sel:"#extras_upscaling_resize input",sel2:"#extras_upscaling_resize [id^=range_id]"},
218 |
219 | scaleToWidth:{sel:"#extras_upscaling_resize_w input"},
220 | scaleToHeight:{sel:"#extras_upscaling_resize_h input"},
221 | scaleToCropToFit:{sel:"#extras_upscaling_crop input"},
222 |
223 | batchDirInput:{sel:"#extras_batch_input_dir textarea"},
224 | batchDirOutput:{sel:"#extras_batch_output_dir textarea"},
225 | batchDirShowImg:{sel:"#extras_show_extras_results input"},
226 |
227 | upscaler1:{grad:"extras_upscaler_1"},
228 | upscaler2:{grad:"extras_upscaler_2"},
229 | upscale2Vis:{sel:"#extras_upscaler_2_visibility input",sel2:"#extras_upscaler_2_visibility [id^=range_id]"},
230 | GFPGANVis:{sel:"#extras_gfpgan_visibility input",sel2:"#extras_gfpgan_visibility [id^=range_id]"},
231 | CodeFormVis:{sel:"#extras_codeformer_visibility input",sel2:"#extras_codeformer_visibility [id^=range_id]"},
232 | CodeFormWeight:{sel:"#extras_codeformer_weight input",sel2:"#extras_codeformer_weight [id^=range_id]"},
233 |
234 |
235 | },
236 | extensions: {
237 | iBrowser: {
238 | name:"stable-diffusion-webui-images-browser",
239 | existCheck:{sel:"#tab_image_browser"},
240 | guiElems: {
241 | iBrowserContainer:{sel:"#tab_image_browser"},
242 | generationInfo: {sel: "#image_browser_tab_txt2img_image_browser_file_info textarea"},
243 |
244 | txt2img:{sel:'#image_browser_tab_txt2img_image_browser_file_info textarea'},
245 | img2img:{sel:'#image_browser_tab_img2img_image_browser_file_info textarea'},
246 | txt2imgG:{sel:'#image_browser_tab_txt2img-grids_image_browser_file_info textarea'},
247 | img2imgG:{sel:'#image_browser_tab_img2img-grids_image_browser_file_info textarea'},
248 | extras:{sel:'#image_browser_tab_extras_image_browser_file_info textarea'},
249 | favorites:{sel:'#image_browser_tab_favorites_image_browser_file_info textarea'},
250 | },
251 | ui:{},
252 | text:{
253 | queueVariationsButtonText:'Add 5 variations',
254 | queueHiResVersionButtonText:'Add HiRes version',
255 | },
256 | functions: {
257 | getValueJSON: function () {
258 | awqLog('iBrowser.getValueJSON: parsing data');
259 | let valueJSON = {type:'t2i'};
260 |
261 | let currentTab = document.querySelector('#image_browser_tabs_container button.selected').innerHTML;
262 | currentTab = currentTab.replace(/\s/g,'');
263 | currentTab = currentTab.replace('-grids','G').toLowerCase();
264 |
265 | let generationInfoValue = conf.extensions.iBrowser.guiElems[currentTab].el.value;
266 |
267 | //Used when loading prompt from image browser
268 | /*
269 | Kind of using the logic from generation_parameters_copypaste.py/parse_generation_parameters (but not really, because that doesn't account for Template/Negative Template)
270 | Structure
271 |
272 | Negative prompt:
273 | a1: b1, a2: b2, etc
274 | Template:
275 | Negative Template:
276 |
277 | , , and can all be multiline, or missing.
278 | Maybe assume that is never missing?
279 | */
280 | let lines = generationInfoValue.split(/\r?\n/);
281 | let whichLine=0; //0=prompt, 1=negPrompt, 2=template, 3=negTemplate, 4: dictionary
282 | valueJSON['prompt']='';
283 | valueJSON['negPrompt']='';
284 |
285 | for (let l of lines) {
286 | if (l.startsWith("Negative prompt: ")) {
287 | whichLine=1;
288 | l=l.substring(17);
289 | }
290 | else if (l.startsWith("Template: ")) {
291 | whichLine=2;
292 | l=l.substring(10);
293 | }
294 | else if (l.startsWith("Negative Template: ")) {
295 | whichLine=3;
296 | l=l.substring(19);
297 | }
298 | else if (l.startsWith("Steps: ")) {
299 | whichLine=4;
300 | }
301 |
302 | switch (whichLine) {
303 | case 0:
304 | valueJSON['prompt']+=l;
305 | break;
306 | case 1:
307 | valueJSON['negPrompt']+=l;
308 | break;
309 | case 2:
310 | //ignore template
311 | break;
312 | case 3:
313 | //ignore neg template
314 | break;
315 | case 4:
316 | for (let v of l.split(/, /)) {
317 | let kv=v.split(/: /);
318 | let key=kv[0];
319 | switch (kv[0]){
320 | case "Steps":
321 | valueJSON['sample']=kv[1];
322 | break;
323 | case "Sampler":
324 | valueJSON['sampleMethod']=kv[1];
325 | break;
326 | case "CFG scale":
327 | valueJSON['cfg']=kv[1];
328 | break;
329 | case "Seed":
330 | valueJSON['seed']=kv[1];
331 | break;
332 | case "Size":
333 | let wh=kv[1].split(/x/)
334 | valueJSON['width']=wh[0];
335 | valueJSON['height']=wh[1];
336 | break;
337 | case "Model":
338 | valueJSON['sdModelCheckpoint']=kv[1];
339 | break;
340 | case "Denoising strength":
341 | valueJSON['hrFixdenoise']=kv[1];
342 | break;
343 | case "Hires upscale":
344 | valueJSON['hrFixUpscaleBy']=kv[1];
345 | valueJSON['highresFix']=true;
346 | break;
347 | case "Hires upscaler":
348 | valueJSON['hrFixUpscaler']=kv[1];
349 | break;
350 | }
351 | }
352 | break;
353 | } // End of switch
354 | } // End of for
355 | return JSON.stringify(valueJSON);
356 | },
357 | }, // End of functions
358 | }, // End of iBrowser
359 | },
360 |
361 | ui:{},
362 | scriptSettings: {
363 | defaultQuantity:{name:"Default queue quantity", description:"Default number of times to execute each queue item", type:"numeric",value:"1"},
364 | rememberQueue:{name:"Remember queue", description:"Remember the queue if you reload the page", type:"boolean",value:true},
365 | notificationSound:{name:"Notification sound", description:"Sound to be played when processing of queue items stops", type:"boolean",value:true},
366 | extensionScript:{name:"Extension script(s)", description:"https://github.com/Kryptortio/SDAtom-WebUi-us#script-extensions", type:"text",value:""},
367 | promptFilter:{name:"Prompt filter(s)", description:"https://github.com/Kryptortio/SDAtom-WebUi-us#prompt-filter", type:"text",value:""},
368 | promptFilterNegative:{name:"Filter negative prompt", description:"Apply the prompt filter to the negative filter as well", type:"boolean",value:false},
369 | autoscrollOutput:{name:"Autoscroll console", description:"Scroll console automatically when new lines appear", type:"boolean",value:true},
370 | verboseLog:{name:"Verbose console", description:"Log as much as possible to the console", type:"boolean",value:false},
371 | maxOutputLines:{name:"Max console lines", description:"The maximum number of lines that can be shown in the console box", type:"numeric",value:"500"},
372 | overwriteQueueSettings1:{name:"Alt 1 overwrite", description:"Add settings you want to overwrite the current settings with when you click the Alt 1 button to add to queue (same format as in the queue)", type:"text",value:'{"width":"768","height":"768"}'},
373 | overwriteQueueSettings2:{name:"Alt 2 overwrite", description:"Add settings you want to overwrite the current settings with when you click the Alt 2 button to add to queue (same format as in the queue)", type:"text",value:'{"width":"1024","height":"1024"}'},
374 | overwriteQueueSettings3:{name:"Alt 3 overwrite", description:"Add settings you want to overwrite the current settings with when you click the Alt 3 button to add to queue (same format as in the queue)", type:"text",value:'{"sample":"20","sampleMethod":"Euler a","width":"512","height":"512","restoreFace": false,"tiling": false,"batchCount": "1","batchSize": "1","cfg": "7","seed": "-1","extra": false, "varSeed": "-1","varStr": "0"}'},
375 | buttonOpacity:{name:"Button transparency", description:"Change how visible the floating buttons in the corner should be", type:"numeric",value:0.7},
376 | },
377 | savedSetting: JSON.parse(localStorage.awqSavedSetting || '{}'),
378 | currentQueue: JSON.parse(localStorage.awqCurrentQueue || '[]'),
379 | };
380 |
381 | if(localStorage.hasOwnProperty("awqNotificationSound") &&
382 | !localStorage.hasOwnProperty("awqScriptSettings")) { // Tmp settings migration
383 | awqLog('Copying settings from old storage');
384 | if (localStorage.hasOwnProperty("awqNotificationSound"))
385 | conf.scriptSettings.notificationSound.value = localStorage.awqNotificationSound == 1 ? true : false;
386 | if (localStorage.hasOwnProperty("awqAutoscrollOutput"))
387 | conf.scriptSettings.autoscrollOutput.value = localStorage.awqAutoscrollOutput == 1 ? true : false;
388 | if (localStorage.hasOwnProperty("awqVerboseLog"))
389 | conf.scriptSettings.verboseLog.value = localStorage.awqVerboseLog == 1 ? true : false;
390 | if (localStorage.hasOwnProperty("awqMaxOutputLines"))
391 | conf.scriptSettings.maxOutputLines.value = localStorage.awqMaxOutputLines;
392 | if (localStorage.hasOwnProperty("awqPromptFilter"))
393 | conf.scriptSettings.promptFilter.value = localStorage.awqPromptFilter;
394 | if (localStorage.hasOwnProperty("awqExtensionScript"))
395 | conf.scriptSettings.extensionScript.value = localStorage.awqExtensionScript;
396 | }
397 | const c_emptyQueueString = 'Queue is empty';
398 | const c_addToQueueButtonText = 'Add to queue';
399 | const c_processButtonText = 'Process queue';
400 | const c_defaultTextStoredSettings = "Stored settings";
401 | const c_innerUIWidth = 'calc(100vw - 20px)';
402 | const c_uiElemntHeight = '25px';
403 | const c_uiElemntHeightSmall = '18px';
404 | const c_audio_base64 = new Audio('data:audio/mpeg;base64,//PkZAAAAAGkAAAAAAAAA0gAAAAATEFNRTMuMTAwVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV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VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV');
405 | const c_defaultOtputConsoleText = "Here you will see some information about what the script is doing";
406 | const c_defaultOtputConsoleTextHTML = `${c_defaultOtputConsoleText}`;
407 | const c_extraResizeModeScaleByType = 1;
408 | const c_extraResizeModeScaleToType = 2;
409 | const c_wait_tick_duration = 200;
410 | const c_any_value = '';
411 |
412 | // ----------------------------------------------------------------------------- Logging
413 | function preAwqLog(p_message) {
414 | console.log(`SDAtom-WebUi-us: ${p_message}`);
415 | }
416 | preAwqLog(`Running SDAtom-WebUi-us version ${c_scriptVersion} using ${c_scriptHandeler} with browser ${window.navigator.userAgent}`);
417 |
418 | function awqLog(p_message) {
419 | if(conf.scriptSettings.verboseLog.value) {
420 | awqLogPublishMsg(p_message, 'lightgray');
421 | }
422 | }
423 | function awqLogPublishMsg(p_message, p_color) {
424 | if(!conf.ui.outputConsole) return;
425 | if(conf.ui.outputConsole.innerHTML.match('console-description')) {
426 | let ASDWUIVerText = '' + conf.commonData.versionContainer.el.textContent + '';
427 | conf.ui.outputConsole.innerHTML = `* Running SDAtom-WebUi-us version ${c_scriptVersion} using ${c_scriptHandeler} with browser ${window.navigator.userAgent} stable-diffusion-webui version ${ASDWUIVerText}`;
428 | }
429 | let lines = conf.ui.outputConsole.querySelectorAll('div');
430 | let line = document.createElement('div');
431 | line.className = 'awq-console-line';
432 | const timestamp = (new Date()).toLocaleTimeString([], {hour: '2-digit',minute: '2-digit',second: '2-digit', hour12: false});
433 | line.innerHTML = '' + timestamp + ': ' + p_message + '';
434 | conf.ui.outputConsole.appendChild(line);
435 |
436 | if(lines.length >= conf.scriptSettings.maxOutputLines.value) {
437 | lines[0].parentNode.removeChild(lines[0]);
438 | }
439 | if(conf.scriptSettings.autoscrollOutput.value) conf.ui.outputConsole.scrollTo(0, conf.ui.outputConsole.scrollHeight);
440 | }
441 | function awqLogPublishError(p_message) { awqLogPublishMsg(p_message, 'red') }
442 | window.addEventListener("error", (event) => {
443 | if(conf.scriptSettings.verboseLog.value) {
444 | awqLogPublishMsg(
445 | `Javascript error (can be caused by something other than this script): ${event.message} source:${event.filename} line:${event.lineno} col:${event.colno} Error:${event.error ? JSON.stringify(event.error) : '' }`,
446 | 'darkorange'
447 | );
448 | }
449 | },true);
450 | window.addEventListener("unhandledrejection", (event) => {
451 | if(conf.scriptSettings.verboseLog.value) {
452 | awqLogPublishMsg(
453 | `Javascript promise error (can be caused by something other than this script): ${event.reason}`,
454 | 'darkorange'
455 | );
456 | }
457 | },true);
458 | let oldWarn = window.console.warn,oldInfo = window.console.info,oldLog = window.console.log,oldError = window.console.error;
459 | window.console.warn = function(p_msg) {
460 | if(conf.scriptSettings.verboseLog.value) awqLogPublishMsg('log (warn) message (can be caused by something other than this script):' + p_msg +`
Call stack:${getCallStack()}
`, 'lightgray'); oldWarn(p_msg);
461 | }
462 | window.console.info = function(p_msg) {
463 | if(conf.scriptSettings.verboseLog.value) awqLogPublishMsg('log (info) message (can be caused by something other than this script):' + p_msg +`
Call stack:${getCallStack()}
`, 'lightgray'); oldInfo(p_msg);
464 | }
465 | window.console.log = function(p_msg) {
466 | if(conf.scriptSettings.verboseLog.value) awqLogPublishMsg('log (log) message (can be caused by something other than this script):' + p_msg +`
Call stack:${getCallStack()}
`, 'lightgray'); oldLog(p_msg);
467 | }
468 | // ----------------------------------------------------------------------------- Wait for content to load
469 | let waitForLoadInterval = setInterval(initAWQ, c_wait_tick_duration);
470 | function initAWQ() {
471 | window.awqConf = conf;
472 | conf.shadowDOM.root = document.querySelector(conf.shadowDOM.sel);
473 | if(!conf.shadowDOM.root || !conf.shadowDOM.root.querySelector('#txt2img_prompt')) return;
474 | clearInterval(waitForLoadInterval);
475 |
476 | conf.commonData.versionContainer.el = conf.shadowDOM.root.querySelector('#footer .versions');
477 |
478 | // Check for extensions
479 | for(let ext in conf.extensions) {
480 | if(!document.querySelector(conf.extensions[ext].existCheck.sel)) {
481 | preAwqLog(`Extension ${conf.extensions[ext].name} not found, disabling`);
482 | conf.extensions[ext] = false;
483 | } else {
484 | preAwqLog(`Extension ${conf.extensions[ext].name} found`);
485 | }
486 | }
487 |
488 | loadScriptSettings();
489 | generateMainUI();
490 |
491 | try { throw new Error(); } catch(e) { awqLog(`initAWQ: stack = ${e.stack.replace(/^(.*?)\binitAWQ/s,'')}`) }
492 |
493 | try { eval(conf.scriptSettings.extensionScript.value);} catch(e) { awqLogPublishMsg(`Failed to load extension script, error: ${e.message} l:${e.lineNumber} c:${e.columnNumber}\n${e.stack}
`,'darkorange')}
494 |
495 | function mapElementsToConf(p_object, p_info) {
496 | for (let prop in p_object) {
497 | if(p_object[prop].sel) {
498 | p_object[prop].el = conf.shadowDOM.root.querySelector(p_object[prop].sel);
499 | if(!p_object[prop].el) awqLogPublishError(`Failed to find the ${p_info} ${prop}`);
500 | }
501 | if(p_object[prop].sel2) {
502 | p_object[prop].el2 = conf.shadowDOM.root.querySelector(p_object[prop].sel2);
503 | if(!p_object[prop].el2) awqLogPublishError(`Failed to find the secondary ${p_info} ${prop}`);
504 | }
505 | if(p_object[prop].grad) {
506 | let gradIndex = p_object[prop].gradIndex ? p_object[prop].gradIndex : 0;
507 | p_object[prop].gradEl = findGradioComponentState(p_object[prop].grad)[gradIndex];
508 | if(!p_object[prop].gradEl) awqLogPublishError(`Failed to find the gradio element ${p_info} ${prop}`);
509 | }
510 | if(p_object[prop].gradLab) {
511 | p_object[prop].gradEl = findGradioComponentStateByLabel(p_object[prop].gradLab)[0];
512 | if(!p_object[prop].gradEl) awqLogPublishError(`Failed to find the gradio element ${p_info} ${prop}`);
513 | }
514 | }
515 | }
516 |
517 | mapElementsToConf(conf.commonData, 'main object');
518 | mapElementsToConf(conf.t2i, 't2i object');
519 | mapElementsToConf(conf.t2i.controls, 't2i control');
520 | mapElementsToConf(conf.i2i, 'i2i object');
521 | mapElementsToConf(conf.i2i.controls, 'i2i control');
522 | mapElementsToConf(conf.ext, 'ext object');
523 | mapElementsToConf(conf.ext.controls, 'ext control');
524 | if(conf.extensions.iBrowser) waitForElm(conf.extensions.iBrowser.guiElems.txt2img.sel).then(function() {mapElementsToConf(conf.extensions.iBrowser.guiElems, 'iBrowser objects')});
525 |
526 | setInterval(updateStatus, c_wait_tick_duration);
527 |
528 |
529 | }
530 |
531 | function appendAddToQueueButton(container, top, innerHTML, onclick, title, right) {
532 | let button = document.createElement('button');
533 | button.innerHTML = innerHTML;
534 | button.style.height = c_uiElemntHeight;
535 | button.style.color = 'black';
536 | button.style.position = 'fixed';
537 | button.style.top = top + 'px';
538 | button.style.right = right ? right + 'px' : 0;
539 | button.style.opacity = conf.scriptSettings.buttonOpacity.value;
540 | button.onclick = onclick;
541 | button.style.cursor = "pointer";
542 | button.title = title;
543 | button.style.display = 'none';
544 | button.classList.add('awq-hover-button');
545 | container.appendChild(button);
546 | return button;
547 | }
548 |
549 | function generateMainUI() {
550 | let awqCSSElem = document.createElement('style');
551 | awqCSSElem.innerHTML = `
552 | #AWQ-container {
553 | background:var(--background-fill-primary);
554 | }
555 | #AWQ-container button {
556 | border:var(--button-border-width) solid var(--button-secondary-border-color);
557 | background:var(--button-secondary-background-fill);
558 | color:var(--button-secondary-text-color);
559 | }
560 | #AWQ-container input, #AWQ-container select, #AWQ-container .awq-console-line,
561 | #awq-script-settings-popup input, #awq-script-settings-popup textarea {
562 | box-shadow: var(--input-shadow);
563 | border: var(--input-border-width) solid var(--input-border-color);
564 | border-radius: var(--input-radius);
565 | background: var(--input-background-fill);
566 | color: var(--body-text-color);
567 | }
568 | #AWQ-container input.completed-queue-item {
569 | background:var(--button-secondary-background-fill);
570 | color:var(--button-secondary-text-color);
571 | }
572 | #AWQ-container .awq-console-line {
573 | border-radius: unset;
574 | }
575 | #awq-script-settings-popup {
576 | background:var(--background-fill-primary);
577 | }
578 | #awq-script-settings-popup label, #awq-script-settings-popup span {
579 | color: var(--block-title-text-color);
580 | }
581 | `;
582 | document.head.appendChild(awqCSSElem);
583 |
584 | let container = document.createElement('div');
585 | container.id = 'AWQ-container';
586 | container.className = document.querySelector('gradio-app > div').classList.contains('dark') ? 'dark' : '';
587 | container.style.width = c_innerUIWidth;
588 | container.style.border = "1px solid white";
589 | container.style.position = "relative";
590 | container.style.zIndex = "2147483647";
591 | document.body.appendChild(container);
592 |
593 | let addToQueueButton = appendAddToQueueButton(container, 0, c_addToQueueButtonText, appendQueueItem, "Add an item to the queue according to current tab and settings");
594 | let addToQueueButtonA1 = appendAddToQueueButton(container, 25, 'A1', () => {appendQueueItem(null, null, null, JSON.parse(conf.scriptSettings.overwriteQueueSettings1.value)) }, "Add an item to the queue according to current tab and settings and overwrite with Alt 1",63);
595 | let addToQueueButtonA2 = appendAddToQueueButton(container, 25, 'A2', () => {appendQueueItem(null, null, null, JSON.parse(conf.scriptSettings.overwriteQueueSettings2.value)) }, "Add an item to the queue according to current tab and settings and overwrite with Alt 2",32);
596 | let addToQueueButtonA3 = appendAddToQueueButton(container, 25, 'A3', () => {appendQueueItem(null, null, null, JSON.parse(conf.scriptSettings.overwriteQueueSettings3.value)) }, "Add an item to the queue according to current tab and settings and overwrite with Alt 3",1);
597 | let unsupportedButton = appendAddToQueueButton(container, 0, 'Tab not supported', function(){}, "Not supported");
598 | unsupportedButton.disabled = true;
599 | unsupportedButton.innerHTML = 'Tab not supported';
600 | unsupportedButton.style.cursor = 'not-allowed';
601 |
602 | let defaultQueueQuantity = document.createElement('input');
603 | defaultQueueQuantity.placeholder = 'Def #';
604 | defaultQueueQuantity.style.height = c_uiElemntHeightSmall;
605 | defaultQueueQuantity.style.width = '50px';
606 | defaultQueueQuantity.type = 'number';
607 | defaultQueueQuantity.title = "How many items of each will be added to the queue (default is 1)";
608 | defaultQueueQuantity.value = conf.scriptSettings.defaultQuantity.value;
609 | defaultQueueQuantity.onchange = function() {conf.scriptSettings.defaultQuantity.value = this.value;};
610 | defaultQueueQuantity.onfocus = function() {this.select();};
611 | container.appendChild(defaultQueueQuantity);
612 | let assignDefaultToAll = document.createElement('button');
613 | assignDefaultToAll.innerHTML = ' ⤵';
614 | assignDefaultToAll.style.cursor = "pointer";
615 | assignDefaultToAll.title = "Assign the default value to all queue items";
616 | assignDefaultToAll.style.height = c_uiElemntHeight;
617 | assignDefaultToAll.style.marginRight = '10px';
618 | assignDefaultToAll.onclick = function() {
619 | if(conf.scriptSettings.defaultQuantity.value >= 0) {
620 | document.querySelectorAll('.AWQ-item-quantity').forEach((inp) => {inp.value = conf.scriptSettings.defaultQuantity.value});
621 | updateQueueState();
622 | }
623 | };
624 | container.appendChild(assignDefaultToAll);
625 |
626 | let processButton = document.createElement('button');
627 | processButton.innerHTML = c_processButtonText;
628 | processButton.style.height = c_uiElemntHeight;
629 | processButton.style.cursor = "pointer";
630 | processButton.title = "Start processing the queue, click again to stop";
631 | processButton.onclick = function() {
632 | toggleProcessButton();
633 | }
634 | conf.ui.processButton = processButton;
635 | container.appendChild(processButton);
636 |
637 | let clearButton = document.createElement('button');
638 | clearButton.innerHTML = "Clear queue";
639 | clearButton.style.marginLeft = "5px";
640 | clearButton.style.height = c_uiElemntHeight;
641 | clearButton.style.cursor = "pointer";
642 | clearButton.title = "Empty the queue completely";
643 | clearButton.onclick = function() {
644 | if(!confirm('Are you sure you want to remove everything in your queue?')) return;
645 | queueContainer.innerHTML = c_emptyQueueString;
646 | let oldQueueLength = conf.currentQueue.length;
647 | conf.currentQueue = [];
648 | updateQueueState();
649 | awqLogPublishMsg(`Queue has been cleared, ${oldQueueLength} items removed`);
650 | }
651 | container.appendChild(clearButton);
652 |
653 | let scriptSettingsButton = document.createElement('button');
654 | scriptSettingsButton.innerHTML = "Script settings";
655 | scriptSettingsButton.style.float = 'right';
656 | scriptSettingsButton.style.height = c_uiElemntHeight;
657 | scriptSettingsButton.style.cursor = "pointer";
658 | scriptSettingsButton.title = "Open the settings popup for the script";
659 | scriptSettingsButton.onclick = openScriptSettingsPopup;
660 | container.appendChild(scriptSettingsButton);
661 |
662 |
663 | let queueContainer = document.createElement('div');
664 | queueContainer.style.width = c_innerUIWidth;
665 | queueContainer.style.border = "1px solid white";
666 | queueContainer.style.color = "gray";
667 | queueContainer.style.marginBottom = "5px";
668 | queueContainer.innerHTML = c_emptyQueueString;
669 | container.appendChild(queueContainer);
670 |
671 |
672 |
673 | let clearSettingButton = document.createElement('button');
674 | clearSettingButton.innerHTML = "❌";
675 | clearSettingButton.style.height = c_uiElemntHeight;
676 | clearSettingButton.style.background = 'none';
677 | clearSettingButton.onclick = function() {clearSetting(); }
678 | clearSettingButton.style.cursor = "pointer";
679 | clearSettingButton.title = "Remove the currently selected setting";
680 | container.appendChild(clearSettingButton);
681 | let settingsStorage = document.createElement('select');
682 | settingsStorage.style.height = c_uiElemntHeight;
683 | settingsStorage.title = "List of stored settings (template of all settings)";
684 | container.appendChild(settingsStorage);
685 | let editSettingButton = document.createElement('button');
686 | editSettingButton.innerHTML = "✏️";
687 | editSettingButton.style.height = c_uiElemntHeight;
688 | editSettingButton.onclick = function() {editSetting(); }
689 | editSettingButton.style.cursor = "pointer";
690 | editSettingButton.title = "Edit the currently selected setting (a property can be removed to not change it when loading)";
691 | container.appendChild(editSettingButton);
692 | let loadSettingButton = document.createElement('button');
693 | loadSettingButton.innerHTML = "Load";
694 | loadSettingButton.style.height = c_uiElemntHeight;
695 | loadSettingButton.onclick = function() {loadSetting(); }
696 | loadSettingButton.style.cursor = "pointer";
697 | loadSettingButton.title = "Load the currently selected setting (replacing current settings)";
698 | container.appendChild(loadSettingButton);
699 | let settingName =document.createElement('input');
700 | settingName.placeholder = "Setting name";
701 | settingName.style.height = c_uiElemntHeightSmall;
702 | settingName.title = "Name to use when saving a new setting (duplicates not allowed)";
703 | settingName.onfocus = function() {this.select();};
704 | container.appendChild(settingName);
705 | let saveSettingButton = document.createElement('button');
706 | saveSettingButton.innerHTML = "Save";
707 | saveSettingButton.style.height = c_uiElemntHeight;
708 | saveSettingButton.onclick = function() {saveSettings(); }
709 | saveSettingButton.style.cursor = "pointer";
710 | saveSettingButton.title = "Save currently selected settings so that you can load them again later";
711 | container.appendChild(saveSettingButton);
712 |
713 |
714 |
715 | let outputConsole = document.createElement('div');
716 | outputConsole.title = c_defaultOtputConsoleText;
717 | outputConsole.innerHTML = c_defaultOtputConsoleTextHTML;
718 | outputConsole.style.width = 'calc(100vw - 50px)';
719 | outputConsole.style.border = "1px solid black";
720 | outputConsole.style.color = "gray";
721 | outputConsole.style.padding = "2px";
722 | outputConsole.style.marginTop = "5px";
723 | outputConsole.style.marginBottom = "5px";
724 | outputConsole.style.marginLeft = "15px";
725 | outputConsole.style.marginRight = "15px";
726 | outputConsole.style.height = (16*10)+"px";
727 | outputConsole.style.overflow = "auto";
728 | //outputConsole.style.backgroundColor = "white";
729 | outputConsole.style.boxShadow = 'inset 0px 1px 4px #666';
730 | container.appendChild(outputConsole);
731 |
732 | let outputConsoleClearButton = document.createElement('button');
733 | outputConsoleClearButton.innerHTML = "Clear";
734 | outputConsoleClearButton.style.height = c_uiElemntHeight;
735 | outputConsoleClearButton.onclick = function() {conf.ui.outputConsole.innerHTML = c_defaultOtputConsoleTextHTML; }
736 | outputConsoleClearButton.style.cursor = "pointer";
737 | outputConsoleClearButton.style.marginLeft = "10px";
738 | outputConsoleClearButton.title = "Clear the console above";
739 | container.appendChild(outputConsoleClearButton);
740 |
741 |
742 | conf.ui.addToQueueButton = addToQueueButton;
743 | conf.ui.addToQueueButtonA1 = addToQueueButtonA1;
744 | conf.ui.addToQueueButtonA2 = addToQueueButtonA2;
745 | conf.ui.addToQueueButtonA3 = addToQueueButtonA3;
746 | conf.ui.unsupportedButton = unsupportedButton;
747 |
748 | conf.ui.queueContainer = queueContainer;
749 | conf.ui.clearButton = clearButton;
750 | conf.ui.loadSettingButton = loadSettingButton;
751 | conf.ui.settingName = settingName;
752 | conf.ui.settingsStorage = settingsStorage;
753 | conf.ui.defaultQueueQuantity = defaultQueueQuantity;
754 | conf.ui.outputConsole = outputConsole;
755 |
756 | document.querySelector('.gradio-container').style.overflow = 'visible'; // Fix so that a dropdown menu can overlap the queue
757 |
758 | refreshSettings();
759 |
760 | if(conf.currentQueue.length > 0) {
761 | awqLog('Loaded saved queue:'+conf.currentQueue.length);
762 | for(let i = 0; i < conf.currentQueue.length; i++) {
763 | appendQueueItem(conf.currentQueue[i].quantity, conf.currentQueue[i].value, conf.currentQueue[i].type);
764 | }
765 | updateQueueState();
766 | }
767 | awqLog('generateMainUI: Completed');
768 | }
769 |
770 | function appendQueueItem(p_quantity, p_value, p_type, p_overwrite_data) {
771 | awqLog('appendQueueItem: quantity:' + p_quantity + ' type:' + p_type);
772 | let quantity = isNaN(p_quantity) || p_quantity == null ?
773 | (parseInt(conf.ui.defaultQueueQuantity.value) > 0 ?
774 | parseInt(conf.ui.defaultQueueQuantity.value) : 1) : p_quantity;
775 |
776 | let queueItem = document.createElement('div');
777 | queueItem.style.width = c_innerUIWidth;
778 | let itemType =document.createElement('input');
779 | itemType.classList = 'AWQ-item-type';
780 | itemType.style.display = "50px";
781 | itemType.style.height = c_uiElemntHeightSmall;
782 | itemType.style.width = "20px";
783 | itemType.title = "This is the type/tab for the queue item";
784 | itemType.disabled = true;
785 | let itemQuantity = document.createElement('input');
786 | function updateItemQuantityBG() {
787 | if(itemQuantity.value.length == 0) { itemQuantity.style.color = 'red'; }
788 | else if(itemQuantity.value < 1) { itemQuantity.style.color = 'rgb(0, 225, 0)'; itemQuantity.classList.add('completed-queue-item') }
789 | else if(itemQuantity.value > 0) { itemQuantity.style.color = 'white'; itemQuantity.classList.remove('completed-queue-item')}
790 | }
791 | itemQuantity.classList = 'AWQ-item-quantity';
792 | itemQuantity.value = quantity;
793 | itemQuantity.style.width = "50px";
794 | itemQuantity.type = 'number';
795 | itemQuantity.style.height = c_uiElemntHeightSmall;
796 | itemQuantity.onchange = function() {
797 | updateItemQuantityBG();
798 | updateQueueState();
799 | };
800 | updateItemQuantityBG();
801 | itemQuantity.onfocus = function() {this.select();};
802 | itemQuantity.title = "This is how many times this item should be executed";
803 | let itemJSON =document.createElement('input');
804 | itemJSON.classList = 'AWQ-item-JSON';
805 | itemJSON.value = p_value || getValueJSON(p_type);
806 | if(p_overwrite_data) {
807 | awqLog(`appendQueueItem: Adding to queue with Overwriting: ${JSON.stringify(p_overwrite_data)}`);
808 | let jsonData = JSON.parse(itemJSON.value);
809 | for(let setKey in p_overwrite_data) {
810 | jsonData[setKey] = p_overwrite_data[setKey];
811 | }
812 | itemJSON.value = JSON.stringify(jsonData);
813 | }
814 | itemJSON.style.width = "calc(100vw - 290px)";
815 | itemJSON.style.height = "18px";
816 | itemJSON.onchange = function() {
817 | updateQueueState();
818 | // Update itemType if needed
819 | let newType = itemJSON.value.match(/"type":"([^"]+)"/);
820 | newType = newType ? newType[1] : null;
821 | if(newType != itemType.value) itemType.value = newType;
822 | }
823 | itemJSON.title = "This is a JSON string with all the settings to be used for this item. Can be changed while processing the queue but will fail if you enter invalid values.";
824 |
825 | let JSONType = itemJSON.value.match(/"type":"([^"]+)"/);
826 | JSONType = JSONType ? JSONType[1] : conf.commonData.activeType;
827 | itemType.value = p_type || JSONType;
828 |
829 | let removeItem =document.createElement('button');
830 | removeItem.innerHTML = '❌';
831 | removeItem.style.height = c_uiElemntHeight;
832 | removeItem.style.background = 'none';
833 | removeItem.style.cursor = "pointer";
834 | removeItem.title = "Remove this item from the queue";
835 | removeItem.onclick = function() {
836 | this.parentNode.parentNode.removeChild(this.parentNode);
837 | updateQueueState();
838 | awqLogPublishMsg(`Removed queue item`);
839 | };
840 | let moveItemUp =document.createElement('button');
841 | moveItemUp.innerHTML = '⇧';
842 | moveItemUp.style.height = c_uiElemntHeight;
843 | moveItemUp.style.cursor = "pointer";
844 | moveItemUp.title = "Move this item up in the queue";
845 | moveItemUp.onclick = function() {
846 | let tar = this.parentNode;
847 | if(tar.previousSibling) {
848 | tar.parentNode.insertBefore(tar, tar.previousSibling);
849 | awqLogPublishMsg(`Rearranged queue`);
850 | updateQueueState();
851 | }
852 |
853 | };
854 | let moveItemDown =document.createElement('button');
855 | moveItemDown.innerHTML = '⇩';
856 | moveItemDown.style.height = c_uiElemntHeight;
857 | moveItemDown.style.cursor = "pointer";
858 | moveItemDown.title = "Move this item down in the queue";
859 | moveItemDown.onclick = function() {
860 | let tar = this.parentNode;
861 | if(tar.nextSibling) {
862 | tar.parentNode.insertBefore(tar.nextSibling, tar);
863 | awqLogPublishMsg(`Rearranged queue`);
864 | updateQueueState();
865 | }
866 | };
867 | let moveItemBottom =document.createElement('button');
868 | moveItemBottom.innerHTML = '⤓';
869 | moveItemBottom.style.height = c_uiElemntHeight;
870 | moveItemBottom.style.cursor = "pointer";
871 | moveItemBottom.title = "Move this item to the bottom of the queue";
872 | moveItemBottom.onclick = function() {
873 | let tar = this.parentNode;
874 | if(tar.parentNode.lastChild !== tar) {
875 | tar.parentNode.appendChild(tar);
876 | updateQueueState();
877 | }
878 | };
879 | let moveItemTop =document.createElement('button');
880 | moveItemTop.innerHTML = '⤒';
881 | moveItemTop.style.height = c_uiElemntHeight;
882 | moveItemTop.style.cursor = "pointer";
883 | moveItemTop.title = "Move this item to the top of the queue";
884 | moveItemTop.onclick = function() {
885 | let tar = this.parentNode;
886 | let parentFirstChild = tar.parentNode.firstChild;
887 | if(parentFirstChild && parentFirstChild !== tar) {
888 | tar.parentNode.insertBefore(tar, parentFirstChild);
889 | awqLogPublishMsg(`Rearranged queue`);
890 | updateQueueState();
891 | }
892 | };
893 | let loadItem =document.createElement('button');
894 | loadItem.innerHTML = 'Load';
895 | loadItem.style.height = c_uiElemntHeight;
896 | loadItem.style.cursor = "pointer";
897 | loadItem.title = "Load the settings from this item";
898 | loadItem.onclick = async function() {
899 | let itemRow = this.parentNode;
900 | await loadJson(itemRow.querySelector('.AWQ-item-JSON').value);
901 | };
902 |
903 | queueItem.appendChild(removeItem);
904 | queueItem.appendChild(moveItemUp);
905 | queueItem.appendChild(moveItemDown);
906 | queueItem.appendChild(moveItemBottom);
907 | queueItem.appendChild(moveItemTop);
908 | queueItem.appendChild(loadItem);
909 | queueItem.appendChild(itemType);
910 | queueItem.appendChild(itemQuantity);
911 | queueItem.appendChild(itemJSON);
912 |
913 | if(conf.ui.queueContainer.innerHTML == c_emptyQueueString) conf.ui.queueContainer.innerHTML = "";
914 | conf.ui.queueContainer.appendChild(queueItem);
915 |
916 | awqLogPublishMsg(`Added new ${itemType.value} queue item (${quantity}x)`);
917 | // Wait with updating state while loading a predefined queue
918 | if(isNaN(p_quantity)) updateQueueState();
919 | }
920 |
921 | function saveScriptSettings() {
922 | awqLog('Saving script settings');
923 | let scriptSettingsCopy = structuredClone(conf.scriptSettings);
924 |
925 | // Delete data that does not need to be saved
926 | for(let ssk in scriptSettingsCopy) {
927 | for(let ssk2 in scriptSettingsCopy[ssk]) {
928 | if(ssk2 != 'value') delete scriptSettingsCopy[ssk][ssk2];
929 | }
930 | }
931 |
932 | conf.ui.defaultQueueQuantity.value = conf.scriptSettings.defaultQuantity.value; // Update beacuse this one is in two places
933 | localStorage.awqScriptSettings = JSON.stringify(scriptSettingsCopy);
934 | }
935 |
936 | function loadScriptSettings(p_scriptSettings) {
937 | if(!localStorage.hasOwnProperty("awqScriptSettings") || !isJsonString(localStorage.awqScriptSettings)) return;
938 | awqLog('Loding saved script settings');
939 |
940 | let savedSettings = p_scriptSettings || JSON.parse(localStorage.awqScriptSettings);
941 | for(let ssk in conf.scriptSettings) {
942 | if(savedSettings.hasOwnProperty(ssk)) conf.scriptSettings[ssk].value = savedSettings[ssk].value;
943 | }
944 | }
945 |
946 | function openScriptSettingsPopup() {
947 | let dialog = document.createElement('span');
948 | dialog.id = 'awq-script-settings-popup';
949 | dialog.className = document.querySelector('gradio-app > div').classList.contains('dark') ? 'dark' : '';
950 | dialog.style.minWidth = '90%';
951 | dialog.style.minHeight = '90%';
952 | dialog.style.marginLeft = '5%';
953 | dialog.style.marginTop = '5%';
954 | dialog.style.top = '0';
955 | dialog.style.position = 'fixed';
956 | dialog.style.zIndex = '1000';
957 | dialog.style.borderRadius = '15px';
958 | dialog.style.boxShadow = '3px 3px 100px black,3px 3px 500px black, 3px 3px 25px black, inset 0 0 10px black';
959 |
960 | let titleText = document.createElement('span');
961 | titleText.innerHTML = 'Script settings - hold your mouse over an item for a description';
962 | titleText.style.top = '5px';
963 | titleText.style.left = '10px';
964 | titleText.style.position = 'absolute';
965 |
966 | let closeButton = document.createElement('span');
967 | closeButton.style.position = 'absolute';
968 | closeButton.style.top = '5px';
969 | closeButton.style.right = '10px';
970 | closeButton.style.textShadow = '#292929 2px 3px 5px';
971 | closeButton.style.cursor = 'pointer';
972 | closeButton.onclick = function() {document.body.removeChild(dialog); saveScriptSettings();};
973 | closeButton.innerHTML = '⛌';
974 |
975 | let dialogBody = document.createElement('span');
976 | dialogBody.style.width = '90%';
977 | dialogBody.style.height = '90%';
978 | dialogBody.style.marginLeft = '5%';
979 | dialogBody.style.marginTop = 'max(5%,45px)';
980 | dialogBody.style.top = '0';
981 | dialogBody.style.position = 'absolute';
982 | dialogBody.style.overflow = 'auto';
983 | dialogBody.style.display = 'grid';
984 | dialogBody.style.gridAutoFlow = 'row';
985 | dialogBody.style.gridTemplateColumns = 'repeat(auto-fit, minmax(200px, 1fr))';
986 |
987 | dialog.appendChild(titleText);
988 | dialog.appendChild(closeButton);
989 | dialog.appendChild(dialogBody);
990 |
991 | // Create input for each script setting
992 | for(let ssKey in conf.scriptSettings) {
993 | let ssObj = conf.scriptSettings[ssKey];
994 |
995 | let ssElem = document.createElement(ssObj.type == 'text' ? 'textarea' : 'input');
996 | ssElem.id = 'awq-ss-'+ssKey;
997 | ssElem.placeholder = ssObj.name;
998 | ssElem.value = ssObj.value;
999 | ssElem.style.height = ssObj.type == 'text' ? '40px' : '20px';
1000 | ssElem.style.marginRight = '20px';
1001 | ssElem.onchange = function() {
1002 | conf.scriptSettings[ssKey].value = ssObj.type == 'boolean' ? this.checked : this.value;
1003 | saveScriptSettings();
1004 | };
1005 | if(ssObj.type == 'boolean') ssElem.type = 'checkbox';
1006 | if(ssObj.type == 'numeric') {
1007 | ssElem.type = 'number' ;
1008 | ssElem.inputmode = 'numeric';
1009 | ssElem.onkeypress = e => { if (e.key.match(/\D/g)) { e.preventDefault();} };
1010 | }
1011 | if(ssObj.type == 'boolean') {
1012 | ssElem.type = 'checkbox';
1013 | ssElem.checked = ssObj.value;
1014 | }
1015 |
1016 | let cbLabel = document.createElement('label');
1017 | cbLabel.for = ssElem.id;
1018 | cbLabel.innerHTML = ssObj.name;
1019 | cbLabel.title = ssObj.description;
1020 |
1021 | let ssElemContainer = document.createElement('span');
1022 |
1023 | ssElemContainer.appendChild(cbLabel);
1024 |
1025 |
1026 | if(ssObj.description.match("http")) {
1027 | let helpLink = document.createElement('a');
1028 | helpLink.innerHTML = '❓';
1029 | helpLink.target = '_blank';
1030 | helpLink.href = ssObj.description;
1031 | helpLink.style.textDecoration = 'none';
1032 | ssElem.title = ssObj.name;
1033 | ssElemContainer.appendChild(helpLink);
1034 | } else {
1035 | ssElem.title = ssObj.description;
1036 | }
1037 |
1038 | ssElemContainer.appendChild(ssElem);
1039 |
1040 | dialogBody.appendChild(ssElemContainer);
1041 | }
1042 |
1043 |
1044 |
1045 | let importExportButton = document.createElement('button');
1046 | importExportButton.innerHTML = "Import/export";
1047 | importExportButton.style.height = c_uiElemntHeight;
1048 | importExportButton.style.cursor = "pointer";
1049 | importExportButton.title = "Import or export all the data for this script (to import add previoiusly exported data to the right, to export leave it empty). Importing data will reload the page!";
1050 | importExportButton.onclick = exportImport;
1051 | let importExportData = document.createElement('input');
1052 | importExportData.id = 'import-export-data-input';
1053 | importExportData.placeholder = 'Import/export data';
1054 | importExportData.style.height = c_uiElemntHeightSmall;
1055 | importExportData.style.width = '125px';
1056 | importExportData.title = "Exported data will be show here, add data here to import it. Importing data will reload the page!";
1057 | importExportData.onfocus = function() {this.select();};
1058 | let importExportContainer = document.createElement('span');
1059 | importExportContainer.appendChild(importExportButton);
1060 | importExportContainer.appendChild(importExportData);
1061 | dialogBody.appendChild(importExportContainer);
1062 |
1063 |
1064 |
1065 | // *** Search & Replace *** START
1066 | // Add replace in queue function GUI
1067 | let collectedAttributes = {};
1068 | let anyOption = document.createElement('option');
1069 | anyOption.value = c_any_value;
1070 | conf.currentQueue.map(el => { // Fetch all attributes and values currently in queue
1071 | let queueObject = JSON.parse(el.value);
1072 | Object.keys(queueObject).forEach(function(key,index) {
1073 | if(!collectedAttributes[key]) collectedAttributes[key] = {};
1074 | collectedAttributes[key][queueObject[key]] = '';
1075 | });
1076 | });
1077 | let componentOptions = [];
1078 | window.gradio_config.components.forEach(el => {
1079 | if(el.props && el.props.choices) {
1080 | componentOptions.push(el.props.choices);
1081 | }
1082 | });
1083 |
1084 | let replaceLabel = document.createElement('label');
1085 | replaceLabel.innerHTML = 'Search and replace';
1086 | replaceLabel.style.display = 'block';
1087 | replaceLabel.title = 'Here you can search for values in the queue and replace them with something else';
1088 | let replaceAttributeSelectorLabel = document.createElement('label');
1089 | replaceAttributeSelectorLabel.innerHTML = 'Attribute';
1090 | replaceAttributeSelectorLabel.title = 'Choose the attribute to replace inside of ( to replace in any attribute)';
1091 | let replaceAttributeSelector = document.createElement('input');
1092 | replaceAttributeSelector.setAttribute('list','awq-replace-attrib-dataset');
1093 | replaceAttributeSelector.className = 'awq-right-align-placeholder';
1094 | replaceAttributeSelector.placeholder='▼';
1095 | replaceAttributeSelector.type = 'text';
1096 | replaceAttributeSelector.title = replaceAttributeSelectorLabel.title;
1097 | replaceAttributeSelector.onfocus = function() {this.select();};
1098 | let replaceAttributeSelectorDataset = document.createElement('datalist');
1099 | replaceAttributeSelectorDataset.id = 'awq-replace-attrib-dataset';
1100 | replaceAttributeSelectorDataset.appendChild(anyOption);
1101 | Object.keys(collectedAttributes).forEach(function(key,index) { // Add all attributes from queue
1102 | let attribOption = document.createElement('option');
1103 | attribOption.value = key;
1104 | replaceAttributeSelectorDataset.appendChild(attribOption);
1105 |
1106 | });
1107 | let replaceValueSelectorLabel = document.createElement('label');
1108 | replaceValueSelectorLabel.innerHTML = 'Old value';
1109 | replaceValueSelectorLabel.style.display = 'block';
1110 | replaceValueSelectorLabel.title = 'Find this value and replace it with the one below ( to replace anything)';
1111 | let replaceValueSelector = document.createElement('input');
1112 | replaceValueSelector.setAttribute('list','awq-replace-value-dataset');
1113 | replaceValueSelector.className = 'awq-right-align-placeholder';
1114 | replaceValueSelector.placeholder='▼';
1115 | replaceValueSelector.type = 'text';
1116 | replaceValueSelector.title = replaceValueSelectorLabel.title;
1117 | replaceValueSelector.onfocus = function() {this.select();};
1118 | let replaceValueSelectorDataset = document.createElement('datalist');
1119 | replaceValueSelectorDataset.id = 'awq-replace-value-dataset';
1120 | let replaceContainer = document.createElement('span');
1121 | let replaceNewValueSelectorLabel = document.createElement('label');
1122 | replaceNewValueSelectorLabel.innerHTML = 'New value';
1123 | replaceNewValueSelectorLabel.style.display = 'block';
1124 | let replaceNewValueSelector = document.createElement('input');
1125 | replaceNewValueSelector.setAttribute('list','awq-replace-new-value-dataset');
1126 | replaceNewValueSelector.className = 'awq-right-align-placeholder';
1127 | replaceNewValueSelector.placeholder='▼';
1128 | replaceNewValueSelector.type = 'text';
1129 | replaceNewValueSelector.title = 'The value to replace with';
1130 | replaceNewValueSelector.onfocus = function() {this.select();};
1131 | let replaceNewValueSelectorDataset = document.createElement('datalist');
1132 | replaceNewValueSelectorDataset.id = 'awq-replace-new-value-dataset';
1133 |
1134 | let replaceButton = document.createElement('button');
1135 | replaceButton.innerHTML = "Replace";
1136 |
1137 | replaceContainer.appendChild(replaceLabel);
1138 | replaceContainer.appendChild(replaceAttributeSelectorLabel);
1139 | replaceContainer.appendChild(replaceAttributeSelector);
1140 | replaceContainer.appendChild(replaceAttributeSelectorDataset);
1141 | replaceContainer.appendChild(replaceValueSelectorLabel);
1142 | replaceContainer.appendChild(replaceValueSelector);
1143 | replaceContainer.appendChild(replaceValueSelectorDataset);
1144 | replaceContainer.appendChild(replaceNewValueSelectorLabel);
1145 | replaceContainer.appendChild(replaceNewValueSelector);
1146 | replaceContainer.appendChild(replaceNewValueSelectorDataset);
1147 | replaceContainer.appendChild(replaceButton);
1148 | dialogBody.appendChild(replaceContainer);
1149 |
1150 | function updateReplaceValueSelectorDataset() {
1151 | let foundValues = collectedAttributes[replaceAttributeSelector.value];
1152 | replaceValueSelectorDataset.innerHTML = '';
1153 | replaceValueSelectorDataset.appendChild(anyOption.cloneNode());
1154 | if(foundValues) {
1155 | replaceValueSelectorDataset.innerHTML = '';
1156 | replaceValueSelectorDataset.appendChild(anyOption.cloneNode());
1157 | Object.keys(foundValues).forEach(function(key,index) { // Add all possible values for currently selected attribute
1158 | let valueOption = document.createElement('option');
1159 | valueOption.value = key;
1160 | replaceValueSelectorDataset.appendChild(valueOption);
1161 | });
1162 | } else {
1163 | Object.keys(collectedAttributes).forEach(function(key,index) {
1164 | let attrib = collectedAttributes[key];
1165 | Object.keys(attrib).forEach(function(innerKey,innerIndex) {
1166 | let valueOption = document.createElement('option');
1167 | valueOption.value = innerKey;
1168 | replaceValueSelectorDataset.appendChild(valueOption);
1169 | });
1170 | });
1171 | }
1172 | }
1173 | function updateReplaceNewValueSelectorDataset() {
1174 | let matchingValues = [];
1175 | // Any components that has the option we are trying to replace?
1176 | componentOptions.forEach(arr => { if(arr.includes(replaceValueSelector.value)) matchingValues.push(arr) });
1177 |
1178 | // If not add all their options
1179 | if(matchingValues.length == 0) {
1180 | matchingValues = [...componentOptions];
1181 | }
1182 |
1183 | // Remove duplicates and replace dataset options
1184 | replaceNewValueSelectorDataset.innerHTML = '';
1185 | [...new Set(matchingValues.flat())].forEach(el => {
1186 | let valueOption = document.createElement('option');
1187 | valueOption.value = el;
1188 | replaceNewValueSelectorDataset.appendChild(valueOption);
1189 | });
1190 | }
1191 | updateReplaceNewValueSelectorDataset();
1192 |
1193 | replaceAttributeSelector.onchange = function() { updateReplaceValueSelectorDataset(); }
1194 | replaceValueSelector.onchange = function() { updateReplaceNewValueSelectorDataset(); }
1195 | updateReplaceValueSelectorDataset();
1196 |
1197 | // Handle clicking the search and replace button
1198 | replaceButton.onclick = function() {
1199 | let attributeValue = replaceAttributeSelector.value
1200 | let anyAttribute = attributeValue == c_any_value;
1201 | let oldValue = replaceValueSelector.value;
1202 | let anyOldValue = oldValue == c_any_value;
1203 | let currentQueue = conf.currentQueue;
1204 | let newValue = replaceNewValueSelector.value;
1205 |
1206 | Object.keys(currentQueue).forEach(function(key,index) { // Loop queue entries
1207 | let queueElentry = JSON.parse(currentQueue[key].value);
1208 | if(anyAttribute) {
1209 | Object.keys(queueElentry).forEach(function(keyInner,indexInner) { // Loop queue entry attributes
1210 | if(anyOldValue) {
1211 | // Replace everything with the new value (why are you doing this?)
1212 | if(newValue != queueElentry[keyInner]) awqLog(`replaceButton: updated queue item ${key} attribute ${keyInner} to ${newValue}`);
1213 | queueElentry[keyInner] = newValue;
1214 | } else {
1215 | // Search and replace in all attributes
1216 | let replacedValue = queueElentry[keyInner].replaceAll ? queueElentry[keyInner].replaceAll(oldValue,newValue) : queueElentry[keyInner];
1217 | if(replacedValue != queueElentry[keyInner]) awqLog(`replaceButton: updated queue item ${key} attribute ${keyInner} to ${replacedValue}`);
1218 | queueElentry[keyInner] = replacedValue;
1219 | }
1220 | });
1221 | } else {
1222 | if(anyOldValue) {
1223 | // Replace all values for this attribute
1224 | if(newValue != queueElentry[attributeValue]) awqLog(`replaceButton: updated queue item ${key} attribute ${attributeValue} to ${newValue}`);
1225 | queueElentry[attributeValue] = newValue;
1226 | } else {
1227 | // Replace string in specific attribute
1228 | let replacedValue = queueElentry[attributeValue].replaceAll(oldValue,newValue);
1229 | if(replacedValue != queueElentry[attributeValue]) awqLog(`replaceButton: updated queue item ${key} attribute ${attributeValue} to ${replacedValue}`);
1230 | queueElentry[attributeValue] = replacedValue;
1231 | }
1232 | }
1233 | let newJson = JSON.stringify(queueElentry);
1234 |
1235 | currentQueue[key].value = JSON.stringify(queueElentry);
1236 | });
1237 |
1238 | // Update state
1239 | let queueElems = conf.ui.queueContainer.querySelectorAll('.AWQ-item-JSON');
1240 | for(let i=0; i < currentQueue.length; i++) {
1241 | queueElems[i].value = currentQueue[i].value;
1242 | }
1243 | updateQueueState();
1244 | }
1245 |
1246 | // *** Search & Replace *** STOP
1247 |
1248 |
1249 | document.body.appendChild(dialog);
1250 |
1251 |
1252 | // Customize behaviour of the opacity button to show immediate effect
1253 | let opacityButton = document.getElementById('awq-ss-buttonOpacity');
1254 | opacityButton.type = 'range';
1255 | opacityButton.min = 0;
1256 | opacityButton.max = 1;
1257 | opacityButton.step = 0.1;
1258 | opacityButton.onchange = function() {
1259 | document.querySelectorAll('.awq-hover-button').forEach(function(elem) {
1260 | conf.scriptSettings.buttonOpacity.value = opacityButton.value;
1261 | elem.style.opacity = conf.scriptSettings.buttonOpacity.value;
1262 | });
1263 | };
1264 | }
1265 |
1266 | function toggleProcessButton(p_set_processing) {
1267 | awqLog('toggleProcessButton:' + p_set_processing);
1268 | let pb = conf.ui.processButton;
1269 | let undefinedInput = typeof p_set_processing == 'undefined';
1270 |
1271 | if(undefinedInput) {
1272 | toggleProcessButton(!conf.commonData.processing);
1273 | } else if (p_set_processing) {
1274 | awqLogPublishMsg('Processing started');
1275 | conf.commonData.processing = true;
1276 | pb.style.background = 'green';
1277 | pb.innerHTML = '⏸︎ ';
1278 | let cogElem = document.createElement('div')
1279 | cogElem.innerHTML = '⚙️';
1280 | cogElem.style.display = 'inline-block';
1281 | pb.appendChild(cogElem);
1282 |
1283 | //cogElem.animate([{ transform: 'rotate(0)' },{transform: 'rotate(360deg)'}], {duration: 1000,iterations: Infinity});
1284 |
1285 | executeAllNewTasks();
1286 | } else {
1287 | awqLogPublishMsg('Processing ended');
1288 | conf.commonData.processing = false;
1289 | conf.commonData.previousTaskStartTime = null;
1290 | pb.style.background = null;
1291 | pb.innerHTML = c_processButtonText;
1292 | }
1293 | }
1294 |
1295 | function updateQueueState() {
1296 | let queueItems = conf.ui.queueContainer.getElementsByTagName('div');
1297 | awqLog('updateQueueState: old length:'+conf.currentQueue.length + ' new length:'+queueItems.length);
1298 |
1299 | let newArray = [];
1300 | for(let i = 0; i < queueItems.length; i++) {
1301 | let newRowObject = {};
1302 | newRowObject.rowid = i;
1303 | newRowObject.type = queueItems[i].querySelector('.AWQ-item-type').value;
1304 | newRowObject.quantity = queueItems[i].querySelector('.AWQ-item-quantity').value;
1305 | newRowObject.value = queueItems[i].querySelector('.AWQ-item-JSON').value;
1306 | newArray.push(newRowObject);
1307 | }
1308 | conf.currentQueue = newArray;
1309 | if(conf.scriptSettings.rememberQueue.value) {
1310 | awqLog('updateQueueState: Saving current queue state '+conf.currentQueue.length);
1311 | localStorage.awqCurrentQueue = JSON.stringify(conf.currentQueue);
1312 | } else {
1313 | awqLog('updateQueueState: Cleared current queue state');
1314 | localStorage.removeItem("awqCurrentQueue");
1315 | }
1316 | }
1317 |
1318 | let stuckProcessingCounter = 0;
1319 | function updateStatus() {
1320 | let previousType = conf.commonData.activeType;
1321 | let previousWorking = conf.commonData.working;
1322 |
1323 | let workingOnI2I = conf.i2i.controls.skipButton.el.getAttribute('style') == 'display: block;';
1324 | let workingOnT2I = conf.t2i.controls.skipButton.el.getAttribute('style') == 'display: block;';
1325 | let workingOnExt = conf.ext.controls.loadingElement.el.innerHTML.length > 0;
1326 |
1327 | // Hide all buttons by default, and then show the right one
1328 | conf.ui.addToQueueButton.style.display = 'none'
1329 | conf.ui.addToQueueButtonA1.style.display = 'none'
1330 | conf.ui.addToQueueButtonA2.style.display = 'none'
1331 | conf.ui.addToQueueButtonA3.style.display = 'none'
1332 | conf.ui.unsupportedButton.style.display = 'none'
1333 |
1334 | if(conf.commonData.i2iContainer.el.style.display !== 'none') {
1335 | conf.commonData.activeType = 'i2i';
1336 | } else if(conf.commonData.t2iContainer.el.style.display !== 'none') {
1337 | conf.commonData.activeType = 't2i';
1338 | } else if(conf.commonData.extContainer.el.style.display !== 'none') {
1339 | conf.commonData.activeType = 'ext';
1340 | } else if(conf.extensions.iBrowser && conf.extensions.iBrowser.guiElems.iBrowserContainer.el.style.display !== 'none') {
1341 | conf.commonData.activeType = 'iBrowser';
1342 | } else {
1343 | conf.commonData.activeType = 'other';
1344 | conf.ui.unsupportedButton.style.display = 'block';
1345 | }
1346 |
1347 | if(conf.commonData.activeType != 'other') {
1348 | conf.ui.addToQueueButton.style.display = 'block';
1349 | conf.ui.addToQueueButtonA1.style.display = 'block';
1350 | conf.ui.addToQueueButtonA2.style.display = 'block';
1351 | conf.ui.addToQueueButtonA3.style.display = 'block';
1352 | }
1353 |
1354 | let typeChanged = conf.commonData.activeType !== previousType ? true : false;
1355 | let workingChanged = conf.commonData.working !== previousWorking ? true : false;
1356 |
1357 | if(typeChanged) awqLog('updateStatus: active type changed to:' + conf.commonData.activeType);
1358 | if(workingChanged) awqLog('updateStatus: Work status changed to:' + conf.commonData.working);
1359 |
1360 | // If no work is being done for a while disable queue
1361 | stuckProcessingCounter = !conf.commonData.waiting && !workingChanged && !conf.commonData.working && conf.commonData.processing ? stuckProcessingCounter + 1 : 0;
1362 | if(stuckProcessingCounter > 30) {
1363 | awqLog('updateStatus: stuck in processing queue status? Disabling queue processing');
1364 | toggleProcessButton(false);
1365 | stuckProcessingCounter = 0;
1366 | playWorkCompleteSound();
1367 | }
1368 | }
1369 | async function executeNewTask() {
1370 | awqLog('executeNewTask: working='+conf.commonData.working + ' processing=' + conf.commonData.processing);
1371 | if(conf.commonData.working) return; // Already working on task
1372 | if(!conf.commonData.processing) return; // Not proicessing queue
1373 |
1374 | if(conf.commonData.previousTaskStartTime) {
1375 | let timeSpent = Date.now() - conf.commonData.previousTaskStartTime;
1376 | awqLogPublishMsg(`Completed work on queue item after ${Math.floor(timeSpent/1000/60)} minutes ${Math.round((timeSpent-Math.floor(timeSpent/60000)*60000)/1000)} seconds `);
1377 | }
1378 |
1379 | let queueItems = conf.ui.queueContainer.getElementsByTagName('div');
1380 | for(let i = 0; i < queueItems.length; i++) {
1381 | let itemQuantity = queueItems[i].querySelector('.AWQ-item-quantity');
1382 | let itemType = queueItems[i].querySelector('.AWQ-item-type').value;
1383 | if(itemQuantity.value > 0) {
1384 | awqLog('executeNewTask: found next work item with index ' + i + ', quantity ' + itemQuantity.value + ' and type ' + itemType);
1385 | await loadJson(queueItems[i].querySelector('.AWQ-item-JSON').value);
1386 | await clickStartButton(itemType);
1387 | conf.commonData.working = true;
1388 | itemQuantity.value = itemQuantity.value - 1;
1389 | itemQuantity.onchange();
1390 | awqLogPublishMsg(`Started working on ${itemType} queue item ${i+1} (${itemQuantity.value} more to go) `);
1391 | conf.commonData.previousTaskStartTime = Date.now();
1392 | await waitForTaskToComplete(itemType);
1393 | return;
1394 | }
1395 | }
1396 | conf.commonData.previousTaskStartTime = null;
1397 | awqLog('executeNewTask: No more tasks found');
1398 | toggleProcessButton(false); // No more tasks to process
1399 | playWorkCompleteSound();
1400 | }
1401 |
1402 | async function executeAllNewTasks() {
1403 | while(conf.commonData.processing) {
1404 | await executeNewTask();
1405 | }
1406 | }
1407 |
1408 | function playWorkCompleteSound() { if(conf.scriptSettings.notificationSound.value) c_audio_base64.play();}
1409 |
1410 | function editSetting() {
1411 | let settingStorage = conf.ui.settingsStorage;
1412 | let settingIndex = settingStorage.selectedIndex;
1413 | let settingOption = settingStorage.options[settingIndex];
1414 | let settingKey = settingOption.innerHTML;
1415 | if(settingKey == c_defaultTextStoredSettings) return;
1416 | awqLog('editSettings: index'+settingIndex);
1417 |
1418 | let editContainer = document.createElement('div');
1419 | editContainer.style.cssText = 'position: fixed;bottom: 0;left: 0;width: 100vw;height: 100vh;background:black;z-index: 9999;';
1420 | let txtInput = document.createElement('input');
1421 | txtInput.style.cssText = 'width: 100vw;height: 10vh;';
1422 | txtInput.title = "Name of the settins set (do not remove the prefix)";
1423 | editContainer.appendChild(txtInput);
1424 | let txtArea = document.createElement('textarea');
1425 | txtArea.style.cssText = 'width: 100vw;height: 80vh;';
1426 | txtArea.title = 'The set of settings i JSON format (Edit the value inside the "" but leave structure intact, an entire propertey: "id":"value" can also be removed if you do not want this setting set to make any changes to that setting)';
1427 | editContainer.appendChild(txtArea);
1428 | let editButton = document.createElement('button');
1429 | editButton.style.cssText = 'width: 50vw;height: 10vh;';
1430 | editButton.innerHTML = 'OK';
1431 | editButton.title = "Save changes";
1432 | editContainer.appendChild(editButton);
1433 | let resetButton = document.createElement('button');
1434 | resetButton.style.cssText = 'width: 50vw;height: 10vh;';
1435 | resetButton.innerHTML = 'Reset';
1436 | resetButton.title = "Revert changes";
1437 | resetButton.onclick = function() {
1438 | txtArea.value = conf.ui.settingsStorage.options[settingIndex].value;
1439 | txtInput.value = conf.ui.settingsStorage.options[settingIndex].text;
1440 | }
1441 | editContainer.appendChild(resetButton);
1442 |
1443 | resetButton.onclick();
1444 |
1445 | document.body.style.overflow = 'hidden';
1446 | document.body.appendChild(editContainer);
1447 |
1448 | editButton.onclick = function() {
1449 | // Validate
1450 | if(txtInput.value.length < 1) {
1451 | alert('Name is missing');
1452 | return;
1453 | }
1454 | if(!isJsonString(txtArea.value)) {
1455 | alert('Value is invalid JSON');
1456 | return;
1457 | }
1458 | if(!['t2i-','i2i-','ext-'].includes(txtInput.value.substr(0,4))) {
1459 | alert('Name does not have valid prefix (t2i-, i2i-, ext-)');
1460 | return;
1461 | }
1462 |
1463 | // Remove overlay
1464 | document.body.style.overflow = 'scroll';
1465 | document.body.removeChild(editContainer);
1466 |
1467 | // Update data and refresh UI
1468 | awqLog('editSettings: updating '+ settingKey + (settingKey == txtInput.value ? '' : ' to ' + txtInput.value));
1469 | delete conf.savedSetting[settingKey];
1470 | conf.savedSetting[txtInput.value] = txtArea.value;
1471 | localStorage.awqSavedSetting = JSON.stringify(conf.savedSetting);
1472 | refreshSettings();
1473 |
1474 | // Select option again
1475 | let optionToSelect = Array.from(settingStorage.options).find(item => item.text ===txtInput.value);
1476 | optionToSelect.selected = true;
1477 | };
1478 | }
1479 |
1480 | function saveSettings() {
1481 | if(conf.ui.settingName.value.length < 1) {alert('Missing name'); return;}
1482 | if(conf.savedSetting.hasOwnProperty(conf.ui.settingName.value)) {alert('Duplicate name'); return;}
1483 |
1484 | let settingSetName = conf.commonData.activeType + '-'+ conf.ui.settingName.value;
1485 | conf.savedSetting[settingSetName] = getValueJSON();
1486 |
1487 | localStorage.awqSavedSetting = JSON.stringify(conf.savedSetting);
1488 |
1489 | awqLogPublishMsg(`Saved new setting set ` + settingSetName);
1490 | refreshSettings();
1491 | }
1492 | function refreshSettings() {
1493 | awqLog('refreshSettings: saved settings:'+Object.keys(conf.savedSetting).length);
1494 | conf.ui.settingName.value = "";
1495 | conf.ui.settingsStorage.innerHTML = "";
1496 |
1497 | for (let prop in conf.savedSetting) {
1498 | let newOption = document.createElement('option');
1499 | newOption.innerHTML = prop;
1500 | newOption.value = conf.savedSetting[prop]
1501 | conf.ui.settingsStorage.appendChild(newOption);
1502 | }
1503 | if(Object.keys(conf.savedSetting).length < 1) {
1504 | let blankOption = document.createElement('option');
1505 | blankOption.innerHTML = c_defaultTextStoredSettings;
1506 | blankOption.value = "";
1507 | conf.ui.settingsStorage.appendChild(blankOption);
1508 | }
1509 | }
1510 | async function loadSetting() {
1511 |
1512 | if(conf.ui.settingsStorage.value.length < 1) return;
1513 | let itemName = conf.ui.settingsStorage.options[conf.ui.settingsStorage.selectedIndex].text;
1514 | let itemType = itemName.split('-')[0];
1515 | awqLog('loadSetting: ' + itemName);
1516 |
1517 | await loadJson(conf.ui.settingsStorage.value);
1518 | }
1519 | function clearSetting() {
1520 | let ss = conf.ui.settingsStorage;
1521 | if(ss.value.length < 1) return;
1522 | awqLogPublishMsg(`Removed setting ` + ss.options[ss.selectedIndex].innerHTML);
1523 | delete conf.savedSetting[ss.options[ss.selectedIndex].innerHTML];
1524 | ss.removeChild(ss.options[ss.selectedIndex]);
1525 |
1526 | localStorage.awqSavedSetting = JSON.stringify(conf.savedSetting);
1527 | if(ss.value.length < 1) refreshSettings();
1528 |
1529 | }
1530 |
1531 | function clickStartButton(p_type) {
1532 | const c_max_time_to_wait = 100;
1533 | let targetButton = conf[conf.commonData.activeType].controls.genrateButton.el;
1534 | awqLog(`clickStartButton: working ${conf.commonData.working} waiting ${conf.commonData.working} type ${p_type}`);
1535 | if(conf.commonData.working || conf.commonData.waiting) return;
1536 |
1537 | targetButton.click();
1538 |
1539 | conf.commonData.waiting = true;
1540 | return new Promise(resolve => {
1541 | let retryCount = 0;
1542 | let waitForSwitchInterval = setInterval(function() {
1543 | retryCount++;
1544 | if(retryCount >= c_max_time_to_wait) {
1545 | targetButton.click(); retryCount = 0;
1546 | awqLog(`Work has not started after ${c_max_time_to_wait/10} seconds, clicked again`);
1547 | }
1548 | if(!webUICurrentyWorkingOn(p_type)) return;
1549 | conf.commonData.waiting = false;
1550 | awqLog('clickStartButton: work has started');
1551 | clearInterval(waitForSwitchInterval);
1552 | resolve();
1553 | },c_wait_tick_duration);
1554 | });
1555 | }
1556 |
1557 | function switchTabAndWait(p_type) {
1558 | if(p_type == conf.commonData.activeType) return;
1559 | awqLog('switchTabAndWait: ' + p_type);
1560 |
1561 | conf.shadowDOM.root.querySelector(conf[p_type].controls.tabButton.sel).click(); // Using .el doesn't work
1562 |
1563 | conf.commonData.waiting = true;
1564 | return new Promise(resolve => {
1565 | let startingTab = conf.commonData.activeType;
1566 | let waitForSwitchInterval = setInterval(function() {
1567 | if(conf.commonData.activeType !== p_type) return;
1568 | conf.commonData.waiting = false;
1569 | awqLogPublishMsg(`Switched active tab from ${startingTab} to ${conf.commonData.activeType}`);
1570 | clearInterval(waitForSwitchInterval);
1571 | resolve();
1572 | },c_wait_tick_duration);
1573 | });
1574 | }
1575 |
1576 | function switchTabAndWaitUntilSwitched(p_targetTabName, p_tabConfig) {
1577 | awqLog('switchTabAndWaitUntilSwitched: p_target=' + p_targetTabName + ' p_config=' + p_tabConfig);
1578 |
1579 | let targetTabConf = p_tabConfig.filter( (elem) => { return elem.name == p_targetTabName })[0];
1580 | function correctTabVisible() {
1581 | return conf.shadowDOM.root.querySelector(targetTabConf.containerSel).style.display == 'none' ? false : true;
1582 | }
1583 |
1584 | if(correctTabVisible()) return;
1585 |
1586 | conf.shadowDOM.root.querySelector(targetTabConf.buttonSel).click();
1587 |
1588 | conf.commonData.waiting = true;
1589 | return new Promise(resolve => {
1590 | let waitForSwitchInterval = setInterval(function() {
1591 | if(!correctTabVisible()) return;
1592 | conf.commonData.waiting = false;
1593 | awqLog('switchTabAndWaitUntilSwitched: switch complete');
1594 | clearInterval(waitForSwitchInterval);
1595 | resolve();
1596 | },c_wait_tick_duration);
1597 | });
1598 | }
1599 |
1600 | function forceGradioUIUpdate() {
1601 | const someCheckboxInputSelector = '#txt2img_subseed_show input';
1602 | document.querySelector(someCheckboxInputSelector).click();
1603 | document.querySelector(someCheckboxInputSelector).click();
1604 | }
1605 |
1606 | function webUICurrentyWorkingOn(p_itemType) {
1607 | if(p_itemType == 'i2i') {
1608 | return conf.i2i.controls.skipButton.el.getAttribute('style') == 'display: block;';
1609 | } else if (p_itemType == 't2i') {
1610 | return conf.t2i.controls.skipButton.el.getAttribute('style') == 'display: block;';
1611 | } else {
1612 | return conf.ext.controls.loadingElement.el.innerHTML.length > 0;
1613 | }
1614 | }
1615 |
1616 | function waitForTaskToComplete(p_itemType) {
1617 | awqLog(`waitForTaskToComplete: Waiting to complete work for ${p_itemType}`);
1618 |
1619 | conf.commonData.waiting = true;
1620 | return new Promise(resolve => {
1621 | let waitForCompleteInterval = setInterval(function() {
1622 | if(webUICurrentyWorkingOn(p_itemType)) return;
1623 | clearInterval(waitForCompleteInterval);
1624 | awqLog(`Work is complete for ${p_itemType}`);
1625 | conf.commonData.waiting = false;
1626 | conf.commonData.working = false;
1627 | resolve();
1628 | },c_wait_tick_duration);
1629 | });
1630 | }
1631 |
1632 | function filterPrompt(p_prompt_text, p_neg) {
1633 | let newPromptText = p_prompt_text;
1634 | let promptFilter = conf.scriptSettings.promptFilter.value.length > 0 ?
1635 | JSON.parse(conf.scriptSettings.promptFilter.value) : [];
1636 |
1637 | for(let i=0; i < promptFilter.length; i++) {
1638 | if(!promptFilter[i].hasOwnProperty('pattern') ||
1639 | !promptFilter[i].hasOwnProperty('flags') ||
1640 | !promptFilter[i].hasOwnProperty('replace')) continue;
1641 |
1642 | let regEx = new RegExp(promptFilter[i].pattern, promptFilter[i].flags);
1643 | let tmpNewPromptText = newPromptText.replace(regEx, promptFilter[i].replace);
1644 |
1645 | if(tmpNewPromptText !== newPromptText) {
1646 | let changesCount = levenshteinDist(newPromptText, tmpNewPromptText);
1647 | awqLogPublishMsg(`Filtered ${p_neg ? '(neg)' : ''}prompt with filter (${promptFilter[i].desc}), ${changesCount} char changes`);
1648 | awqLog(`Filtered from:${newPromptText}
to:${tmpNewPromptText}
`);
1649 | newPromptText = tmpNewPromptText;
1650 | }
1651 | }
1652 | return newPromptText;
1653 | }
1654 |
1655 | function exportImport() {
1656 | let exportJSON = JSON.stringify({
1657 | savedSetting: conf.savedSetting,
1658 | currentQueue: conf.currentQueue,
1659 | scriptSettings: JSON.parse(localStorage.awqScriptSettings), // Use localstorage since it has filtered everything except values
1660 | });
1661 | let exportImportInput = document.getElementById('import-export-data-input');
1662 | let importJSON = exportImportInput.value;
1663 |
1664 | if(importJSON.length < 1) {
1665 | awqLogPublishMsg(`Exported script data`);
1666 | exportImportInput.value = exportJSON;
1667 | exportImportInput.focus();
1668 | exportImportInput.select();
1669 | return;
1670 | }
1671 | if(!isJsonString(importJSON)) {
1672 | alert(`There is something wrong with the import data provided`);
1673 | return;
1674 | } else if(exportJSON == importJSON) {
1675 | alert(`The input data is the same as the current script data`);
1676 | } else {
1677 | awqLog('Data has changed');
1678 | let parsedImportJSON = JSON.parse(importJSON);
1679 | conf.savedSetting = parsedImportJSON.savedSetting;
1680 | conf.currentQueue = parsedImportJSON.currentQueue;
1681 | loadScriptSettings(parsedImportJSON.scriptSettings); // Load with loadScriptSettings to only replace values
1682 | localStorage.awqScriptSettings = JSON.stringify(parsedImportJSON.scriptSettings);
1683 | localStorage.awqSavedSetting = JSON.stringify(conf.savedSetting);
1684 | localStorage.awqCurrentQueue = JSON.stringify(conf.currentQueue);
1685 | location.reload();
1686 | }
1687 | }
1688 | function isJsonString(str) {
1689 | try {
1690 | JSON.parse(str);
1691 | } catch (e) {
1692 | return false;
1693 | }
1694 | return true;
1695 | }
1696 | function sleep(ms) {
1697 | return new Promise(resolve => setTimeout(resolve, ms));
1698 | }
1699 | function stringDiffCount(p_str1, p_str2) {
1700 | let count = 0;
1701 | for(let i = 0; i < p_str1.length; i++){
1702 | if(p_str1[i] === p_str2[i]){
1703 | continue;
1704 | };
1705 | count++;
1706 | };
1707 | return count;
1708 | };
1709 | function getCallStack() {
1710 | try {
1711 | throw new Error();
1712 | } catch (err) {
1713 | return err.stack.replace(/^getCallStack.*\n/, '');
1714 | }
1715 | }
1716 |
1717 | function levenshteinDist(s1, s2) {
1718 | if (s1 === s2) {
1719 | return 0;
1720 | } else {
1721 | var s1_len = s1.length, s2_len = s2.length;
1722 | if (s1_len && s2_len) {
1723 | var i1 = 0, i2 = 0, a, b, c, c2, row = [];
1724 | while (i1 < s1_len) {
1725 | row[i1] = ++i1;
1726 | }
1727 | while (i2 < s2_len) {
1728 | c2 = s2.charCodeAt(i2);
1729 | a = i2;
1730 | ++i2;
1731 | b = i2;
1732 | for (i1 = 0; i1 < s1_len; ++i1) {
1733 | c = a + (s1.charCodeAt(i1) === c2 ? 0 : 1);
1734 | a = row[i1];
1735 | b = b < a ? (b < c ? b + 1 : c) : (a < c ? a + 1 : c);
1736 | row[i1] = b;
1737 | }
1738 | }
1739 | return b;
1740 | } else {
1741 | return s1_len + s2_len;
1742 | }
1743 | }
1744 | };
1745 |
1746 |
1747 | function getValueJSON(p_type) {
1748 | let type = p_type || conf.commonData.activeType;
1749 | awqLog('getValueJSON: type=' + type);
1750 | let valueJSON = {type:type};
1751 |
1752 | if(type == 'ext') { // Needs special saving since it's not an input but a tab switch
1753 | valueJSON.extrasMode = conf.ext.controls.extrasMode.filter((elem) => {
1754 | return conf.shadowDOM.root.querySelector(elem.containerSel).style.display == 'none' ? false : true
1755 | })[0].name;
1756 | valueJSON.extrasResizeMode = conf.ext.controls.extrasResizeMode.filter((elem) => {
1757 | return conf.shadowDOM.root.querySelector(elem.containerSel).style.display == 'none' ? false : true
1758 | })[0].name;
1759 | } else if(type == 'i2i') { // Needs special saving since it's not an input but a tab switch
1760 | valueJSON.i2iMode = conf.i2i.controls.i2iMode.filter((elem) => {
1761 | return conf.shadowDOM.root.querySelector(elem.containerSel).style.display == 'none' ? false : true
1762 | })[0].name;
1763 | } else if(type == 'iBrowser') {
1764 | return conf.extensions.iBrowser.functions.getValueJSON();
1765 | }
1766 |
1767 | for (let prop in conf[type]) {
1768 | if(prop !== 'controls') {
1769 | try {
1770 | if(conf[type][prop].gradEl) {
1771 | valueJSON[prop] = getGradVal(conf[type][prop].gradEl);
1772 |
1773 | } else if(conf[type][prop].el.classList.contains('input-accordion')) { // "input-accordion" (checkbox alternative)
1774 | valueJSON[prop] = conf[type][prop].el.classList.contains('input-accordion-open') ? true : false;
1775 | } else if(conf[type][prop].el.type == 'fieldset') { // Radio buttons
1776 | valueJSON[prop] = conf[type][prop].el.querySelector('input:checked').value;
1777 | } else if(conf[type][prop].el.type == 'checkbox') {
1778 | valueJSON[prop] = conf[type][prop].el.checked;
1779 | } else { // Inputs, Textarea
1780 | valueJSON[prop] = conf[type][prop].el.value;
1781 | if(prop == 'prompt') valueJSON[prop] = filterPrompt(valueJSON[prop]);
1782 | if(prop == 'negPrompt' && conf.scriptSettings.promptFilterNegative.value) valueJSON[prop] = filterPrompt(valueJSON[prop], true);
1783 | }
1784 | } catch(e) {
1785 | awqLogPublishError(`Failed to retrieve settings for ${type} item ${prop} with error ${e.message}: ${e.stack}
`);
1786 | }
1787 | }
1788 | }
1789 |
1790 | valueJSON.sdModelCheckpoint = getGradVal(conf.commonData.sdModelCheckpoint.gradEl);
1791 | return JSON.stringify(valueJSON);
1792 | }
1793 | async function loadJson(p_json) {
1794 | let inputJSONObject = JSON.parse(p_json);
1795 | let type = inputJSONObject.type ? inputJSONObject.type : conf.commonData.activeType;
1796 | let oldData = JSON.parse(getValueJSON(type));
1797 | let waitForThisContainer;
1798 | awqLog('loadJson: ' + type);
1799 |
1800 | let currentModel = getGradVal(conf.commonData.sdModelCheckpoint.gradEl);
1801 | if(currentModel == inputJSONObject.sdModelCheckpoint) {
1802 | awqLog('loadJson: Correct model already loaded: ' + currentModel);// No action needed
1803 | } else if(conf.commonData.sdModelCheckpoint.gradEl.props.choices.includes(inputJSONObject.sdModelCheckpoint)) { // Check if model exists
1804 | awqLog('loadJson: Trying to load model: ' + inputJSONObject.sdModelCheckpoint);
1805 | setGradVal(conf.commonData.sdModelCheckpoint.gradEl, inputJSONObject.sdModelCheckpoint);
1806 | setCheckpointWithPost(inputJSONObject.sdModelCheckpoint); // Only setting gradio config no longer works?
1807 | } else {
1808 | awqLogPublishError(`Model ${inputJSONObject.sdModelCheckpoint} was not found, using current model ${currentModel}`);
1809 | }
1810 |
1811 | if(conf.commonData.activeType != inputJSONObject.type) await switchTabAndWait(inputJSONObject.type); // Switch tab?
1812 |
1813 | if(inputJSONObject.extrasResizeMode) await switchTabAndWaitUntilSwitched(inputJSONObject.extrasResizeMode, conf.ext.controls.extrasResizeMode); // Needs special loading since it's not an input but a tab switch
1814 | if(inputJSONObject.extrasMode) await switchTabAndWaitUntilSwitched(inputJSONObject.extrasMode, conf.ext.controls.extrasMode); // Needs special loading since it's not an input but a tab switch
1815 |
1816 | if(inputJSONObject.i2iMode) await switchTabAndWaitUntilSwitched(inputJSONObject.i2iMode, conf.i2i.controls.i2iMode); // Needs special loading since it's not an input but a tab switch
1817 |
1818 | let loadOutput = 'loadJson: loaded: ';
1819 |
1820 | for (let prop in inputJSONObject) {
1821 | let triggerOnBaseElem = true;
1822 | if(['type','extrasMode','extrasResizeMode','sdModelCheckpoint', 'i2iMode'].includes(prop)) continue;
1823 | try {
1824 | if(oldData[prop] != inputJSONObject[prop]) loadOutput += `${prop}:${oldData[prop]}-->${inputJSONObject[prop]} | `;
1825 |
1826 | if(conf[type][prop].el) {
1827 | if(conf[type][prop].el.type == 'fieldset') {
1828 | triggerOnBaseElem = false; // No need to trigger this on base element
1829 | conf[type][prop].el.querySelector('[value="' + inputJSONObject[prop] + '"]').checked = true;
1830 | triggerChange(conf[type][prop].el.querySelector('[value="' + inputJSONObject[prop] + '"]'));
1831 | } else if(conf[type][prop].el.classList.contains('input-accordion')) { // "input-accordion" (checkbox alternative)
1832 | let currentValue = conf[type][prop].el.classList.contains('input-accordion-open') ? true : false;
1833 | if(inputJSONObject[prop] != currentValue) {
1834 | conf[type][prop].el.querySelector('.label-wrap').click();
1835 | }
1836 |
1837 | } else if(conf[type][prop].el.type == 'select-one') { // Select
1838 | if(conf[type][prop].el.checked == inputJSONObject[prop]) triggerOnBaseElem = false; // Not needed
1839 | conf[type][prop].el.value = inputJSONObject[prop];
1840 | } else if(conf[type][prop].el.type == 'checkbox') {
1841 | if(conf[type][prop].el.checked == inputJSONObject[prop]) triggerOnBaseElem = false; // Prevent checbox getting toggled
1842 | conf[type][prop].el.checked = inputJSONObject[prop];
1843 | } else { // Input, Textarea
1844 | if(conf[type][prop].el.value == inputJSONObject[prop]) triggerOnBaseElem = false; // Fixes svelte error
1845 | conf[type][prop].el.value = inputJSONObject[prop];
1846 | }
1847 | if(conf[type][prop].el2) {
1848 | let triggerForSel2 = conf[type][prop].sel2.value != inputJSONObject[prop];
1849 | conf[type][prop].el2.value = inputJSONObject[prop];
1850 | if(triggerForSel2) triggerChange(conf[type][prop].el2);
1851 | }
1852 | }
1853 | if(conf[type][prop].gradEl) {
1854 | setGradVal(conf[type][prop].gradEl, inputJSONObject[prop]);
1855 | triggerOnBaseElem = false;
1856 | }
1857 | if(triggerOnBaseElem) triggerChange(conf[type][prop].el);
1858 | } catch(e) {
1859 | awqLogPublishError(`Failed to load settings for ${type} item ${prop} with error ${e.message}: ${e.stack}
`);
1860 | }
1861 | }
1862 | awqLog(loadOutput.replace(/\|\s$/, ''));
1863 | forceGradioUIUpdate();
1864 | }
1865 |
1866 | function waitForElm(selector) {
1867 | return new Promise(resolve => {
1868 | if (document.querySelector(selector)) {
1869 | return resolve(document.querySelector(selector));
1870 | }
1871 |
1872 | const observer = new MutationObserver(mutations => {
1873 | if (document.querySelector(selector)) {
1874 | resolve(document.querySelector(selector));
1875 | observer.disconnect();
1876 | }
1877 | });
1878 |
1879 | observer.observe(document.body, {
1880 | childList: true,
1881 | subtree: true
1882 | });
1883 | });
1884 | }
1885 | function setCheckpointWithPost(p_target_cp) {
1886 | awqLog('setCheckpointWithPost: '+ p_target_cp);
1887 | let targetCheckpoint = p_target_cp.replace('/','//').replace('\\','\\\\');
1888 |
1889 | // Try to find fn_index for the switch checkpoint "function"
1890 | let checkPointGradioElemId = conf.commonData.sdModelCheckpoint.gradEl.id;
1891 | let fnIndex = window.gradio_config.dependencies.filter(comp => comp.inputs[0] == checkPointGradioElemId);
1892 | fnIndex = fnIndex ? window.gradio_config.dependencies.indexOf(fnIndex[0]) : null;
1893 | if(fnIndex) {
1894 | awqLog('setCheckpointWithPost: found fn_index '+ fnIndex);
1895 | } else {
1896 | awqLogPublishError('setCheckpointWithPost: failed to find fn_index for model change');
1897 | return;
1898 | }
1899 |
1900 | fetch("/run/predict", {
1901 | method: "POST",
1902 | headers: {"Content-Type": "application/json"},
1903 | redirect: "follow",
1904 | body: `{"fn_index":${fnIndex},"data":["${targetCheckpoint}"],"event_data":null,"session_hash":"trlwn215an"}`
1905 | }).then(response => {
1906 | awqLog(`setCheckpointWithPost: repsonse: ${response.status}-${response.statusText}: ${JSON.stringify(response.json())}`);
1907 | }).catch(error => {
1908 | awqLog(`setCheckpointWithPost: error: ${JSON.stringify(error)}`);
1909 | });;
1910 | }
1911 |
1912 | function triggerChange(p_elem) {
1913 | let evt = document.createEvent("HTMLEvents");
1914 | evt.initEvent("change", false, true); // Needed for script to update subsection
1915 | p_elem.dispatchEvent(evt);
1916 | evt = document.createEvent("HTMLEvents");
1917 | evt.initEvent("input", false, true); // Needded for webui to register changed settings
1918 | p_elem.dispatchEvent(evt);
1919 | }
1920 |
1921 | function findGradioComponentState(p_elem_id) {
1922 | return window.gradio_config.components.filter(comp => comp.props.elem_id == p_elem_id);
1923 | }
1924 | function findGradioComponentStateByLabel(p_elem_label) {
1925 | return window.gradio_config.components.filter(comp => comp.props.label == p_elem_label);
1926 | }
1927 | function getGradVal(p_grad_comp) {
1928 | return p_grad_comp.props.value;
1929 | }
1930 | function setGradVal(p_grad_comp,p_val) {
1931 | p_grad_comp.props.value = p_val;
1932 | }
1933 | })();
--------------------------------------------------------------------------------
/docs/bookmarklet.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Run the script (SDAtom-WebUi-us) without installing
6 |
7 | To do this we will use a bookmarklet. To run the script drag 👉 this link 👈 to your bookmarks then click it while you have your webui ((http://127.0.0.1:7860/)) open in your browser. This will run the script but if you reload the page you will have to click the bookmark again. If it doesn't work right click the bookmark and click edit/properties and make sure the url contains the following:
8 |
9 | javascript:(function (){document.getElementsByTagName('head')[0].appendChild(document.createElement('script')).src='http://cdn.jsdelivr.net/gh/Kryptortio/SDAtom-WebUi-us/SDAtom-WebUi-us.user.js?'+(new Date()).getTime();}());
10 |
11 |
12 |
13 | It's also possible to manually open the script copying the content and pasting it in your developer console (press F12 then go to Console paste and press enter). This must also be done while you have the webui ((http://127.0.0.1:7860/)) open in your browser.
14 |
15 | Back to Github repo
16 |
17 |
--------------------------------------------------------------------------------
/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Kryptortio/SDAtom-WebUi-us/19e53432b3275b302497a7b3e53db2df856f5bd6/screenshot.png
--------------------------------------------------------------------------------