Skip to content

Instantly share code, notes, and snippets.

@shotadft
Last active April 12, 2026 11:36
Show Gist options
  • Select an option

  • Save shotadft/5f2aee36cc14c177d84ed4590b8c49b4 to your computer and use it in GitHub Desktop.

Select an option

Save shotadft/5f2aee36cc14c177d84ed4590b8c49b4 to your computer and use it in GitHub Desktop.
Obsidian DataviewJS用に書いたヤツ。使用する際は必ずコメントを見てください(見ずに利用することを禁じます)。
/*
(C)2026 Pokémon. (C)1995-2026 Nintendo/Creatures Inc./GAME FREAK inc.
ポケットモンスター・ポケモン・Pokémonは任天堂・クリーチャーズ・ゲームフリークの商標です。
================================================================================
Author: Shotadft
GitHub: https://github.com/shotadft
Gist: https://gist.github.com/shotadft/5f2aee36cc14c177d84ed4590b8c49b4
================================================================================
MIT License
Copyright (C) 2026 Shotadft
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* @typedef {Object} PokeData Pokémon data
* @property {number} ball Index number of the "ballImgs" constant
* @property {string} image Image URL or Prefix
* @property {string | number} race Pokémon Race Name or National Pokédex Number
* @property {string} name Pokémon Nickname
* @property {number} gender 0: male, 1: female, >=2: unknown
* @property {number} level Min 0, Max 100
* @property {string?} comment Comments
*/
/** @type {{ data: PokeData[] }} */
const { data } = input;
/**
* @param {string} url Media Source
* @param {string} alt Alternative text
* @param {number?} width
* @returns {string} img tag
*/
const createImgTag = (url, alt, width) => `<img src="${url}" alt="${alt}" width="${width ?? imageSize}" />`;
// Options
const lang = "ja";
const cacheExpireDay = 1;
const officialImgSource = "home";
const officialImgPrefix = "$";
const officialImgPrefixShiny = "S";
const imageSize = 75;
const unknownDataNick = "??????";
// Never change the following constants
const API_URL = "https://pokeapi.co/api/v2/pokemon/";
const ITEMS_SPRITES_URL = "https://raw.githubusercontent.com/msikma/pokesprite/master/items/";
const MAX_POKEMON_COUNT = 1025; // Make changes whenever a new Pokémon is released
/** Quote: https://icooon-mono.com/00091-%E3%81%AF%E3%81%A6%E3%81%AA%E3%83%9E%E3%83%BC%E3%82%AF%E3%81%AE%E3%82%A2%E3%82%A4%E3%82%B3%E3%83%B3/ */
const unknownDataImage = `<svg xmlns="https://www.w3.org/2000/svg" xml:space="preserve" style="width:${imageSize}px;height:${imageSize}px" viewBox="0 0 512 512"><path fill="#4b4b4b" d="M306 156.1a69 69 0 0 0-22.8-13.2 82 82 0 0 0-55.2.2 70 70 0 0 0-22.6 13.4 62 62 0 0 0-15.3 21.4q-5.6 12.7-5.6 28.3h44.2q0-12 6.8-20 6.8-8.2 20.3-8.2a26 26 0 0 1 20.2 8 28 28 0 0 1 4.4 31.4q-2.8 5.8-7 11.2l-21.2 27.2c-4.5 6-16.7 23-16.7 40.3v10.2h44v-7.1q0-4.4 1.8-9.2a76 76 0 0 1 8.3-13.1l21.2-28.3q7.1-9.5 11.9-19.5a53 53 0 0 0 4.8-23q0-16.2-5.8-28.8-5.8-12.5-15.6-21.2m-72 172.5h46.8v45.1h-46.8z" class="prefix__st0"/><path fill="#4b4b4b" d="M256 0a256 256 0 1 0 0 512 256 256 0 0 0 0-512m0 448c-105.9 0-192-86.1-192-192S150.1 64 256 64s192 86.1 192 192-86.1 192-192 192" class="prefix__st0"/></svg>`;
/** Quote: https://seiga.nicovideo.jp/seiga/im10446381 (SVG conversion is done manually) */
const gXMark = '<svg xmlns="https://www.w3.org/2000/svg" style="width:24px;height:24px" viewBox="0 0 992 892"><path fill="#de0703" d="m388.42 714.12-43.22 83.6a1223 1223 0 0 0-176.15 28.14C133 834.79 98.5 845.18 64.36 859.27c-21.65 8.94-40.82 19.69-61.48 31.71 55.39-99.75 116.09-192.33 182.79-282.18 54.62-73.16 112-142.87 174.48-210.14 39.02 55.96 75.26 112.65 110.12 170.88l-14.42 23.23-9.46 16.78-54.94 98.87z"/><path fill="#d86b83" d="m973.87 2.28-.02 2.54c-5.01 1.09-9.92 2.41-14.95 5.13-58.15 31.49-107.37 72.26-154.95 118.06-39.93 38.44-76.53 79.46-111.8 121.9l-4.13 4.32c.06-1.69.32-2.71 1.09-6.01l-6.01-1.34c-4.56-1.01-10-2.43-14.48-1.38-3.92.92-8.57 3.6-12.24 2.35a41 41 0 0 0-14.38-2.41l-19.99.07-33.26.14-17.54-.02-23.26-.17h-17.96l-13.2-.44c-4.86-.16-9.82.86-14.81.66l-17.98-.73-13.01.4h-20.96l-24.03.16c-4.18.03-8.84-.7-12.93.28-5.74 1.37-10.64 1.75-16.36.53s-12.47-1.22-18.58-1.18l-12.29.08-59.76-.14-7.12 1.03-1.48 4.29C242.75 182.55 165.11 102.49 94.43 50.66 72.45 34.54 50.3 20.25 26.02 8.01 19.01 4.48 11.15 4.24 3.92 2.2c11.22-.7 21.64.72 32.75 2.23 65.97 8.97 130.66 35.65 189.69 66.31 88.21 46.91 167.41 105.22 243.95 171l25.68-201.69 25.66 201.74c85.36-73.34 179.18-141.8 282.19-189.89C853.07 29.06 908.01 9.81 962.01 3.63z"/><path fill="#de0703" d="M928 859.41c-88.17-36.34-190.83-53.31-284.59-62.05l-8.06-16.52c39.5-78.25 80.16-153.75 125.92-230.33 55.41 69.9 106.09 141.63 153.89 216.26 25.24 40.22 49.79 79.74 73.33 123.59-20.61-11.44-38.98-22.09-60.49-30.95"/><path fill="#d53e4f" d="m662.98 285.62-35.13 46.19-15.73 21.14-11.01 15.2c-1.05-3.6-5.06-5.03-9.03-5.07l-14.09-.13-22.78-.18c-4.88-.04-8.57-.06-13.41-.02l-35.76.28-13.05-.61-22.4.37c-8.39.14-16.9.55-25.38-.07-2.73-.2-4.41-.21-7.36.21-10.84 1.54-19.95-3.4-31.88.53-5.57-1.54-10.96-2.14-16.6-1.23l-1.17 5.55-62.7-82.59c-.04-.5 1.35-1.73 1.82-1.82l8.59-1.61 25.08-.22 24.08.16 6.98.42c4.12.25 8.74.95 12.98.44 7.39-.9 14.07-1.41 21.33-.09 11.41-1.07 22.94-1.73 34.53-.46 3.37.37 5.93.5 9.28.05 8.83-1.19 17.78.23 26.71.15l15.52-.15 34.42.09 22.23.26 26.7.32 16.22-.8 10.95-.05 12.94.44 22.38-.32c1.46-.02 4.2 2.76 4.75 3.6Z"/><path fill="#de0703" d="M601.1 368.14a3228 3228 0 0 0-106.58 161.15c-33.72-54.39-68.14-106.68-104.66-158.06l-.91-1.22c-.38-.46-.9-1.63-.78-2.22l1.17-5.55c5.64-.91 11.03-.31 16.6 1.23 11.93-3.93 21.04 1.02 31.88-.53 2.95-.42 4.63-.41 7.36-.21 8.48.61 16.99.2 25.38.07l22.4-.37 13.05.61 35.76-.28c4.85-.04 8.53-.02 13.41.02l22.78.18 14.09.13c3.97.04 7.98 1.47 9.03 5.07Zm9.75 365.55-33.8-62.2c37.83-67.73 77.3-133.98 120.19-198.95l36.36 43.16c-44.01 71.78-83.85 143.09-122.75 218Z"/><path fill="#d44556" d="m688.01 254.23-9.87 12.74-15.16 18.64c-.55-.84-3.3-3.62-4.75-3.6l-22.38.32-12.94-.44-10.95.05-16.22.8-26.7-.32-22.23-.26-34.42-.09-15.52.15c-8.93.09-17.88-1.33-26.71-.15-3.35.45-5.91.32-9.28-.05-11.58-1.27-23.12-.61-34.53.46-7.27-1.33-13.94-.82-21.33.09-4.24.52-8.87-.19-12.98-.44l-6.98-.42-24.08-.16-25.08.22-8.59 1.61c-.48.09-1.86 1.32-1.82 1.82l-28.01-34.76 1.48-4.29 7.12-1.03 59.76.14 12.29-.08c6.11-.04 12.62-.09 18.58 1.18s10.62.84 16.36-.53c4.09-.98 8.75-.25 12.93-.28l24.03-.17h20.96l13.01-.39 17.98.73c4.99.2 9.95-.82 14.81-.66l13.2.44h17.96l23.26.16 17.54.02 33.26-.14 19.99-.07c5.22-.02 9.35.69 14.38 2.41 3.67 1.25 8.32-1.43 12.24-2.35 4.48-1.05 9.93.37 14.48 1.38l6.01 1.34c-.77 3.29-1.03 4.32-1.09 6.01Z"/><path fill="#de0703" d="m553.06 627.85-34.33-58.27c35.42-58.98 72.05-116.6 111.45-172.9l39.39 43.85c-41.03 60.94-78.82 121.98-116.51 187.32"/><path fill="#f998a7" d="m973.85 4.82.02-2.54c4.42-.51 8.52-.82 13.55-.41l-13.58 2.95Z"/></svg>';
const k = ["ボール", "画像", "種族", "タイプ", "ニックネーム", "性別", "レベル", "備考"];
const genderImgs = [
'<svg xmlns="https://www.w3.org/2000/svg" fill="#0072b0" fill-rule="evenodd" style="width:36px;height:36px" viewBox="0 0 36 36"><path class="prefix__cls-1" d="M29.24 3.37h-9.92V6.5h8.22L16.69 17.36A8.3 8.3 0 0 0 12 15.91a8.35 8.35 0 1 0 6.92 3.66L29.24 9.24v7.19h3.13V3.37ZM12 29.61a5.34 5.34 0 1 1 5.34-5.34A5.34 5.34 0 0 1 12 29.61"/></svg>', /** Quote: https://zukan.pokemon.co.jp/img/icon_male.svg */
'<svg xmlns="https://www.w3.org/2000/svg" fill="#dd2d51" style="width:36px;height:36px" viewBox="0 0 36 36"><path class="prefix__cls-1" d="M29.61 21.48h-9.87v-3.07a9.29 9.29 0 1 0-3.48 0v3.07H6.39V25h9.87v11h3.48V25h9.87ZM12.06 9.29A5.94 5.94 0 1 1 18 15.23a5.94 5.94 0 0 1-5.94-5.94"/></svg>' /** Quote: https://zukan.pokemon.co.jp/img/icon_female.svg */
];
const ballImgs = [
"strange", // ストレンジ
"poke", // モンスター
"great", // スーパー
"ultra", // ハイパー
"master", // マスター
"premier", // プレミアム
"heal", // ヒール
"net", // ネット
"nest", // ネスト
"repeat", // リピート
"timer", // タイマー
"luxury", // ゴージャス
"dive", // ダイブ
"dusk", // ダーク
"quick", // クイック
"fast", // スピード
"level", // レベル
"lure", // ルアー
"heavy", // ヘビー
"love", // ラブラブ
"friend", // フレンド
"moon", // ムーン
"dream", // ドリーム
"beast", // ウルトラ
"cherish", // プレシャス
"safari", // サファリ
"sport", // コンペ
"park", // パーク
"poke_hisui", // モンスター(ヒスイ)
"great_hisui", // スーパー(ヒスイ)
"ultra_hisui", // ハイパー(ヒスイ)
"feather", // フェザー
"wing", // ウイング
"jet", // ジェット
"heavy_hisui", // ヘビー(ヒスイ)
"leaden", // メガトン
"gigaton", // ギガトン
"origin", // オリジン
];
// Main Methods
/** @param {string} url */
const getAPI = async (url) => {
try {
const cacheKey = `pokeapi_cache_${encodeURI(url)}`;
const cachedData = localStorage.getItem(cacheKey);
if (cachedData) {
const { data, timestamp } = JSON.parse(cachedData);
const ttl = cacheExpireDay * 24 * 60 * 60 * 1000;
if (Date.now() - timestamp < ttl)
return data;
else
localStorage.removeItem(cacheKey);
}
const res = await fetch(url);
if (!res.ok)
throw new Error(`HTTP Response is ${res.status} ${res.statusText}, not OK[200-299]!`);
const data = await res.json();
const slimData = url.includes("pokemon/") ? {
species: data.species,
sprites: { other: { [officialImgSource]: data.sprites.other[officialImgSource] } },
types: data.types,
forms: data.forms
} : data;
localStorage.setItem(cacheKey, JSON.stringify({
data: slimData,
timestamp: Date.now()
}));
return slimData;
} catch ({ name, message }) {
console.error(name, ": ", message);
dv.el("div", `<p>${name + ": " + message}</p>`);
return null;
}
};
/**
* @param {object} speciesData
* @param {object} pokeData
* @returns {string}
*/
const getPokemonName = async (speciesData, pokeData) => {
const formData = await getAPI(pokeData.forms[0].url);
const speciesTxt = speciesData.names.find(v => v.language.name === lang)?.name ?? unknownDataNick;
const formTxt = formData.form_names.find(v => v.language.name === lang)?.name;
return formTxt ? `${speciesTxt}<br />(${formTxt})` : speciesTxt;
};
/**
* @param {object} types
* @returns {string}
*/
const getPokemonType = async (types) => {
const names = await Promise.all(
types.map(async (t) => {
const typeData = await getAPI(t.type.url);
const found = typeData.names.find(v => v.language.name === lang);
return found ? found.name : t.type.name;
})
);
return names.join(" / ");
};
const rows = await Promise.all(
data.map(async (d) => {
const genderImg = genderImgs[d.gender] ?? "\u4e0d\u660e";
const nickname = (s) => !d.name ? s : d.name;
const comment = !d.comment ? "" : d.comment.replace("{gX}", gXMark);
const ballNum = (!d.ball || d.ball > ballImgs.length) ? 0 : d.ball;
const ballName = ballImgs[ballNum];
const ballImg = createImgTag(`${ITEMS_SPRITES_URL}ball/${ballName}.png`, ballName, 50);
const level = Math.max(0, Math.min(100, d.level));
if (!d.race || d.race <= 0 || d.race > MAX_POKEMON_COUNT)
return [ballImg, unknownDataImage, unknownDataNick, "", nickname(unknownDataNick), genderImg, level, comment];
const pokeData = await getAPI(API_URL + d.race);
const speciesData = await getAPI(pokeData.species.url);
const officialImg = pokeData.sprites.other[officialImgSource];
const isOfficialImgPrefix = d.image.length >= 1 && d.image[0] === officialImgPrefix;
const isOfficialImgPrefixShiny = d.image.length >= 2 && d.image[1] === officialImgPrefixShiny;
const isFemale = d.gender === 1;
/** @type {string} */
const image = isOfficialImgPrefix
? isOfficialImgPrefixShiny
? ((isFemale && officialImg.front_shiny_female) ?
officialImg.front_shiny_female : officialImg.front_shiny)
: ((isFemale && officialImg.front_female) ?
officialImg.front_female : officialImg.front_default)
: d.image;
const name = await getPokemonName(speciesData, pokeData);
const type = await getPokemonType(pokeData.types);
return [ballImg, createImgTag(image, name), name, type, nickname(name), genderImg, level, comment];
})
);
dv.table(k, rows);
/*
(C)2026 Pokémon. (C)1995-2026 Nintendo/Creatures Inc./GAME FREAK inc.
ポケットモンスター・ポケモン・Pokémonは任天堂・クリーチャーズ・ゲームフリークの商標です。
================================================================================
Author: Shotadft
GitHub: https://github.com/shotadft
Gist: https://gist.github.com/shotadft/5f2aee36cc14c177d84ed4590b8c49b4
================================================================================
MIT License
Copyright (C) 2026 Shotadft
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
Quote:
- https://icooon-mono.com/00091-%E3%81%AF%E3%81%A6%E3%81%AA%E3%83%9E%E3%83%BC%E3%82%AF%E3%81%AE%E3%82%A2%E3%82%A4%E3%82%B3%E3%83%B3/
- https://seiga.nicovideo.jp/seiga/im10446381 (SVG conversion is done manually)
- https://zukan.pokemon.co.jp/img/icon_male.svg
- https://zukan.pokemon.co.jp/img/icon_female.svg
*/
const{data:e}=input,a=(e,a,t)=>`<img src="${e}" alt="${a}" width="${t??s}" />`,t="ja",l="home",s=75,i="??????",r=`<svg xmlns="https://www.w3.org/2000/svg" xml:space="preserve" style="width:${s}px;height:${s}px" viewBox="0 0 512 512"><path fill="#4b4b4b" d="M306 156.1a69 69 0 0 0-22.8-13.2 82 82 0 0 0-55.2.2 70 70 0 0 0-22.6 13.4 62 62 0 0 0-15.3 21.4q-5.6 12.7-5.6 28.3h44.2q0-12 6.8-20 6.8-8.2 20.3-8.2a26 26 0 0 1 20.2 8 28 28 0 0 1 4.4 31.4q-2.8 5.8-7 11.2l-21.2 27.2c-4.5 6-16.7 23-16.7 40.3v10.2h44v-7.1q0-4.4 1.8-9.2a76 76 0 0 1 8.3-13.1l21.2-28.3q7.1-9.5 11.9-19.5a53 53 0 0 0 4.8-23q0-16.2-5.8-28.8-5.8-12.5-15.6-21.2m-72 172.5h46.8v45.1h-46.8z" class="prefix__st0"/><path fill="#4b4b4b" d="M256 0a256 256 0 1 0 0 512 256 256 0 0 0 0-512m0 448c-105.9 0-192-86.1-192-192S150.1 64 256 64s192 86.1 192 192-86.1 192-192 192" class="prefix__st0"/></svg>`,n=['<svg xmlns="https://www.w3.org/2000/svg" fill="#0072b0" fill-rule="evenodd" style="width:36px;height:36px" viewBox="0 0 36 36"><path class="prefix__cls-1" d="M29.24 3.37h-9.92V6.5h8.22L16.69 17.36A8.3 8.3 0 0 0 12 15.91a8.35 8.35 0 1 0 6.92 3.66L29.24 9.24v7.19h3.13V3.37ZM12 29.61a5.34 5.34 0 1 1 5.34-5.34A5.34 5.34 0 0 1 12 29.61"/></svg>','<svg xmlns="https://www.w3.org/2000/svg" fill="#dd2d51" style="width:36px;height:36px" viewBox="0 0 36 36"><path class="prefix__cls-1" d="M29.61 21.48h-9.87v-3.07a9.29 9.29 0 1 0-3.48 0v3.07H6.39V25h9.87v11h3.48V25h9.87ZM12.06 9.29A5.94 5.94 0 1 1 18 15.23a5.94 5.94 0 0 1-5.94-5.94"/></svg>'],c=["strange","poke","great","ultra","master","premier","heal","net","nest","repeat","timer","luxury","dive","dusk","quick","fast","level","lure","heavy","love","friend","moon","dream","beast","cherish","safari","sport","park","poke_hisui","great_hisui","ultra_hisui","feather","wing","jet","heavy_hisui","leaden","gigaton","origin"],o=async e=>{try{const a=`pokeapi_cache_${encodeURI(e)}`,t=localStorage.getItem(a);if(t){const{data:e,timestamp:l}=JSON.parse(t),s=864e5;if(Date.now()-l<s)return e;localStorage.removeItem(a)}const s=await fetch(e);if(!s.ok)throw new Error(`HTTP Response is ${s.status} ${s.statusText}, not OK[200-299]!`);const i=await s.json(),r=e.includes("pokemon/")?{species:i.species,sprites:{other:{[l]:i.sprites.other[l]}},types:i.types,forms:i.forms}:i;return localStorage.setItem(a,JSON.stringify({data:r,timestamp:Date.now()})),r}catch({name:e,message:a}){return console.error(e,": ",a),dv.el("div",`<p>${e+": "+a}</p>`),null}},h=await Promise.all(e.map(async e=>{const s=n[e.gender]??"不明",h=a=>e.name?e.name:a,m=e.comment?e.comment.replace("{gX}",'<svg xmlns="https://www.w3.org/2000/svg" style="width:24px;height:24px" viewBox="0 0 992 892"><path fill="#de0703" d="m388.42 714.12-43.22 83.6a1223 1223 0 0 0-176.15 28.14C133 834.79 98.5 845.18 64.36 859.27c-21.65 8.94-40.82 19.69-61.48 31.71 55.39-99.75 116.09-192.33 182.79-282.18 54.62-73.16 112-142.87 174.48-210.14 39.02 55.96 75.26 112.65 110.12 170.88l-14.42 23.23-9.46 16.78-54.94 98.87z"/><path fill="#d86b83" d="m973.87 2.28-.02 2.54c-5.01 1.09-9.92 2.41-14.95 5.13-58.15 31.49-107.37 72.26-154.95 118.06-39.93 38.44-76.53 79.46-111.8 121.9l-4.13 4.32c.06-1.69.32-2.71 1.09-6.01l-6.01-1.34c-4.56-1.01-10-2.43-14.48-1.38-3.92.92-8.57 3.6-12.24 2.35a41 41 0 0 0-14.38-2.41l-19.99.07-33.26.14-17.54-.02-23.26-.17h-17.96l-13.2-.44c-4.86-.16-9.82.86-14.81.66l-17.98-.73-13.01.4h-20.96l-24.03.16c-4.18.03-8.84-.7-12.93.28-5.74 1.37-10.64 1.75-16.36.53s-12.47-1.22-18.58-1.18l-12.29.08-59.76-.14-7.12 1.03-1.48 4.29C242.75 182.55 165.11 102.49 94.43 50.66 72.45 34.54 50.3 20.25 26.02 8.01 19.01 4.48 11.15 4.24 3.92 2.2c11.22-.7 21.64.72 32.75 2.23 65.97 8.97 130.66 35.65 189.69 66.31 88.21 46.91 167.41 105.22 243.95 171l25.68-201.69 25.66 201.74c85.36-73.34 179.18-141.8 282.19-189.89C853.07 29.06 908.01 9.81 962.01 3.63z"/><path fill="#de0703" d="M928 859.41c-88.17-36.34-190.83-53.31-284.59-62.05l-8.06-16.52c39.5-78.25 80.16-153.75 125.92-230.33 55.41 69.9 106.09 141.63 153.89 216.26 25.24 40.22 49.79 79.74 73.33 123.59-20.61-11.44-38.98-22.09-60.49-30.95"/><path fill="#d53e4f" d="m662.98 285.62-35.13 46.19-15.73 21.14-11.01 15.2c-1.05-3.6-5.06-5.03-9.03-5.07l-14.09-.13-22.78-.18c-4.88-.04-8.57-.06-13.41-.02l-35.76.28-13.05-.61-22.4.37c-8.39.14-16.9.55-25.38-.07-2.73-.2-4.41-.21-7.36.21-10.84 1.54-19.95-3.4-31.88.53-5.57-1.54-10.96-2.14-16.6-1.23l-1.17 5.55-62.7-82.59c-.04-.5 1.35-1.73 1.82-1.82l8.59-1.61 25.08-.22 24.08.16 6.98.42c4.12.25 8.74.95 12.98.44 7.39-.9 14.07-1.41 21.33-.09 11.41-1.07 22.94-1.73 34.53-.46 3.37.37 5.93.5 9.28.05 8.83-1.19 17.78.23 26.71.15l15.52-.15 34.42.09 22.23.26 26.7.32 16.22-.8 10.95-.05 12.94.44 22.38-.32c1.46-.02 4.2 2.76 4.75 3.6Z"/><path fill="#de0703" d="M601.1 368.14a3228 3228 0 0 0-106.58 161.15c-33.72-54.39-68.14-106.68-104.66-158.06l-.91-1.22c-.38-.46-.9-1.63-.78-2.22l1.17-5.55c5.64-.91 11.03-.31 16.6 1.23 11.93-3.93 21.04 1.02 31.88-.53 2.95-.42 4.63-.41 7.36-.21 8.48.61 16.99.2 25.38.07l22.4-.37 13.05.61 35.76-.28c4.85-.04 8.53-.02 13.41.02l22.78.18 14.09.13c3.97.04 7.98 1.47 9.03 5.07Zm9.75 365.55-33.8-62.2c37.83-67.73 77.3-133.98 120.19-198.95l36.36 43.16c-44.01 71.78-83.85 143.09-122.75 218Z"/><path fill="#d44556" d="m688.01 254.23-9.87 12.74-15.16 18.64c-.55-.84-3.3-3.62-4.75-3.6l-22.38.32-12.94-.44-10.95.05-16.22.8-26.7-.32-22.23-.26-34.42-.09-15.52.15c-8.93.09-17.88-1.33-26.71-.15-3.35.45-5.91.32-9.28-.05-11.58-1.27-23.12-.61-34.53.46-7.27-1.33-13.94-.82-21.33.09-4.24.52-8.87-.19-12.98-.44l-6.98-.42-24.08-.16-25.08.22-8.59 1.61c-.48.09-1.86 1.32-1.82 1.82l-28.01-34.76 1.48-4.29 7.12-1.03 59.76.14 12.29-.08c6.11-.04 12.62-.09 18.58 1.18s10.62.84 16.36-.53c4.09-.98 8.75-.25 12.93-.28l24.03-.17h20.96l13.01-.39 17.98.73c4.99.2 9.95-.82 14.81-.66l13.2.44h17.96l23.26.16 17.54.02 33.26-.14 19.99-.07c5.22-.02 9.35.69 14.38 2.41 3.67 1.25 8.32-1.43 12.24-2.35 4.48-1.05 9.93.37 14.48 1.38l6.01 1.34c-.77 3.29-1.03 4.32-1.09 6.01Z"/><path fill="#de0703" d="m553.06 627.85-34.33-58.27c35.42-58.98 72.05-116.6 111.45-172.9l39.39 43.85c-41.03 60.94-78.82 121.98-116.51 187.32"/><path fill="#f998a7" d="m973.85 4.82.02-2.54c4.42-.51 8.52-.82 13.55-.41l-13.58 2.95Z"/></svg>'):"",p=!e.ball||e.ball>c.length?0:e.ball,g=c[p],d=a(`https://raw.githubusercontent.com/msikma/pokesprite/master/items/ball/${g}.png`,g,50),f=Math.max(0,Math.min(100,e.level));if(!e.race||e.race<=0||e.race>1025)return[d,r,i,"",h(i),s,f,m];const w=await o("https://pokeapi.co/api/v2/pokemon/"+e.race),v=await o(w.species.url),u=w.sprites.other[l],x=e.image.length>=1&&"$"===e.image[0],_=e.image.length>=2&&"S"===e.image[1],y=1===e.gender,b=x?_?y&&u.front_shiny_female?u.front_shiny_female:u.front_shiny:y&&u.front_female?u.front_female:u.front_default:e.image,$=await(async(e,a)=>{const l=await o(a.forms[0].url),s=e.names.find(e=>e.language.name===t)?.name??i,r=l.form_names.find(e=>e.language.name===t)?.name;return r?`${s}<br />(${r})`:s})(v,w),k=await(async e=>(await Promise.all(e.map(async e=>{const a=(await o(e.type.url)).names.find(e=>e.language.name===t);return a?a.name:e.type.name}))).join(" / "))(w.types);return[d,a(b,$),$,k,h($),s,f,m]}));dv.table(["ボール","画像","種族","タイプ","ニックネーム","性別","レベル","備考"],h);
@shotadft
Copy link
Copy Markdown
Author

Warning

コード内に含まれているSVG画像にはMITライセンスが適応されません
これは他の場所から引用・転用したものであり、改変すると著作権違反になる可能性があるためです。そのため、別の画像を使用する際は自前で別の画像を用意してください。
重要なことなのでもう一度言います。コード内に含まれているSVG画像にはMITライセンスが適応されません

使い方

  1. データを用意する
    例:
const data = [
    { ball: 1, image: "$", race: 25, name: "せんせい", gender: 0, level: 100, comment: "赤いフェズをかぶっているのが特徴" }
];
  1. 読み込む
await dv.view("scripts/pokelist.min", { data: data });
  1. 完成!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment