MCBBS Wiki欢迎您共同参与编辑!在参与编辑之前请先阅读Wiki方针。
如果在编辑的过程中遇到了什么问题,可以去讨论板提问。
为了您能够无阻碍地参与编辑 未验证/绑定过邮箱的用户,请尽快绑定/验证。
MCBBS Wiki GitHub群组已上线!
您可以在回声洞中发表吐槽!
服务器状态监控。点击进入
本站由MCBBS用户自行搭建,与MCBBS及东银河系漫游指南(北京)科技有限公司没有从属关系。点此了解 MCBBS Wiki 不是什么>>
用户:QWERTY770/common.js:修订间差异
跳到导航
跳到搜索
(Gadget代替// Edit via Wikiplus) |
(InPageEdit) |
||
(未显示同一用户的2个中间版本) | |||
第1行: | 第1行: | ||
var thisHref = window.location.href |
var thisHref = window.location.href |
||
try { |
|||
/* Wikiplus */ |
|||
mw.loader.load('https:// |
mw.loader.load('https://cdn.jsdelivr.net/npm/mediawiki-inpageedit') |
||
} catch (error) { |
|||
mw.loader.load('https://unpkg.com/mediawiki-inpageedit') |
|||
} |
|||
/* 部分链接新窗口打开 */ |
/* 部分链接新窗口打开 */ |
||
第15行: | 第18行: | ||
for (var i = a_mct.length - 1; i >= 0; i--) { |
for (var i = a_mct.length - 1; i >= 0; i--) { |
||
a_mct[i].setAttribute("target","_blank") |
a_mct[i].setAttribute("target","_blank") |
||
} |
} |
||
} |
} |
||
$('#p-personal ul').append('<li><a href="?action=purge">强制刷新</a><li>') |
$('#p-personal ul').append('<li><a href="?action=purge">强制刷新</a><li>') |
||
$('#p-personal ul').append('<li><a href=" |
$('#p-personal ul').append('<li><a href="?action=info">info</a></li>'); |
||
$('#p-personal ul').append('<li><a href="https://mcbbs.wiki/wiki/User: |
$('#p-personal ul').append('<li><a href="https://mcbbs.wiki/wiki/User:QWERTY770/common.js">js</a></li>') |
||
$('#p- |
$('#p-personal ul').append('<li><a href="https://mcbbs.wiki/wiki/User:QWERTY770/common.css">css</a></li>') |
||
$('#p-help ul').append('<li><a href="https://mcbbs.wiki/wiki/%E6%A8%A1%E6%9D%BF:MCBBS%E8%AE%BA%E5%9D%9B%E4%BA%8B%E4%BB%B6">MCBBS事件</a></li>') |
|||
$('#p-help ul').append('<li><a href="https://mcbbs.wiki/wiki/%E6%A8%A1%E6%9D%BF:MCBBS%E8%AE%BA%E5%9D%9B%E6%9C%BA%E5%88%B6">MCBBS机制</a></li>') |
|||
$('#p-help ul').append('<li><a href="https://mcbbs.wiki/wiki/%E6%A8%A1%E6%9D%BF:MCBBS%E8%AE%BA%E5%9D%9B%E7%94%A8%E6%88%B7">MCBBS用户</a></li>') |
|||
$('#p-help ul').append('<li><a href="https://mcbbs.wiki/wiki/%E6%A8%A1%E6%9D%BF:MCBBS%E8%AE%BA%E5%9D%9B%E7%89%88%E5%9D%97">MCBBS板块</a></li>') |
|||
$('#p-help ul').append('<li><a href="https://mcbbs.wiki/wiki/%E5%88%86%E7%B1%BB:%E7%B4%A2%E5%BC%95">索引</a></li>') |
|||
$('#p-help ul').append('<li><a href="https://mcbbs.wiki/wiki/MCBBS_Wiki:%E7%94%B3%E8%AF%B7%E8%81%8C%E4%BD%8D">申请职位</a></li>') |
|||
$('#mw-panel .portal:eq(2)').remove() |
|||
// 在 $(document).ready 中调用 |
// 在 $(document).ready 中调用 |
||
第43行: | 第38行: | ||
/* 强制显示头像&用户名 */ |
/* 强制显示头像&用户名 */ |
||
$('head').append("<style>.comment-post .comment-avatar {opacity: 1;transition: all .3s;}.comment-post .comment-user {opacity: 1;transition: all .3s;}</style>") |
$('head').append("<style>.comment-post .comment-avatar {opacity: 1;transition: all .3s;}.comment-post .comment-user {opacity: 1;transition: all .3s;}</style>") |
||
/* MCBBS Wiki Helper 0.7.6 */ |
|||
/* By FreeLieAlgebra */ |
|||
/* lib |
|||
---------------------------------------------------------------------- |
|||
*/ |
|||
function getTitle() { |
|||
return mw.config.get("wgPageName"); |
|||
} |
|||
function getPatrolToken(func) { |
|||
$.ajax({url: "/api.php?action=query&meta=tokens&format=json&type=patrol", type: "GET", success: function(data){func(data.query.tokens.patroltoken);}}) |
|||
} |
|||
function getCsrfToken(func) { |
|||
$.ajax({url: "/api.php?action=query&meta=tokens&format=json&type=csrf", type: "GET", success: function(data){func(data.query.tokens.csrftoken);}}) |
|||
} |
|||
function getRollbackToken(func) { |
|||
$.ajax({url: "/api.php?action=query&meta=tokens&format=json&type=rollback", type: "GET", success: function(data){func(data.query.tokens.rollbacktoken);}}) |
|||
} |
|||
function getWikiText(title, func) { |
|||
$.ajax({url: "/api.php?action=query&prop=revisions&titles=" + title + "&rvprop=content&indexpageids=true&format=json", type: "GET", success: function(data){func(data.query.pages[data.query.pageids[0]].revisions[0]["*"]);}}) |
|||
} |
|||
function getRevIds(func) { |
|||
$.ajax( |
|||
{url: "/api.php?action=query&prop=revisions&titles="+ title + "&rvlimit=20&rvprop=ids&format=json", type: "GET", success: function(data){ |
|||
var revisionslist = data.query.pages[pageid.toString()].revisions; |
|||
var revli = []; |
|||
for(i = 0; revisionslist[i]; i +=1) |
|||
{revli[i] = revisionslist[i].revid;} |
|||
func(revli);} |
|||
} |
|||
) |
|||
} |
|||
function searchWiki(text, func){ |
|||
$.ajax({url: "/api.php?action=query&format=json&list=search&srsearch=" + text + "&srlimit=max&srwhat=text&srprop=", type: "GET", success: |
|||
function(data){ |
|||
var res = data.query.search, res2 = []; |
|||
for(i = 0; res[i]; i += 1) |
|||
{res2[i]=res[i].title;} |
|||
func(res2);} |
|||
}); |
|||
} |
|||
function patrolRevision (patroltoken, revid){ |
|||
$.ajax({url: "/api.php?action=patrol&format=json", type: "POST", data: {"token" : patroltoken, "revid" : revid}}); |
|||
} |
|||
function editPage(title, summary, minor, text, csrftoken){ |
|||
$.ajax({url:"/api.php?action=edit&format=json", type:"POST", data: {title: title, summary: summary, minor: minor, basetimestamp: "now", text: text, token: csrftoken}}); |
|||
} |
|||
function movePage (from, to, reason, csrftoken, func) { |
|||
$.ajax({url:"/api.php?action=move", data: {from:from, to: to, reason: reason, token:csrftoken}, type: "POST", success: function(data){func(data);}}); |
|||
} |
|||
function getLinksHere(title, func) { |
|||
$.ajax({url: "/api.php?action=query&prop=linkshere&lhnamespace=*&lhlimit=max&lhprop=title&indexpageids=true&format=json&titles=" + title, type: "GET", success: function(data) |
|||
{var res = data.query.pages[data.query.pageids[0]].linkshere, res2 = []; |
|||
for (i = 0; res[i]; i += 1){ |
|||
res2[i] = res[i].title; |
|||
} |
|||
func(res2); |
|||
} |
|||
}); |
|||
} |
|||
/* ------ action functions------*/ |
|||
function patrolAll() { |
|||
getRevIds(function (revli) { |
|||
getPatrolToken(function (patroltoken) { |
|||
for(i = 0; revli[i]; i += 1){ |
|||
patrolRevision(patroltoken, revli[i]); |
|||
} |
|||
}); |
|||
}); |
|||
} |
|||
function inPageAPITest(){ |
|||
var option = prompt("请输入测试项目", "wgPageName"); |
|||
if (option != null) { |
|||
var result = mw.config.get(option); |
|||
prompt("结果:", result); |
|||
} |
|||
} |
|||
function replaceText(title, org, subst, summary) { |
|||
if (summary == undefined){summary = "";} |
|||
getCsrfToken(function (csrftoken) { |
|||
getWikiText(title, function (wikiText) { |
|||
var changedText = wikiText.split(org).join(subst); |
|||
editPage(title, summary, "true", changedText, csrftoken); |
|||
}); |
|||
}); |
|||
} |
|||
function massSearchReplace (org, subst) { |
|||
searchWiki(org, function (pageTitleList) { |
|||
for (i = 0; pageTitleList[i]; i += 1) |
|||
{replaceText(pageTitleList[i], org, subst, "批量搜索替换“" + org + "”为“" + subst + "”,第" + i + "个");} |
|||
}); |
|||
} |
|||
function massSearchReplacePrompt (){ |
|||
var org = prompt("org"); |
|||
var subst = prompt("subst"); |
|||
if (prompt("Continue?") != null) |
|||
{massSearchReplace(org, subst);} |
|||
} |
|||
function deepMove (from, to, reason) { |
|||
getCsrfToken(function (csrftoken) { |
|||
movePage(from, to, reason, csrftoken, function(data){ |
|||
getLinksHere(from, function (pageList) { |
|||
for (i = 0; pagelist[i]; i += 1){ |
|||
replaceText(pageList[i], "[[" + from + "]]", "[[" + to + "]]", "// DeepMove by MBWH"); |
|||
} |
|||
}); |
|||
}); |
|||
}); |
|||
} |
|||
function deepMovePrompt(){ |
|||
var from = prompt("From:", title); |
|||
var to = prompt("To:"); |
|||
var reason = prompt("Reason:"); |
|||
if (prompt("Continue?") != null) |
|||
{deepMove(from, to, reason);} |
|||
} |
|||
/* 一些变量 |
|||
---------------------------------------------------------------------- |
|||
*/ |
|||
var title, res1, pageid; |
|||
title = getTitle(); |
|||
res1 = "/wiki/Special:WhatLinksHere/" + title; |
|||
pageid = mw.config.get("wgArticleId"); |
|||
/* 电脑版 |
|||
---------------------------------------------------------------------- |
|||
*/ |
|||
/* 右上角添加 */ |
|||
$('#p-personal ul').append('<li><a href="?action=info">info</a></li>'); |
|||
/* 手机版 |
|||
---------------------------------------------------------------------- |
|||
*/ |
|||
/* 手机版左端导航添加 */ |
/* 手机版左端导航添加 */ |
||
$('#p-tb').append('<div class="mbwh-mb-pl-btn"><li class=""><button onclick="getRevIds(window.alert);">getRevIds</button></li><li class=""><button onclick="patrolAll();">patrolAll</button></li><li class=""><button onclick="inPageAPITest();">inPageAPITest</button></li><li class=""><button onclick="massSearchReplacePrompt();">批量搜索替换</button></li><li class=""><button onclick="deepMovePrompt();">DeepMove</button></li></div>'); |
|||
/* Wikiplus (Deprecated, use InPageEdit instead) |
|||
$('#p-tb').append('<div class="mbwh-mb-pl-btn"><li class=""><button onclick="getRevIds(window.alert);">getRevIds</button></li><li class=""><button onclick="patrolAll();">patrolAll</button></li><li class=""><button onclick="inPageAPITest();">inPageAPITest</button></li><li class=""><button onclick="massSearchReplacePrompt();">批量搜索替换</button></li><li class=""><button onclick="deepMovePrompt();">DeepMove</button></li></div>'); |
|||
mw.loader.load('https://wikiplus-app.com/Main.js'); */ |
2024年6月16日 (日) 21:45的最新版本
var thisHref = window.location.href
try {
mw.loader.load('https://cdn.jsdelivr.net/npm/mediawiki-inpageedit')
} catch (error) {
mw.loader.load('https://unpkg.com/mediawiki-inpageedit')
}
/* 部分链接新窗口打开 */
addTarget("mw-changeslist-title")
addTarget("mw-changeslist-diff")
addTarget("mw-changeslist-diff-cur")
addTarget("mw-changeslist-groupdiff")
addTarget("mw-changeslist-history")
addTarget("mw-userlink")
function addTarget (obj) {
var a_mct = document.getElementsByClassName(obj);
for (var i = a_mct.length - 1; i >= 0; i--) {
a_mct[i].setAttribute("target","_blank")
}
}
$('#p-personal ul').append('<li><a href="?action=purge">强制刷新</a><li>')
$('#p-personal ul').append('<li><a href="?action=info">info</a></li>');
$('#p-personal ul').append('<li><a href="https://mcbbs.wiki/wiki/User:QWERTY770/common.js">js</a></li>')
$('#p-personal ul').append('<li><a href="https://mcbbs.wiki/wiki/User:QWERTY770/common.css">css</a></li>')
// 在 $(document).ready 中调用
$(document).ready(function(){
loadAddon('loadprism')
})
// 这个函数封装了 mw.loader
function loadAddon(s) {
mw.loader.load("//mcbbs.wiki/index.php?title=MediaWiki:Addon-" + s + ".js&action=raw&ctype=text/javascript"
, "text/javascript");
}
/* 强制显示头像&用户名 */
$('head').append("<style>.comment-post .comment-avatar {opacity: 1;transition: all .3s;}.comment-post .comment-user {opacity: 1;transition: all .3s;}</style>")
/* 手机版左端导航添加 */
$('#p-tb').append('<div class="mbwh-mb-pl-btn"><li class=""><button onclick="getRevIds(window.alert);">getRevIds</button></li><li class=""><button onclick="patrolAll();">patrolAll</button></li><li class=""><button onclick="inPageAPITest();">inPageAPITest</button></li><li class=""><button onclick="massSearchReplacePrompt();">批量搜索替换</button></li><li class=""><button onclick="deepMovePrompt();">DeepMove</button></li></div>');
/* Wikiplus (Deprecated, use InPageEdit instead)
mw.loader.load('https://wikiplus-app.com/Main.js'); */