Nix0n commited on
Commit
0b56a4e
1 Parent(s): 2891633

Upload AUTOMATIC1111 - change output folder.user.js

Browse files
AUTOMATIC1111 - change output folder.user.js ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // ==UserScript==
2
+ // @name AUTOMATIC1111 - change output folder
3
+ // @namespace http://tampermonkey.net/
4
+ // @version 0.1
5
+ // @description Quick change ouput folder
6
+ // @author You
7
+ // @match http://127.0.0.1:7860/
8
+ // @match http://localhost:7860/
9
+ // @match https*://*.loca.lt/*
10
+ // @icon https://www.google.com/s2/favicons?sz=64&domain=0.1
11
+ // @grant none
12
+ // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js
13
+ // @run-at document-end
14
+ // ==/UserScript==
15
+
16
+ (function() {
17
+ 'use strict';
18
+
19
+ setTimeout(() => {
20
+ const outputPathTxt2img1 = 'your/path/to/txt2img/output/folder'; //here you put your main txt2img output folder path
21
+ const outputPathTxt2img2 = 'your/path/to/alternative/txt2img/output/folder'; //here you put your alternative txt2img output folder path
22
+
23
+ const outputPathImg2img1 = 'your/path/to/img2img/output/folder'; //here you put your main img2img output folder path
24
+ const outputPathImg2img2 = 'your/path/to/alternative/img2img/output/folder'; //here you put your alternative img2img output folder path
25
+
26
+ const container = querySelectorAllShadows('.container')[0];
27
+ const txt2imgInput = querySelectorAllShadows('#setting_outdir_txt2img_samples textarea')[0];
28
+ const img2imgInput = querySelectorAllShadows('#setting_outdir_img2img_samples textarea')[0];
29
+ const saveBtn = querySelectorAllShadows('#tab_settings .gr-button-primary')[0];
30
+
31
+ const checked = txt2imgInput.value === outputPathTxt2img2 ? 'checked' : '';
32
+
33
+ console.log(container)
34
+ console.log(txt2imgInput)
35
+ console.log(saveBtn)
36
+ $(container).prepend( `
37
+ <label class="toggle incognito">
38
+ <input class="toggle-checkbox" type="checkbox" ${checked}>
39
+ <div class="toggle-switch"></div>
40
+ <span class="toggle-label">Alternative directory</span>
41
+ </label>
42
+ ` );
43
+
44
+ const incogintoEl = container.querySelector('.incognito .toggle-checkbox');
45
+ incogintoEl.addEventListener('change', (e) => {
46
+ const targetEl = e.currentTarget;
47
+ if (targetEl.checked) {
48
+ console.log("Checkbox is checked..");
49
+ txt2imgInput.value = outputPathTxt2img2;
50
+ img2imgInput.value = outputPathImg2img2;
51
+ } else {
52
+ console.log("Checkbox is not checked..");
53
+ txt2imgInput.value = outputPathTxt2img1;
54
+ img2imgInput.value = outputPathImg2img1;
55
+ }
56
+ console.log(txt2imgInput)
57
+ txt2imgInput.dispatchEvent(new Event("input", { bubbles: true }));
58
+ img2imgInput.dispatchEvent(new Event("input", { bubbles: true }));
59
+ })
60
+ console.log(incogintoEl)
61
+ }, 1000)
62
+
63
+
64
+ addStyle(`
65
+ body {
66
+ color:red;
67
+ }
68
+ .toggle {
69
+ cursor: pointer;
70
+ display: inline-block;
71
+ margin-bottom: 2em;
72
+ }
73
+
74
+ .toggle-switch {
75
+ display: inline-block;
76
+ background: #ccc;
77
+ border-radius: 16px;
78
+ width: 58px;
79
+ height: 32px;
80
+ position: relative;
81
+ vertical-align: middle;
82
+ transition: background 0.25s;
83
+ }
84
+ .toggle-switch:before, .toggle-switch:after {
85
+ content: "";
86
+ }
87
+ .toggle-switch:before {
88
+ display: block;
89
+ background: linear-gradient(to bottom, #fff 0%, #eee 100%);
90
+ border-radius: 50%;
91
+ box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
92
+ width: 24px;
93
+ height: 24px;
94
+ position: absolute;
95
+ top: 4px;
96
+ left: 4px;
97
+ transition: left 0.25s;
98
+ }
99
+ .toggle:hover .toggle-switch:before {
100
+ background: linear-gradient(to bottom, #fff 0%, #fff 100%);
101
+ box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
102
+ }
103
+ .toggle-checkbox:checked + .toggle-switch {
104
+ background: #56c080;
105
+ }
106
+ .toggle-checkbox:checked + .toggle-switch:before {
107
+ left: 30px;
108
+ }
109
+
110
+ .toggle-checkbox {
111
+ position: absolute;
112
+ visibility: hidden;
113
+ }
114
+
115
+ .toggle-label {
116
+ margin-left: 5px;
117
+ position: relative;
118
+ top: 2px;
119
+ }
120
+ `)
121
+
122
+ function addStyle(styleText) {
123
+ let s = document.createElement('style');
124
+ s.appendChild(document.createTextNode(styleText));
125
+ querySelectorAllShadows('.gradio-container')[0].appendChild(s);
126
+ }
127
+
128
+ function querySelectorAllShadows(selector, el = document.body) {
129
+ // recurse on childShadows
130
+ const childShadows = Array.from(el.querySelectorAll('*')).
131
+ map(el => el.shadowRoot).filter(Boolean);
132
+
133
+ const childResults = childShadows.map(child => querySelectorAllShadows(selector, child));
134
+
135
+ // fuse all results into singular, flat array
136
+ const result = Array.from(el.querySelectorAll(selector));
137
+ return result.concat(childResults).flat();
138
+ }
139
+
140
+ })();
141
+
142
+
143
+
144
+
145
+