User:Alexander Windsor/common.js
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
window.difflink = ['request'];
window.LocalComments = { //本地时间小工具24小时制
twentyFourHours: true
};
window.LocalComments.disablePages = function() { //本地时间小工具黑名单
if (RLCONF.wgDiffOldId !== undefined) return true;
return false;
};
/*
mw.loader.load('https://wikiplus-app.com/Main.min.js?action=raw&ctype=text/javascript');//Wikiplus编辑器
mw.loader.load('/wiki/MediaWiki:Gadget-PatrollCount.js?action=raw&ctype=text/javascript'); //未巡查统计
mw.loader.load('/wiki/User:Former User aDB0haVymg/gadgets/close-anx.js?action=raw&ctype=text/javascript'); //关闭anx
mw.loader.load('/wiki/User:TheJosh/NewPagePatroller.js?action=raw&ctype=text/javascript'); //新页面统计
mw.loader.load('/wiki/User:Vozhuo/Tool/MOSNUM dates.js?action=raw&ctype=text/javascript'); //修正参考来源日期格式
mw.loader.load('/wiki/User:AnYiLin/js/pangu_wiki.user.js?action=raw&ctype=text/javascript'); //中英文加空格
*/
//mw.loader.load('/wiki/User:Alexander_Misel/admin.js?action=raw&ctype=text/javascript');//获取当前在线管理员
mw.loader.load('/wiki/User:PhiLiP/wikicache/load.js?action=raw&ctype=text/javascript');//编辑自动保存,防止误关正在编辑的页面
//mw.loader.load('/wiki/User:Jasonzhuocn/userhighlighter.js?action=raw&ctype=text/javascript');//将所有管理员用户加黄色背景
mw.loader.load('/wiki/User:Super Wang/MarkBlockedUsers.js?action=raw&ctype=text/javascript');//用删除线标记被封禁用户(由User:Super Wang修订)
mw.loader.load('/wiki/User:Vanished user 1929210/js/link-ts.js?action=raw&ctype=text/javascript');//自动翻译链接
mw.loader.load('/wiki/User:Super Wang/CommentsinLocalTime.js?action=raw&ctype=text/javascript');//修正留言日期格式
mw.loader.load('User:Vozhuo/Tool/MOSNUM dates.js');//英文/中文日期格式转ISO
//mw.loader.load('/wiki/User:AnYiLin/js/ArticleInfo.js?action=raw&ctype=text/javascript'); // 页面浏览量
//mw.loader.load('/wiki/User:AnYiLin/js/PurgePageCache.js?action=raw&ctype=text/javascript'); // 清除缓存
importScript("User:小躍/Vote-Template/Vote.js");//投票小工具
if (RLCONF.wgAction === 'history')
mw.loader.load('/wiki/User:WhitePhosphorus/js/rrd.js?action=raw&ctype=text/javascript'); //提报修订版本删除
if (RLCONF.wgAction === 'view' && RLCONF.wgIsArticle && RLCONF.wgCurRevisionId !== 0 && RLCONF.wgRevisionId !== 0 && RLCONF.wgCurRevisionId === RLCONF.wgRevisionId) {
if (RLCONF.wgPageName === 'Wikipedia:防滥用过滤器/错误报告')
mw.loader.load('/wiki/User:Xiplus/js/close-affp.js?action=raw&ctype=text/javascript');//关闭AF/FP报告
if (RLCONF.wgPageName === 'Wikipedia:当前的破坏')
mw.loader.load('/wiki/User:Xiplus/js/close-vip.js?action=raw&ctype=text/javascript');//关闭vip
if (/^MediaWiki:[^/]+(\/zh)?$/.test(RLCONF.wgPageName))
mw.loader.load('/wiki/User:Xiplus/js/TranslateVariants.js?action=raw&ctype=text/javascript'); // 自动转换变体
}
//mw.loader.load('/wiki/User:AnYiLin/js/CheckEligibility.js?action=raw&ctype=text/javascript'); //查询人事票资格
$(function() { // 调用 2010 编辑器(基于 Timeless 皮肤)
if (document.body.classList.contains('skin-timeless') && !RLCONF.wgPageName.match(/\S+\.(css|js|json)$/) && ($('#ca-edit').length > 0 || $('#ca-ve-edit').length > 0) && $('#ca-history').length > 0) {
mw.loader.using(['ext.gadget.site-lib', 'mediawiki.Uri']).then(function() {
var style = document.createElement('style'),
text = wgULS('通过 2010 编辑器编辑', '通過 2010 編輯器編輯', undefined, '透過 2010 編輯器編輯'),
title = wgULS('通过 2010 编辑器编辑本页', '通過 2010 編輯器編輯本頁', undefined, '透過 2010 編輯器編輯本頁'),
dom = '<li id="ca-2010-edit"><a href="' + new mw.Uri().extend({action: 'submit'}).toString() + '" title="' + text + '">' + text + '</a></li>';
style.id = 'css-common';
if ($('#ca-addsection').length > 0) {
style.appendChild(document.createTextNode('@media screen and (max-width:1638px) and (min-width:1232px){#mw-page-header-links{font-size:.8em}}@media screen and (max-width:1232px) and (min-width:850px){#mw-page-header-links{font-size:.2em}}'));
$('#ca-addsection').before(dom);
} else {
style.appendChild(document.createTextNode('@media screen and (max-width:1538px) and (min-width:1392px){#mw-page-header-links{font-size:.8em}}@media screen and (max-width:1392px) and (min-width:1099px){#mw-page-header-links{font-size:.2em}}@media screen and (max-width:1051px) and (min-width:904px){#mw-page-header-links{font-size:.8em}}@media screen and (max-width:904px) and (min-width:850px){#mw-page-header-links{font-size:.2em}}'));
$('#ca-history').before(dom);
}
document.head.appendChild(style)
});
}
});
$(window).ready(function() { // 让 Template:ilh 有和 en:Template:Further_ill 类似的效果
window.setTimeout(function() {
mw.hook('wikipage.content').add(function($item) {
if ($item.attr('id') === 'mw-content-text') {
$('.ilh-all').each(function() {
$(this).find('.ilh-page')
.append($('<sup>').append('[')
.append($('<a>', {
class: 'extiw',
href: $(this).find('.ilh-link>a').attr('href'),
title: $(this).data('foreign-title'),
target: '_blank',
text: $(this).data('lang-code')
})).append(']').css('user-select', 'none'));
});
}
});
}, 500);
});
(function($) { // 让 Gadget-Wordcount 支持触屏
function bytecount(text) {
text = text.replace(/[\u0000-\u007F]/g, '.');
text = text.replace(/[\u0080-\u07FF\uD800-\uDFFF]/g, '..');
text = text.replace(/[\u0800-\uD7FF\uE000-\uFFFF]/g, '...');
return text.length;
};
function cjkcount(text) {
text = text.replace(/\./g, '');
text = text.replace(/[\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u3005\u3007\u3021-\u3029\u3038-\u303B\u3400-\u4DB5\u4E00-\u9FCC\uF900-\uFA6D\uFA70-\uFAD9]|[\uD840-\uD868][\uDC00-\uDFFF]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|[\uD86A-\uD86C][\uDC00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]/g, '.');
text = text.replace(/[^\.]/g, '');
return text.length;
};
function getwcbytext(text) {
return text.length + ' character(s) (' + cjkcount(text) + ' CJK)<br>' + bytecount(text) + ' byte(s) in <a href="' + mw.config.get('wgScript') + '?title=UTF-8">UTF-8</a> encoding';
};
function getsel() {
return window.getSelection().toString();
};
function dowc() {
$('.wordcount').remove();
var text = getsel();
if (text.length == 0) return;
var divj = $('<div>').html(getwcbytext(text))
.css({
'position': 'fixed',
'right': '0',
'bottom': '0',
'margin': '4px',
'padding': '6px'
})
.addClass('wordcount ui-state-highlight ui-corner-all')
.appendTo('body');
window.setTimeout(function() {
divj.fadeOut('slow');
}, 5000);
};
'ontouchstart' in document ? $(document).on('touchstart touchend', dowc) : $(document).mouseup(dowc).keyup(dowc);
})(jQuery);
/*
(function() {
if (!/wmmirror\.live/.test(location.host)) return;
var reg = /\s?\/\/ Edit via \[\[\S+?\]\]/;
$(function() {
setTimeout(function() {
*/ $('#wpSummary').val($('#wpSummary').val().replace(reg, ''));
}, 1000);
});
var mo = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
mutation.addedNodes.forEach(function(node) {
var dom = node.querySelector('.ext-discussiontools-ui-replyWidget-editSummary input');
if (dom) {
setTimeout(function() {
dom.value = dom.value.replace(reg, '');
}, 1000);
}
});
});
});
mo.observe(document.body, {
childList: true,
subtree: true,
});
})();