LLWiki正在建设中,欢迎加入我们!
“MediaWiki:Gadget-site-shared.js”的版本间差异
跳转到导航
跳转到搜索
小 标签:移动版网页编辑 移动版编辑 |
|||
第1行: | 第1行: | ||
"use strict"; |
|||
/*global mw, $, OO, wgULS*/ |
|||
// Unslashifier by [[wikipedia:User:Majavah]] |
// Unslashifier by [[wikipedia:User:Majavah]] |
||
const pagename = mw.config.get('wgPageName'); |
const pagename = mw.config.get('wgPageName'); |
||
第9行: | 第11行: | ||
$content.find('a').filter(function() { return /(Μ's|Lily white)/.test( this.textContent ); }) |
$content.find('a').filter(function() { return /(Μ's|Lily white)/.test( this.textContent ); }) |
||
.each(function() { |
.each(function() { |
||
$(this).text( this.textContent.replace("Μ's", "μ's").replace('Lily white', 'lily white') ); |
|||
}); |
|||
}); |
}); |
||
第26行: | 第28行: | ||
mw.hook('wikipage.content').add( function($content) { |
mw.hook('wikipage.content').add( function($content) { |
||
const action = mw.config.get('wgAction'); |
|||
if (mw.config.get( 'wgNamespaceNumber' ) == 10 && ['view', 'submit'].includes( action )) { |
|||
$content.find( '.mw-highlight > pre' ).last().html(function() { |
|||
const ele = $(this); |
|||
if (ele.text().startsWith( '-->' ) && ele.text().endsWith( '<!--' )) { |
|||
const text = ele.html(), |
|||
i = text.lastIndexOf( '<!--' ); |
|||
return (text.slice(0, i) + text.slice(i + 7)).replace(/-->/, ''); |
|||
} |
|||
if (ele.text().startsWith( '<noinclude>' ) && ele.text().endsWith( '</noinclude>' )) { |
|||
ele.children( '.nt:first-of-type, .nt:last-of-type, .p:first-of-type, .p:last-of-type' ).remove(); |
|||
const text = ele.html(), |
|||
i = text.lastIndexOf( '<' ); |
|||
return (text.slice(0, i) + text.slice(i + 4)).replace(/>/, ''); |
|||
} |
|||
return ele.html(); |
|||
}); |
|||
} |
|||
if(['edit', 'submit'].includes( action ) && |
|||
!mw.config.get('wgIsProbablyEditable') && |
!mw.config.get('wgIsProbablyEditable') && |
||
$('.editRequest').length == 1) { |
$('.editRequest').length == 1) { |
||
第59行: | 第80行: | ||
action: "continue", |
action: "continue", |
||
label: "我知道了", |
label: "我知道了", |
||
flags: "destructive" |
flags: ["primary", "destructive"] |
||
}, { |
}, { |
||
action: "jump", |
action: "jump", |
||
label: "前往LLWiki", |
label: "前往LLWiki", |
||
flags: "progressive", |
flags: ["primary", "progressive"], |
||
href: top === window ? "https://llwiki.org" : location.href, |
href: top === window ? "https://llwiki.org" : location.href, |
||
target: "_blank" |
target: "_blank" |
2020年12月15日 (二) 08:32的版本
"use strict"; /*global mw, $, OO, wgULS*/ // Unslashifier by [[wikipedia:User:Majavah]] const pagename = mw.config.get('wgPageName'); if (pagename.endsWith('/')) { const url = '/zh/' + pagename.slice(0, -1); window.location.href = url; } mw.hook( 'wikipage.categories' ).add(function($content) { $content.find('a').filter(function() { return /(Μ's|Lily white)/.test( this.textContent ); }) .each(function() { $(this).text( this.textContent.replace("Μ's", "μ's").replace('Lily white', 'lily white') ); }); }); if (['edit', 'submit'].includes( mw.config.get('wgAction') ) && mw.config.get('wgIsProbablyEditable')) { $('body').on('click', 'span.mw-charinsert-item', function(e) { $('#wpTextbox1').textSelection( 'encapsulateSelection', { pre: $(this).data('mw-charinsert-start') || $(this).data('start'), peri: '', post: $(this).data('mw-charinsert-end') || $(this).data('end') } ); }); } mw.hook('wikipage.content').add( function($content) { const action = mw.config.get('wgAction'); if (mw.config.get( 'wgNamespaceNumber' ) == 10 && ['view', 'submit'].includes( action )) { $content.find( '.mw-highlight > pre' ).last().html(function() { const ele = $(this); if (ele.text().startsWith( '-->' ) && ele.text().endsWith( '<!--' )) { const text = ele.html(), i = text.lastIndexOf( '<!--' ); return (text.slice(0, i) + text.slice(i + 7)).replace(/-->/, ''); } if (ele.text().startsWith( '<noinclude>' ) && ele.text().endsWith( '</noinclude>' )) { ele.children( '.nt:first-of-type, .nt:last-of-type, .p:first-of-type, .p:last-of-type' ).remove(); const text = ele.html(), i = text.lastIndexOf( '<' ); return (text.slice(0, i) + text.slice(i + 4)).replace(/>/, ''); } return ele.html(); }); } if(['edit', 'submit'].includes( action ) && !mw.config.get('wgIsProbablyEditable') && $('.editRequest').length == 1) { var ele = $('.editRequest > a'), href = new mw.Uri(ele.attr('href')), date = new Date(); href.query.preloadtitle = '编辑请求' + ' - ' + mw.config.get('wgUserName') + ' (' + date.getFullYear() + '-' + date.getMonth() + '-' + date.getDate() + ')'; ele.attr('href', href.toString()); } /* 沙盒顶部 */ var uri = new mw.Uri(); if( ['LLWiki:沙盒', 'Template:Sandbox'].includes(pagename) && mw.config.get('wgAction') == 'view' && !(uri.query.diff || uri.query.oldid) ) { var sandboxTop = $('<div>'); sandboxTop.load('/zh?title=LLWiki:沙盒/顶部&variant=' + mw.config.get('wgUserVariant') + ' #mw-content-text table', function() { $content.prepend(sandboxTop.children()); }); } // 引自[[moegirl:mediawiki:common.js]] if (top !== window || location.host !== 'llwiki.org') { var messageDialog = new OO.ui.MessageDialog(), windowManager = new OO.ui.WindowManager(); $("body").append(windowManager.$element); windowManager.addWindows([messageDialog]); messageDialog.title.$label.html('<p>LLWiki提醒您</p><p>您正在非LLWiki域名' + wgULS('访问', '訪問') + '</p>'); messageDialog.message.$label.html('<p>' + wgULS('请注意不要在此域名下输入您的用户名或密码', '請注意不要在此域名下輸入您的用戶名或密碼') + ',以策安全!</p><p>LLWiki' + wgULS('域名为 ', '域名為') + ' llwiki.org</p>'); windowManager.openWindow(messageDialog, { actions: [{ action: "continue", label: "我知道了", flags: ["primary", "destructive"] }, { action: "jump", label: "前往LLWiki", flags: ["primary", "progressive"], href: top === window ? "https://llwiki.org" : location.href, target: "_blank" }] }); var timer = setInterval(function() { if($('.oo-ui-windowManager .oo-ui-buttonElement-button').length) { clearInterval(timer); $('.oo-ui-windowManager .oo-ui-buttonElement-button').each(function() { if(this.href) { $(this).off('click'); } }); } }, 100); } });