社区文档构建进行中,欢迎编辑。社区答疑群(非官方):717421103,点点小课堂(腾讯会议):5696651544

全站通知:

Widget:GIU

来自WIKI实验室WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

<input id="imageTitle" placeholder="在此输入图片标题"><input type="button" onclick=GIUFun.getImgURI() value="提交"> <input id="imgURI" style="width:100%"> <script> GIUFun={ "getImgURI":function(){ let imgTitle=document.getElementById("imageTitle").value let result="" if(imgTitle){ result=getApi(encodeURI("https://wiki.biligame.com"+mw.config.values.wgScriptPath+"/api.php?action=parse&contentmodel=wikitext&prop=text&text=文件:"+imgTitle+"&format=json")) try{ result=result.parse.text["*"].match(/src="(.*?)"/)[1] } catch(e){ result="" } } document.getElementById("imgURI").value=result } } function getApi(url,callback=false,callbackE=false){ let ajax=new XMLHttpRequest() if(!callback){ ajax.open("GET",url,false) ajax.send() let json=JSON.parse(ajax.responseText) return json } ajax.open("GET",url) ajax.send() ajax.onreadystatechange=function(){ if(ajax.readyState==4){ if(ajax.status==200){ callback(ajax.responseText) } else if(ajax.status==404&&callbackE){ callbackE(true) } } } } </script>