User:PhiLiP/tongwen.js
外观
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
// 禁用同文堂
// Author & Maintainer: [[User:PhiLiP]]
if ( $.inArray( wgAction, ['edit', 'submit'] ) > -1 ) {
$( function() {
function tongwen() {
// this is where the magic happens, detect the tag attr
// and we'll know if the user enabled Tongwentang.
if ( $('html[zhtongwen]:first').length ) {
if ( !$( '#no-tongwen' ).length ) {
var notongwen = $('<div id="no-tongwen"></div>' )
.text( wgUVS(
'请关闭同文堂的自动转换功能,否则它将污染你编辑维基百科页面时的源码。',
'請關閉同文堂的自動轉換功能,否則它將污染你編輯維基百科頁面時的源碼。' ) )
.css( {
background: 'none repeat scroll 0 0 #CC0000',
color: 'white',
fontSize: '1em',
fontWeight: 'bold',
lineHeight: '2em',
margin: '10px auto',
textAlign: 'center',
width: '60%',
padding: '0 10px',
borderRadius: '8px',
MozBorderRadius: '8px',
WebkitBorderRadius : '8px',
KhtmlBorderRadius : '8px'
} )
.append( $( '<a></a>' )
.css( {
color: '#C9C9C9',
display: 'inline-block',
padding: '0 8px'
} )
.attr( 'href', location.search )
.text( wgUVS( '重载页面', '重載頁面' ) ) )
.append( $( '<a></a>' )
.css( {
color: '#C9C9C9',
display: 'inline-block',
padding: '0 8px'
} )
.attr( 'href', '#' )
.text( wgUVS( '强制提交', '強制提交' ) )
.click( function() {
$( '#editform' ).unbind( 'submit.tongwen' ).submit( function() {
var textarea = $( '#wpTextbox1' );
textarea.val( textarea.val() + '<!--tag:tongwentang-->' );
} ).submit();
} ) );
$( '#editform' ).before( notongwen );
}
location.hash = '#no-tongwen';
return true;
} else {
return false;
}
}
$( '#editform' ).bind( 'submit.tongwen', function( event ) {
if ( tongwen() ) {
event.preventDefault();
}
} );
tongwen();
} );
}