Skip to content

Commit

Permalink
common_query: update fetch_desc()
Browse files Browse the repository at this point in the history
  • Loading branch information
salix5 committed Nov 6, 2023
1 parent 521353f commit 72b208b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions common_query.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ const response = {
};

async function fetch_desc(card, request_locale) {
const re_ptext = /<div class="frame pen_effect">.*?<div class="item_box_text">.*?([^\r\n\t]*).*?<\/div>/s;
const re_text = /<div class="text_title">.*?<\/div>.*?([^\r\n\t]+).*?<\/div>/s;
if (!card.cid)
if (!card.cid || !ygo.official_name[request_locale])
return '';

const re_ptext = /<div class="frame pen_effect">.*?<div class="item_box_text">.*?([^\r\n\t]+).*?<\/div>/s;
const re_text = /<div class="text_title">.*?<\/div>.*?([^\r\n\t]+).*?<\/div>/s;
let raw_data = await fetch(ygo.print_db_link(card.cid, request_locale)).then(response => response.text());
let ctext = '';
let res_text = re_text.exec(raw_data);
Expand All @@ -32,9 +33,11 @@ async function fetch_desc(card, request_locale) {
let ptext = '';
let res_ptext = re_ptext.exec(raw_data);
if (res_ptext) {
if (res_ptext[1] === '</div>')
res_ptext[1] = '';
ptext = res_ptext[1].replaceAll('<br>', '\n');
}
return `${ptext}\n【${ygo.lang[request_locale][ygo.type.TYPE_MONSTER]}${ygo.lang[request_locale][ygo.monster_type.TYPE_EFFECT]}】\n${ctext}\n`;
return `${ptext}\n【${ygo.lang[request_locale].type_name[ygo.monster_type.TYPE_EFFECT]}】\n${ctext}\n`;
}
else {
return `${ctext}\n`;
Expand Down
1 change: 1 addition & 0 deletions ygo-query.js
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ module.exports = {
cid_inverse,
name_table,
lang,
official_name,

is_alternative,
is_released,
Expand Down

0 comments on commit 72b208b

Please sign in to comment.