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

来自萌娘共享
跳转至: 导航搜索
第6行: 第6行:
 
$.ajax({
 
$.ajax({
 
url: 'https://zh.moegirl.org.cn/' + mw.config.get('wgPageName'),
 
url: 'https://zh.moegirl.org.cn/' + mw.config.get('wgPageName'),
beforeSend: function(XHR) {
 
XHR.setRequestHeader('accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9')
 
},
 
 
success: function(data) {
 
success: function(data) {
 
let links = $('div#mw-imagepage-section-linkstoimage', $(data));
 
let links = $('div#mw-imagepage-section-linkstoimage', $(data));
第17行: 第14行:
 
$(nolinks).replaceWith($('<p />').html('获取链入错误:' + $('<font color="red" />').text(msg)))
 
$(nolinks).replaceWith($('<p />').html('获取链入错误:' + $('<font color="red" />').text(msg)))
 
},
 
},
dataType: 'html'
+
dataType: 'html',
 +
crossDomain: true
 
});
 
});
 
})
 
})

2021年1月27日 (三) 20:36的版本

'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)))
			},
			dataType: 'html',
			crossDomain: true
		});
})