2,424
个编辑
MCBBS Wiki欢迎您共同参与编辑!在参与编辑之前请先阅读Wiki方针。
如果在编辑的过程中遇到了什么问题,可以去讨论板提问。
为了您能够无阻碍地参与编辑 未验证/绑定过邮箱的用户,请尽快绑定/验证。
MCBBS Wiki GitHub群组已上线!
您可以在回声洞中发表吐槽!
服务器状态监控。点击进入
本站由MCBBS用户自行搭建,与MCBBS及东银河系漫游指南(北京)科技有限公司没有从属关系。点此了解 MCBBS Wiki 不是什么>>
小无编辑摘要 标签:移动版编辑 移动版网页编辑 |
无编辑摘要 标签:移动版编辑 移动版网页编辑 |
||
| 第74行: | 第74行: | ||
} | } | ||
function replaceText(title, org, subst, summary) { | |||
if (summary == undefined){summary = "";} | |||
$.ajax( | |||
{url: "/api.php?action=query&meta=tokens&format=json&type=csrf", type: "GET", | |||
success: function(data){ | |||
var csrftoken = data.query.tokens.csrftoken; | |||
$.ajax( | |||
{url: "/api.php?action=query&prop=revisions&titles=" + title + "&rvprop=content&indexpageids=true&format=json", type: "GET", | |||
success: function(data){ | |||
var pageId = data.query.pageids[0]; | |||
var wikiText = data.query.pages[pageId].revisions[0]["*"]; | |||
var changedText = wikiText.split(org).join(subst)//do something with it | |||
$.ajax({url:"/api.php?action=edit&format=json", type:"POST", | |||
data: {title: title, summary: summary, minor: "true", basetimestamp: "now", text: changedText, token: csrftoken}, | |||
success: function(data){console.log(JSON.stringify(data));}}); | |||
}}) | |||
}} | |||
) | |||
} | |||
function massReplace (org, subst) {$.ajax({url: "/api.php?action=query&format=json&list=search&srsearch=" + org + "&srlimit=max&srwhat=text&srprop=", type: "GET", success: function (data) { | |||
var results = data.query.search; | |||
for (i = 0; results[i]; i += 1) | |||
{replaceText(results[i].title, org, subst, "批量替换" + org + "为" + subst + ",第" + i + "个");} | |||
} | |||
}) | |||
} | |||