imported>SD hehua |
imported>一个人的孤独 |
第1行: |
第1行: |
| 请求创建小工具页面,内容如下:
| | <includeonly>=</includeonly><noinclude>{{萌百:=}}</noinclude> |
| <pre class="hljs"> | |
| //<nowiki>
| |
| /**
| |
| * @Source: https://llwiki.org/zh/mediawiki:gadget-mobileEdit.js
| |
| * @Author: [[User:Bhsd]]
| |
| * @Dependencies: ext.gadget.site-lib, mediawiki.util, oojs-ui-windows, user.options
| |
| */
| |
| "use strict";
| |
| const script = mw.config.get( 'wgScript' ),
| |
| pagename = mw.util.wikiUrlencode( mw.config.get( 'wgPageName' ) ),
| |
| id = mw.config.get( 'wgRevisionId' ),
| |
| action = mw.config.get('wgAction'),
| |
| contentModel = mw.config.get( 'wgPageContentModel' );
| |
| | |
| $('body').on('click', 'a.new, .mw-mf-diff-info__link-latest > a', function() {
| |
| $(this).attr('href', function(i, val) { return val.replace('&action=edit', '&action=submit'); });
| |
| });
| |
| | |
| $(function() {
| |
| if (action == 'view' || mw.config.get( 'wgNamespaceNumber') >= 0) {
| |
| $( 'a.edit-page' ).filter(function() { return /^T-/.test( $(this).data('section') ); }).remove();
| |
| $( 'a.edit-page' ).off( 'click' ).on('click', function(e) {
| |
| e.stopImmediatePropagation();
| |
| const self = $(this),
| |
| section = self.data('section'),
| |
| param = section ? '§ion=' + section : '';
| |
| location.href = script + '?action=submit&title=' + pagename + '&oldid=' + id + param;
| |
| }).removeAttr('href');
| |
| }
| |
| | |
| if (["edit", "submit"].includes( action )) {
| |
| const warning = mw.user.options.get( 'useeditwarning' ),
| |
| id = mw.util.getParamValue( 'oldid' ),
| |
| cid = mw.config.get( 'wgCurRevisionId' ),
| |
| href = script + (id && id < cid ? '?oldid=' + id : '/' + pagename),
| |
| cancelBtn = new OO.ui.ButtonWidget( {label: wgULS("取消编辑", "取消編輯"),
| |
| flags: ['primary', 'destructive'], href: href} );
| |
| cancelBtn.$element.appendTo( '.editButtons' );
| |
| if (warning) {
| |
| cancelBtn.$element.on('click', 'a', function(e) {
| |
| e.preventDefault();
| |
| OO.ui.confirm( wgULS("您要放弃这次更改吗?", "您要放棄這次更改嗎?"), {actions: [{label: "取消"},
| |
| {label: wgULS("确定", "確認"), flags: ['primary', 'destructive'], action: 'accept'}]} )
| |
| .then(function(confirm) {
| |
| if (confirm) { location.href = href; }
| |
| });
| |
| });
| |
| }
| |
| }
| |
| });
| |
| //</nowiki>
| |
| </pre>
| |
| 使用这个小工具需要在[[mediawiki:gadgets-definition]]添加
| |
| <pre>* mobileEdit[ResourceLoader|dependencies=ext.gadget.site-lib,mediawiki.util,oojs-ui-windows,user.options|rights=edit|targets=mobile]|mobileEdit.js</pre>
| |
| 如果导入后不可用,请再与我联系。谢谢![[用户:Bhsd|Bhsd]]([[用户讨论:Bhsd|讨论]]) 2021年5月7日 (五) 23:41 (CST)<br/>
| |
| {{@|1==海豚=}}请来看看-- [[:zhmoe: 萌 娘 百 科: 巡查姬|<span style="color:orange">Patroller</span>]][[用户:SD hehua|SD hehua]]([[用户讨论:SD hehua|聊天室]]) 2021年5月8日 (六) 18:40 (CST) | |