“User:サンムル/js/linksToImage.js”的版本间的差异

来自萌娘共享
跳转至: 导航搜索
 
第12行: 第12行:
 
},
 
},
 
error: function(XHR, msg, e) {
 
error: function(XHR, msg, e) {
$(nolinks).replaceWith($('<p />').html('获取链入错误:' + $('<font color="red" />').text(msg)))
+
$(nolinks).replaceWith($('<p />').html('获取链入错误:' + $('<font color="red" />').text(msg).html()))
 
},
 
},
 
dataType: 'html',
 
dataType: 'html',

2021年1月27日 (三) 20:38的最新版本

'use strict';
$(function() {
	if (mw.config.get('wgNamespaceNumber') !== 6) return; // 非File名称空间。
	let nolinks = $("div#mw-imagepage-nolinkstoimage");
	if (nolinks.length !== 0)
		$.ajax({
			url: 'https://zh.moegirl.org.cn/' + mw.config.get('wgPageName'),
			success: function(data) {
				let links = $('div#mw-imagepage-section-linkstoimage', $(data));
				if (links.length !== 0)
					$(nolinks).replaceWith(links);
			},
			error: function(XHR, msg, e) {
				$(nolinks).replaceWith($('<p />').html('获取链入错误:' + $('<font color="red" />').text(msg).html()))
			},
			dataType: 'html',
			crossDomain: true
		});
})