User:魔琴/sandbox/Quick102.js

// Uses scripts from en:Wikipedia:User_scripts/Guide, en:User:Evad37/MoveToDraft.js and zh:User:Hamish/massmove.js // v1.0.0-alpha //

$('#bodyContent').prepend(' outside test text '); $(document).ready( function {	var API = new mw.Api;	function ShowQuick102 {		if ( mw.config.get( 'wgNamespaceNumber' ) === 2 && /autoconfirmed/.test( mw.config.get('wgUserGroups')) ){  //仅在用户命名空间适用，仅对自动确认用户显示 	        var link = mw.util.addPortletLink( 'p-cactions', '#', '快速102', 'ca-quick102', '快速发布草稿'); 	        $( link ).click( function ( event ) { event.preventDefault; var userpage= mw.config.get( 'wgPageName' ); var articlepage= userpage.replace(/^.*\//, ""); MovePage(userpage,articlepage); if (/sysop|patroller|rollbacker/.test(mw.config.get('wgUserGroups'))) { TagO1(userpage); }				window.location.reload; } );	    }	}	// 移动页面	function MovePage(userpage,articlepage) {		var logpage_wikitext = '';		API.postWithToken( 'csrf', { action: 'move', from: userpage, to: articlepage, movetalk: 1, noredirect: 1, reason: "使用快速102发布新条目" } );	}	// 加入O1	function TagO1(userpage) {		API.postWithToken( 'csrf', { action: 'edit', title: userpage, prependtext: '{'+'{d|O1}}\n', summary: '条目已发布至主命名空间，请求快速删除（CSD O1）' } );	}	mw.loader.using( 'mediawiki.util', function { // Wait for the page to be parsed $( document ).ready( function { 	    	ShowQuick102;	    } ); } ); } );

//