my-sd/javascript/user.js
soaska 919b945d7c
Some checks failed
Linter / ruff (push) Failing after 32s
Tests / tests on CPU (push) Failing after 1m1s
Linter / eslint (push) Has been cancelled
Tried to set tests for gitea, added userjs and styles
2024-05-02 23:06:54 +03:00

57 lines
2.4 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Custom scripts by XpucT
// Homepage: https://boosty.to/xpuct
document.addEventListener('keydown', function(e) {
// Reload UI по F2
if (e.code === 'F2') {
document.querySelector('#settings_restart_gradio').click()
e.preventDefault()
// Включить / Выключить ADetailer по F1
// } else if (e.code === 'F1') {
// document.querySelector('#script_txt2img_adetailer_ad_enable').children[1].click()
// e.preventDefault()
// Показать предыдущую генерацию по клавише Shift
} else if (e.keyCode === 16 && document.querySelector('.livePreview'))
document.querySelector('.livePreview').style.display = 'none'
})
document.addEventListener('keyup', function(e) {
if (e.keyCode === 16 && document.querySelector('.livePreview')) {
document.querySelector('.livePreview').style.display = 'block'
}
})
onUiLoaded(function() {
// Удаление рекламы в Photopea (работает не всегда)
const result = document.evaluate("//div[@class='flexrow app']/div[2]", document, null, XPathResult.ANY_TYPE, null)
var ad = result.iterateNext()
while (ad) {
ad.parentNode.removeChild(ad)
ad = result.iterateNext()
}
// Граница в txt2img немного левее, а не посередине
document.querySelector('gradio-app .resize-handle-row').style.gridTemplateColumns = '676px 16px 1fr'
// Вставить выбранные стили колесом
document
.querySelectorAll('button[id$=_styles_edit_button]')
.forEach((x) =>
x.addEventListener(
'mousedown',
(e) => e.button === 1 && get_uiCurrentTabContent().querySelector('button[id$=_style_apply]').click()
)
)
// Если нажимать Generate колесом, то генерация будет с ADetailer
document.querySelectorAll('button[id$=_generate]').forEach((x) => x.addEventListener('mousedown', (e) => {
if (e.button === 1) {
get_uiCurrentTabContent().querySelector('div[id$=_adetailer_ad_enable]').children[1].click()
get_uiCurrentTabContent().querySelector('button[id$=_generate]').click()
setTimeout(() => get_uiCurrentTabContent().querySelector('div[id$=_adetailer_ad_enable]').children[1].click(), 100)
e.preventDefault()
}
}))
})