MediaWiki:Gadget-fixCrossWikiNotif.js
跳转到导航
跳转到搜索
注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
- Opera:按 Ctrl-F5。
mw.loader.using(['ext.echo.api', 'mediawiki.language']).then(function() {
if (mw.echo.api.EchoApi.prototype.DEFAULTfetchNotifications) return;
mw.echo.api.EchoApi.prototype.DEFAULTfetchNotifications = mw.echo.api.EchoApi.prototype.fetchNotifications;
mw.echo.api.EchoApi.prototype.fetchNotifications = function() {
return this.DEFAULTfetchNotifications.apply(this, arguments).then(function(data) {
var foreignNotifData = ( data || { list: [] } ).list.find(function(notifData) {
return notifData.type === 'foreign';
}), wikiList, source, title;
if (foreignNotifData) {
wikiList = [];
for (source in foreignNotifData.sources) {
title = source.replace('_', '.wiki.gg/').replace(/\/en$/, '');
wikiList.push(title);
foreignNotifData.sources[source].title = title;
foreignNotifData.sources[source].url = 'https://' + title + '/api.php';
foreignNotifData.sources[source].base = 'https://' + title + '/wiki/$1';
}
if (foreignNotifData['*'] && foreignNotifData['*'].body === mw.language.listToText(Array(wikiList.length).fill(''))) {
foreignNotifData['*'].body = mw.language.listToText(wikiList);
}
}
return data;
});
};
});