Repository navigation
Expand file tree
/
Copy pathtampermonkey_script.js
More file actions
181 lines (173 loc) · 6.67 KB
/
Copy pathtampermonkey_script.js
File metadata and controls
181 lines (173 loc) · 6.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
// ==UserScript==
// @name Custom Webpage Script
// @namespace my-custom-namespace
// @version 1
// @description Adds buttons and a dropdown menu, and removes unwanted buttons from a custom webpage
// @match http://localhost:7861/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Remove unwanted buttons
const unwantedButtons = document.querySelectorAll('button');
unwantedButtons.forEach(button => {
console.log(button.textContent);
if (button.textContent === 'txt2img' ||
button.textContent === 'Extras' ||
button.textContent === 'PNG Info' ||
button.textContent === 'Checkpoint Merger' ||
button.textContent === 'Settings' ||
button.textContent === 'Extensions') {
button.parent().remove();
}
});
function replaceTextareaContent() {
const textarea = document.querySelector('#component-187 textarea');
if (textarea) {
textarea.value = "abcdefg";
}
const tabArea = document.querySelector('tab-nav.scroll-hide.svelte-1g805jl.__web-inspector-hide-shortcut__');
if (tabArea) {
tabArea.style.display = 'none';
}
const footer = document.getElementById('footer');
if (footer) {
footer.style.display = 'none';
}
const side = document.getElementById('component-195');
if (side) {
side.style.display = 'none';
}
const ids2 = document.getElementById("quicksettings");
if (ids2) {
ids2.style.display = 'none';
}
const sideUpper = document.getElementById('resize-mode');
if (sideUpper) {
sideUpper.style.display = 'none';
}
const c307 = document.getElementById('component-307');
if (c307) {
c307.style.display = 'none';
}
const c310 = document.getElementById('component-310');
if (c310) {
c310.style.display = 'none';
}
const c336 = document.getElementById('component-336');
if (c336) {
c336.style.display = 'none';
}
const c463 = document.getElementById('component-463');
if (c463) {
c463.style.display = 'none';
}
const c281 = document.getElementById('component-281');
if (c281) {
c281.style.display = 'none';
}
const selection = document.getElementById('sampler_selection_img2img');
if (selection) {
selection.style.display = 'none';
}
const copyi = document.getElementById('img2img_copy_to_img2img');
if (copyi) {
copyi.style.display = 'none';
}
const sideUpper2 = document.querySelector("block gradio-radio svelte-mppz8v padded");
if (sideUpper2) {
sideUpper2.style.display = 'none';
}
const seedRow = document.getElementById('img2img_seed_row');
if (seedRow) {
seedRow.style.display = 'none';
}
const img2img_override_settings_rows = document.getElementById('img2img_override_settings_rows');
if (img2img_override_settings_rows) {
img2img_override_settings_rows.style.display = 'none';
}
const img2img_script_container = document.getElementById('img2img_script_container');
if (img2img_script_container) {
img2img_script_container.style.display = 'none';
}
const tools = document.getElementById('img2img_tools');
if (tools) {
tools.style.display = 'none';
}
const sideBox = document.querySelector('form.svelte-b6y5bg');
if (sideBox) {
sideBox.style.display = 'none';
}
const styleRow = document.getElementById('img2img_styles_row');
if (styleRow) {
styleRow.style.display = 'none';
}
const quickSettings = document.querySelector("wrap.svelte-1p9xokt");
if (quickSettings) {
quickSettings.style.display = 'none';
}
};
function replaceTextareaContentEarly() {
// const textarea = document.querySelector('#component-187 textarea');
// if (textarea) {
// textarea.value = "a photo of a person with xbvcewq, close-up";
// }
const textToCopy = "a photo of a person with xbvcewq, close-up";
navigator.clipboard.writeText(textToCopy)
.then(() => console.log('Text copied to clipboard'))
.catch(err => console.error('Could not copy text: ', err));
}
function replaceTextareaContentMiddle() {
// const textarea = document.querySelector('#component-187 textarea');
// if (textarea) {
// textarea.focus(); // Give the textarea focus
// textarea.click();
// textarea.value = "a photo of a person with bfdsewf, close-up";
// textarea.blur();
// }
const textToCopy = "a photo of a person with bfdsewf, close-up";
navigator.clipboard.writeText(textToCopy)
.then(() => console.log('Text copied to clipboard'))
.catch(err => console.error('Could not copy text: ', err));
}
function replaceTextareaContentLate() {
// const textarea = document.querySelector('#component-187 textarea');
// if (textarea) {
// textarea.value = "a photo of a person with exfxzjpe, close-up";
// }
const textToCopy = "a photo of a person with exfxzjpe, close-up";
navigator.clipboard.writeText(textToCopy)
.then(() => console.log('Text copied to clipboard'))
.catch(err => console.error('Could not copy text: ', err));
}
const buttonContainer = document.createElement('div');
buttonContainer.style.cssText = 'position: fixed; top: 0; left: 0; right: 0; padding: 10px; display: flex; border-radius: 10px; background-color: white; z-index: 999;';
const earlyButton = document.createElement('button');
earlyButton.textContent = 'Early Acne';
earlyButton.style.cssText = 'border-radius: 5px; padding: 10px; margin-right: 10px;';
buttonContainer.appendChild(earlyButton);
earlyButton.addEventListener('click', replaceTextareaContentEarly);
const middleButton = document.createElement('button');
middleButton.textContent = 'Late Acne';
middleButton.style.cssText = 'border-radius: 5px; padding: 10px; margin-right: 10px;';
middleButton.addEventListener('click', replaceTextareaContentMiddle);
buttonContainer.appendChild(middleButton);
const lateButton = document.createElement('button');
lateButton.textContent = 'Lupus';
lateButton.style.cssText = 'border-radius: 5px; padding: 10px;';
lateButton.addEventListener('click', replaceTextareaContentLate);
buttonContainer.appendChild(lateButton);
const body = document.querySelector('body');
body.insertBefore(buttonContainer, body.firstChild);
// Create button element
const button = document.createElement('button');
button.textContent = 'Replace Textarea Content';
button.style.position = 'fixed';
button.style.bottom = '20px';
button.style.right = '20px';
button.style.zIndex = '10000';
// Add click event listener to the button
button.addEventListener('click', replaceTextareaContent);
// Add button to the webpage
document.body.appendChild(button);
})();