提供: Japanese Scratch-Wiki
注意: 保存後、変更を確認するにはブラウザーのキャッシュを消去する必要がある場合があります。
- Firefox / Safari: Shift を押しながら 再読み込み をクリックするか、Ctrl-F5 または Ctrl-R を押してください (Mac では ⌘-R)
- Google Chrome: Ctrl-Shift-R を押してください (Mac では ⌘-Shift-R)
- Internet Explorer / Microsoft Edge: Ctrl を押しながら 最新の情報に更新 をクリックするか、Ctrl-F5 を押してください
- Opera: Ctrl-F5を押してください
function getIWs(pn){ const pnn=pn.replace(/ /g, "+"); const link = `https://en.scratch-wiki.info/w/api.php?action=parse&format=json&origin=*&page=${pnn}&redirects=1&prop=langlinks`; let j=$.ajax({ url:link, type:'GET', async:false }) console.log(j); let langlinks=j.responseJSON.parse.langlinks; return langlinks; } function getIWtext(lll){ let newiw=lll.filter(p => ["de","fr","hu","id","ru","nl"].includes(p.lang)); console.log(newiw); return newiw.map(k => `[[${k.lang}:${k["*"]}]]`).join(""); } function getEnLink(){ try{ return /\[\[en:([^\]]+)\]\]/.exec($("#wpTextbox1")[0].value)[1]; }catch(e){return "";} } function askPageName(){ let res=window.prompt( 'English pagename', getEnLink() ); if (!res) return ""; return res; } function runProgram(){ let page=askPageName(); let iw="\n"+getIWtext(getIWs(page)); if (!(/\[\[en:([^\]]+)\]\]/.exec($("#wpTextbox1")[0].value))) iw+=`[[en:${page}]]`; $("#wpTextbox1")[0].value+=iw; } window.addEventListener("load", function(){ if (!mw || !$) return; if (!["edit","submit"].includes(mw.config.get("wgAction"))) return; $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'section': 'advanced', 'group': 'insert', 'tools': { 'getiw': { label: 'Get interwiki', // or use labelMsg for a localized label, see above type: 'button', icon: '//upload.wikimedia.org/wikipedia/commons/thumb/e/e4/Twemoji_1f30f.svg/22px-Twemoji_1f30f.svg.png', action: { type: 'callback', execute: runProgram } } } } ); });