用户:夕舞八弦/childPage.js

来自PRTS
跳转到导航 跳转到搜索

注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:Ctrl-F5
var url = window.location.pathname;
url=decodeURI(url);
url=url.substr(3);
var ns;
var api = new mw.Api();
api.get({
	"action": "query",
	"prop":"pageprops",
	"titles":url,
}).done(function(data){
	for(let temO in data.query.pages)
	{
		var o=data.query.pages[temO]; 
		ns=o.ns;
		if(ns!==0){
			url=url.substr(url.indexOf(":")+1);
		}
		var api2 = new mw.Api();
			api2.get({
				"action": "query",
				"list": "allpages",
				"apprefix":url,
				"aplimit":500,
				"apnamespace":ns
			}).done(function(data2){
				for( let i of data2.query.allpages){
   					console.log("http://prts.wiki/w/"+i.title.replace(/ /g,"_"));
				}
	});
	}
});