Duge dyvno, ale ljinj cvydko mynula, tsjomu pospryjav sam xvorum, kotryj maje v lactax „Vvimknuty panelj bb-koda”. Jakctco prybraty ptacku vidty, to perestavav pratsjuvaty skrypt.
▼Прихований текст
// ==UserScript==
// @name Format Hotkey for Replace
// @version 20-March-2021
// @author Jurid
// @description Format Hotkey
// @include https://replace.org.ua/*
// ==/UserScript==
(function () {
document.getElementById("fld1").onkeydown = function (e) {
e = e || window.event
if (e.ctrlKey && get[e.key]) {
e.preventDefault()
insert_text(...get[e.key])
}
}
})()
function insert_text(o, c = o) {
let field, b, s, a
o = "[" + o + "]"; c = "[/" + c + "]"
field = document.getElementById("fld1")
b = field.value.substring(0, field.selectionStart) + o
s = field.value.substring(field.selectionStart, field.selectionEnd)
a = c + field.value.substring(field.selectionEnd, field.value.length)
document.execCommand("insertText", false, o + s + c)
field.selectionStart = b.length
field.selectionEnd = field.value.length - a.length
}
var get = {
"b": ["b"],
"i": ["i"],
"u": ["u"],
"s": ["s"],
"m": ["tt"],
"1": ["list=1", "list"],
"2": ["list=a", "list"],
"8": ["list=*", "list"],
"p": ["*"],
"q": ["quote"],
"k": ["code"],
"l": ["url"],
"g": ["img"],
"r": ["color=green", "color"],
"h": ["spoiler"],
}
Skrypt teper nezalegnyj, tobto ne zalege vid zhadanoji v poperednjomu dopysi funktsiju, a takog maje perevahy:
Nprm + Z i Nprm + Y pratsjuje i na bb-kody.
Vidbuly sja dekotri zminy v horjatcyx kljavicax, nasampered dlja spyskiv. Mogna vge odrazu vyklykaty potrjibnyj spysok.
Takog skrypt vidnosno malyj i duge prostyj dlja rozuminja. Moderatory mogutj sobi odrazu propysaty color=red, aby ustavno buv tcervonyj koljir.