「Widget:萌百条目」:修訂間差異
跳至導覽
跳至搜尋
無編輯摘要
imported>Irukaza 無編輯摘要 |
imported>Irukaza 無編輯摘要 |
||
(未顯示同一使用者於中間所作的 16 次修訂) | |||
行 2: | 行 2: | ||
<includeonly> | <includeonly> | ||
<script> | <script> | ||
const jsonp = (() => { | const jsonp = (() => { | ||
let incrementCallbackKey = 0 | let incrementCallbackKey = 0 | ||
return function jsonp(config) { | return function jsonp(config) { | ||
return new Promise((resolve, reject) => { | return new Promise((resolve, reject) => { | ||
行 27: | 行 18: | ||
scriptTag.onerror = () => reject(new Error('jsonp request error')) | scriptTag.onerror = () => reject(new Error('jsonp request error')) | ||
document.body.appendChild(scriptTag) | document.body.appendChild(scriptTag) | ||
setTimeout(() => reject(new Error('jsonp request timeout')), | setTimeout(() => reject(new Error('jsonp request timeout')), 1_200) | ||
}) | }) | ||
} | } | ||
行 33: | 行 24: | ||
jsonp({ | jsonp({ | ||
url: 'https:// | url: 'https://zh.moegirl.org/api.php', | ||
params: { | params: { | ||
action: 'parse', | action: 'parse', | ||
行 47: | 行 38: | ||
} | } | ||
}) | }) | ||
</script> | </script> | ||
</includeonly> | </includeonly> |