全站通知:

用户:16083703/替换API

来自原神WIKI_BWIKI_哔哩哔哩
跳到导航 跳到搜索

语音替换

var pages = [
    "a",
    "b"
]
console.log(pages);
for (i in pages) {
    new mw.Api().edit("i", function (revision) {
        var text = revision.content;
        text = text.replace(/\|.*?er\|._.*?\n/g, "")
        text = text.replace(/(\|.*?=)(\{\{)(.*)(\|)(.*)(\}\})/g, "$1$3-$5")
        text = text.replace(/(\{\{.*?\/语音)/g, "$11")
        return {
            text: text,
            summary: "edit",
            minor: true
        };
    })
}

删除多余模板:

\|.*?er\|._.*?\n

替换模板:

(\|.*?=)(\{\{)(.*)(\|)(.*)(\}\})
$1$3-$5
(\{\{.*?语音\n)
$11

成就替换

new mw.Api().edit("沙盒/沙盒成就", function (revision) {
    var text = revision.content;
    text = text.replace(/(<div class="box-ic[\s\S]*?=|\][\s\S]*?\n)/g,function ($0,$1) {
	return {
		'<div class="box-ic[\s\S]*?=':"我是开头",
		"\][\s\S]*?\n":"我是结尾\n"
	}[$1];
	})
    return {
		text: text,
		summary: "替换",
		minor: true
	}
})
new mw.Api().edit("沙盒/沙盒成就", function (revision) {
    var text = revision.content;
    text = text.replace(/(<div class="box-ic[\s\S]*?=)|(\][\s\S]*?\n)/g,'$我是开头$我是结尾\n')
	return {
		text: text,
		summary: "替换",
		minor: true
	};
})
new mw.Api().edit("沙盒/沙盒成就", function (revision) {
    var text = revision.content;
    text = text.replace(/(<div class="box-ic[\s\S]*?=)([\s\S]*?)(\][\s\S]*?>)/g, (v,
    ...args) => {
    console.log(v)
    console.log(args[1])
    args[0] = "{{图标|成就|"
    args[2] = "}}"
    var data = args.splice(0, 3).join("")
    console.log(data);
    return data
})
    return {
		text: text,
		summary: "edit",
		minor: true
	};
})