“User:Func/vector.js”的版本间的差异

来自萌娘共享
跳转至: 导航搜索
(// Edit via Wikiplus)
(// Edit via Wikiplus)
第4行: 第4行:
 
mw.loader.load("https://zh.moegirl.org.cn/index.php?title=User:Func/HotCat.js&action=raw&ctype=text/javascript");
 
mw.loader.load("https://zh.moegirl.org.cn/index.php?title=User:Func/HotCat.js&action=raw&ctype=text/javascript");
  
mw.loader.load('https://zh.moegirl.org.cn/index.php?title=MediaWiki:Gadget-popups-startup.js&action=raw&ctype=text/javascript');
+
mw.loader.load('https://zh.moegirl.org.cn/index.php?title=MediaWiki:Gadget-popups-main.js&action=raw&ctype=text/javascript');
  
 
function rallbackInit() {
 
function rallbackInit() {

2021年2月8日 (一) 17:55的版本

// mw.loader.load('//www.mediawiki.org/w/index.php?title=MediaWiki:Gadget-DotsSyntaxHighlighter.js&action=raw&ctype=text/javascript');
mw.loader.load('https://wikiplus-app.com/Main.js');
mw.loader.load('https://zh.moegirl.org.cn/index.php?title=User:東東君/js/Wikiplus-replace.js&action=raw&ctype=text/javascript');
mw.loader.load("https://zh.moegirl.org.cn/index.php?title=User:Func/HotCat.js&action=raw&ctype=text/javascript");

mw.loader.load('https://zh.moegirl.org.cn/index.php?title=MediaWiki:Gadget-popups-main.js&action=raw&ctype=text/javascript');

function rallbackInit() {
	var alledit = $(".mw-contributions-current");
	for( var m = 0, len = alledit.length; m < len; m++ ) {
		var newChk = document.createElement("input");
		newChk.type = "checkbox";
		newChk.setAttribute("data-title", alledit[m].getElementsByClassName("mw-contributions-title")[0].innerText);
		newChk.setAttribute("data-revid", alledit[m].getAttribute("data-mw-revid"));
		alledit[m].prepend(newChk);
	}
	$(".mw-contributions-list").prepend('<div><div style="float:right;" class="mw-history-revisionactions"><button type="submit" name="undobackbatch" value="1" class="contributions-undo-button">撤销选中版本</button><button type="submit" name="rollbackbatch" value="1" class="contributions-rollback-button">回退选中页面</button></div><div class="mw-checkbox-toggle-controls">选择:<a class="mw-checkbox-all" role="button" tabindex="0">全选</a>、<a class="mw-checkbox-none" role="button" tabindex="0">全不选</a>、<a class="mw-checkbox-invert" role="button" tabindex="0">反选</a></div></div>');
 
	var $checkboxes = $('li input[type="checkbox"]');
	function selectAll(check) {
		$checkboxes.prop('checked', check);
	}
	$('.mw-checkbox-all').click(function() {
		selectAll(true);
	});
	$('.mw-checkbox-none').click(function() {
		selectAll(false);
	});
	$('.mw-checkbox-invert').click(function() {
		$checkboxes.prop('checked', function(i, val) {
			return !val;
		});
	});
	
	const api = new mw.Api();
	$('.contributions-rollback-button').click(function() {
		const checked = $(".mw-contributions-list li :checkbox:checked");
		const user = mw.config.get("wgRelevantUserName");
		if (!confirm("您确定要回退这些页面吗?(选中了" + checked.length + "个页面)")) { return; }
		console.log("开始回退...");
		for( var m = 0, len = checked.length; m < len; m++ ) {
			var title = checked[m].getAttribute("data-title");
			try {
				api.postWithToken("rollback", {
					action: "rollback",
					format: "json",
					title: title,
					user: user,
					tags: "Automation tool",
					summary: "//Rollback"
				}).done( console.log("回退成功:" + title) );
			} catch (e) {
				console.log("回退失败:" + e instanceof Error ? e.stack.split("\n")[1].trim() : JSON.stringify(e));
			}
		}
	});
	
		$('.contributions-undo-button').click(function() {
		const checked = $(".mw-contributions-list li :checkbox:checked");
		const user = mw.config.get("wgRelevantUserName");
		if (!confirm("您确定要撤销这些版本吗?(选中了" + checked.length + "个页面)")) { return; }
		console.log("开始撤销...");
		for( var m = 0, len = checked.length; m < len; m++ ) {
			var title = checked[m].getAttribute("data-title");
			var revid = checked[m].getAttribute("data-revid");
			try {
				api.postWithToken("csrf", {
					action: "edit",
					format: "json",
					title: title,
					undo: revid,
					tags: "Automation tool",
					summary: "//Undo"
				}).done( console.log("撤销成功:" + title) );
			} catch (e) {
				console.log("撤销失败:" + e instanceof Error ? e.stack.split("\n")[1].trim() : JSON.stringify(e));
			}
		}
	});
}

$( function() {
	if ( mw.config.get("wgCanonicalSpecialPageName") === "Contributions" ) {
		rallbackInit();
	}
	$("ul").on("copy", function () {
		event.returnValue = false;
		var text = window.getSelection().toString();
		const input = document.createElement('input');
		document.body.appendChild(input);
		input.setAttribute('value', text.replace(/[\xA0\u1680\u180E\u2000-\u200B\u200E\u200F\u2028-\u202F\u205F\u3000]*/g, "")); // 去除 &lmr;等
		input.select();
		document.execCommand('copy');
		document.body.removeChild(input);
	});
});