LLWiki正在建设中,欢迎加入我们!
“User:Bhsd/minerva.js”的版本间差异
跳转到导航
跳转到搜索
小 标签:移动版网页编辑 移动版编辑 |
小 标签:移动版网页编辑 移动版编辑 |
||
第44行: | 第44行: | ||
/* 移动版历史添加与当前对比链接 */ |
/* 移动版历史添加与当前对比链接 */ |
||
$(function() { |
$(function() { |
||
const lastrevid = mw.util.getParamValue( 'offset' ) ? 'cur' : parseInt( $('.page-summary > a').first().attr( 'href' ).match(/\d+$/) ); |
|||
$('.list-thumb').append(function() { |
$('.list-thumb').append(function() { |
||
const oldid = parseInt( $(this).parent().attr( 'href' ).match( /\d+$/ ) ); |
const oldid = parseInt( $(this).parent().attr( 'href' ).match( /\d+$/ ) ); |
||
return $('<p>').append( $('<a>', {text: "当前", |
return oldid == lastrevid ? null : $('<p>').append( $('<a>', {text: "当前", |
||
href: '/zh/special:diff/' + oldid + '/ |
href: '/zh/special:diff/' + oldid + '/' + lastrevid}) ); |
||
}); |
}); |
||
}); |
}); |
2021年6月24日 (四) 01:05的版本
//<nowiki> // 拆分自[[Special:Mypage/common.js]],不可使用ES6语法 "use strict"; mw.loader.using( 'jquery.client' ).then(function() { if ($.client.profile().name == 'firefox') { mw.gadgets = $.extend(mw.gadgets, {stickyHeading: {mode: 'desktop'}}); mw.hook( 'wikipage.content' ).add(function($content) { console.log('Hook: wikipage.content, Firefox开始移除黏性章节标题'); $content.removeClass( 'stickyHeading' ); }); } }); // 直接进入讨论页 $(function() { $('.talk').off( 'click' ).click(function(e) { e.stopImmediatePropagation(); }); }); if (mw.config.get( 'wgArticleId' ) == 1521) { mw.loader.using( ['oojs-ui-core', 'ext.gadget.site-lib'] ).then(function() { mw.tipsy( $('#bodyContent'), '.myTable td[data-sort-value]', {id: 'myTipsy'} ); }); } mw.loader.using( 'mediawiki.util' ).then(function() { const nsid = mw.config.get( 'wgNamespaceNumber' ), specialPage = mw.config.get( 'wgCanonicalSpecialPageName' ), pageName = mw.util.wikiUrlencode( mw.config.get( 'wgPageName' ) ), title = mw.util.wikiUrlencode( mw.config.get('wgTitle') ), script = mw.config.get('wgScript'), loadJs = function(page) { mw.loader.load(script + '?action=raw&ctype=text/javascript&title=' + page); }; if (mw.config.get( 'wgArticleId' ) > 0 && mw.config.get('wgAction') == 'view') { // 移动版强制章节折叠 loadJs( 'user:bhsd/mobileCollapse.js' ); } else if (specialPage == 'Recentchanges') { // 移除多余的符号和空白字符 mw.hook( 'wikipage.content' ).add(function($content) { console.log('Hook: wikipage.content,开始移除多余字符'); $content.find( '.mw-changeslist-line-inner' ).contents().filter(function() { return this.nodeType == 3; }) .remove(); }); } else if (specialPage == "History") { /* 移动版历史添加与当前对比链接 */ $(function() { const lastrevid = mw.util.getParamValue( 'offset' ) ? 'cur' : parseInt( $('.page-summary > a').first().attr( 'href' ).match(/\d+$/) ); $('.list-thumb').append(function() { const oldid = parseInt( $(this).parent().attr( 'href' ).match( /\d+$/ ) ); return oldid == lastrevid ? null : $('<p>').append( $('<a>', {text: "当前", href: '/zh/special:diff/' + oldid + '/' + lastrevid}) ); }); }); } /* 自定义移动版导航 */ mw.hook( 'mobile.menu' ).add(function($menu) { console.log('Hook: mobile.menu,开始添加自定义导航项目'); $menu.find( '.mw-ui-icon-minerva-contributions' ).parent() .after( $('<li>').append( $('<a>', {html: '<i class="fa fa-folder-open"></i><span>子页面</span>', href: script + '?title=Special:前缀索引&prefix=' + title + '/&namespace=' + nsid + '&stripprefix=1' }) ) ).after( $('<li>').append( $('<a>', {html: '<i class="fa fa-hourglass-half"></i><span>展开模板</span>', href: script + '?title=Special:展开模板&wpRemoveComments=1&wpGenerateRawHtml=true&wpInput={{:' + pageName + '}}' }) ) ).after( $('<li>').append( $('<a>', {html: '<i class="fa fa-copy"></i><span>所有页面</span>', href: script + '?title=Special:所有页面&namespace=' + nsid }) ) ).after( $('<li>').append( $('<a>', {href: script + '/Special:替换文本', html: '<i class="fa fa-retweet"></i><span>替换文本</span>' }) ) ).after( $('<li>').append( $('<a>', {href: script + '/Special:滥用过滤器', html: '<i class="fa fa-ban"></i><span>滥用过滤器</span>' }) ) ).after( $('<li>').append( $('<a>', {href: script + '?target=http://*&title=Special:链接搜索', html: '<i class="fas fa-external-link-alt"></i><span>链接搜索</span>' }) ) ).after( $('<li>').append( $('<a>', {html: '<i class="fa fa-users"></i><span>用户列表</span>', href: script + '?title=Special:用户列表&creationSort=1&desc=1' }) ) ).after( $('<li>').append( $('<a>', {href: script + '/Special:版本', html: '<i class="fa fa-puzzle-piece"></i><span>版本</span>'}) ) ); }); }); //</nowiki>