MediaWiki:Gadget-webfont.js
外观
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
//使用方法参考 http://glyphwiki.org/wiki/GlyphWiki:%E3%81%A9%E3%81%86%E3%82%84%E3%81%A3%E3%81%A6%E4%BD%BF%E3%81%86%E3%81%AE%E3%81%8B
//2012-09-11
(function($, mw) {
if ($('div#content').find('span#glyphwebfont').length > 0 || $('div#content').find('span#glyphwebfont-one').length > 0) {
var glyphwikiurls = $.map($('span#glyphwebfont'), function(elem) {
if ($(elem).attr('class') !== undefined) return 'https://tools.wmflabs.org/zhnotofu/webfont.php?wf=' + $(elem).attr('class')
});
var glyphwikiurl = $.map($('span#glyphwebfont-one'), function(elem) {
if ($(elem).attr('class') !== undefined) return 'https://tools.wmflabs.org/zhnotofu/webfont.php?wf1=' + $(elem).attr('class')
});
//console.log(glyphwikiurl);
if (glyphwikiurl.length > 0 || glyphwikiurls.length > 0) {
var total = glyphwikiurls.concat(glyphwikiurl);
//console.log(total);
window.WebFontConfig = {
custom: {
urls: total
}
};
//importScript('MediaWiki:Gadget-webfontloader.js');
mw.loader.load('https://tools-static.wmflabs.org/cdnjs/ajax/libs/webfont/1.6.24/webfontloader.js')
}
//去重
var glyphmap = {};
$('span#glyphwebfont').each(function() {
var value = $(this).attr('class');
if (!glyphmap[value]) glyphmap[value] = true
});
//支持标题
mw.util.addCSS('.mw-body h1, .mw-body-content h1, .mw-body-content h2 {font-family: "Linux Libertine", Georgia, Times, serif, ' + Object.keys(glyphmap).join(',') + '}');
//支持全页
mw.util.addCSS('html, body {font-family: sans-serif,' + Object.keys(glyphmap).join(',') + '}');
//移动版标题
if (mw.config.get('skin') === 'minerva') mw.util.addCSS('.pre-content h1, .content h1, .content h2 {font-family: "Linux Libertine", Georgia, Times, serif, ' + Object.keys(glyphmap).join(',') + '}')
}
})(jQuery, mw);