1
0
mirror of https://github.com/Daichimarukana/uwuzu.git synced 2026-06-04 19:14:41 +00:00

uwuzu v1.5.3 Combeny

This commit is contained in:
Daichimarukana
2025-05-12 17:30:53 +09:00
parent 04849c81aa
commit a5d2661c74
14 changed files with 91 additions and 35 deletions
+27 -1
View File
@@ -116,6 +116,15 @@ async function replaceCustomEmojis(text) {
}
function a_link(text){
const placeholders = {};
let placeholderIndex = 0;
text = text.replace(/'/g, (match) => {
const key = `\u2063{{PLACEHOLDER${placeholderIndex++}}}\u2063`;
placeholders[key] = match; // 元の文字列を保存
return key;
});
text = text.replace(/(https:\/\/[\w!?\/+\-_~;.,*&@#$%()+|https:\/\/[ぁ-んァ-ヶ一ー-龠々\w\-\/?=&%.]+)/g, function(url) {
const escapedUrl = url;
const no_https_link = escapedUrl.replace("https://", "");
@@ -132,6 +141,11 @@ function a_link(text){
return `${before}<a href="/search?q=${encodedTag}" class="hashtags">#${tag}</a>`;
});
for (const key in placeholders) {
const escapedKey = key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
text = text.replace(new RegExp(escapedKey, 'g'), placeholders[key]);
}
return text;
}
@@ -160,6 +174,13 @@ function formatMarkdown(text) {
return key;
});
// ユーザーIDをプレースホルダーに退避
text = text.replace(/@([a-zA-Z0-9_]+)/g, (match) => {
const key = `\u2063{{PLACEHOLDER${placeholderIndex++}}}\u2063`;
placeholders[key] = match; // 元の文字列を保存
return key;
});
// 独自構文などの装飾
text = text.replace(/\[\[buruburu (.+?)\]\]/g, '<span class="buruburu">$1</span>');
text = text.replace(/\[\[time (\d+)\]\]/g, (_, ts) => {
@@ -348,6 +369,11 @@ async function createUeuseHtml(ueuse, selectedUniqid = null) {
if(ueuse["ueuse"].length > 0){
reuse = ``;
if(!(ueuse["reuse"] == null)){
// カスタム絵文字を非同期に差し替え
var inyoreuseHtml = formatMarkdown(a_link(ueuse["reuse"]["ueuse"]));
inyoreuseHtml = await replaceMentions(inyoreuseHtml);
inyoreuseHtml = await replaceCustomEmojis(inyoreuseHtml);
inyo = `<div class="reuse_box" data-uniqid="`+ueuse["reuse"]["uniqid"]+`" id="quote_reuse">
<div class="reuse_flebox">
<a href="/!`+ueuse["reuse"]["uniqid"]+`">
@@ -366,7 +392,7 @@ async function createUeuseHtml(ueuse, selectedUniqid = null) {
</div>
<p>
`+formatMarkdown(a_link(ueuse["reuse"]["ueuse"]))+`
`+inyoreuseHtml+`
</p>
</div>`;
}else{