跳转到内容
主菜单
主菜单
移至侧栏
隐藏
导航
首页
最近更改
随机页面
MediaWiki帮助
槌基百科
搜索
搜索
外观
登录
个人工具
登录
查看“︁MediaWiki:Gadget-ViewerMode.js”︁的源代码
系统消息
讨论
English
阅读
查看源代码
查看历史
工具
工具
移至侧栏
隐藏
操作
阅读
查看源代码
查看历史
常规
链入页面
相关更改
特殊页面
页面信息
外观
移至侧栏
隐藏
←
MediaWiki:Gadget-ViewerMode.js
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于这些用户组的用户执行:
Superadmin
、editor
此页面为本wiki上的软件提供界面文本,并受到保护以防止滥用。如欲修改所有wiki的翻译,请访问
translatewiki.net
上的MediaWiki本地化项目。
您无权编辑此JavaScript页面,因为编辑此页面可能会影响所有访问者。
您可以查看和复制此页面的源代码。
/** * ViewerMode gadget — reader/editor toggle pill in the site header. * Also fixes the missing icon on the "My blog" menu item. */ ( function () { 'use strict'; if ( mw.user.isAnon() ) { return; } var STORAGE_KEY = 'mw-viewer-mode'; var active = localStorage.getItem( STORAGE_KEY ) === '1'; /* Apply class immediately on load (before DOM ready) to avoid flicker */ if ( active ) { document.documentElement.classList.add( 'viewer-mode' ); } function toggle() { active = !active; localStorage.setItem( STORAGE_KEY, active ? '1' : '0' ); document.documentElement.classList.toggle( 'viewer-mode', active ); updateBtn(); } /* Label logic: * viewer mode OFF → button says "阅读视图" (click to enter reader view) * viewer mode ON → button says "编辑视图" (click to return to editor view) */ function updateBtn() { var btn = document.getElementById( 'vm-toggle' ); if ( !btn ) { return; } if ( active ) { btn.textContent = '✏️ 编辑视图'; btn.title = '切换回编辑视图'; btn.classList.add( 'vm-active' ); } else { btn.textContent = '📖 阅读视图'; btn.title = '切换至阅读视图(隐藏编辑工具)'; btn.classList.remove( 'vm-active' ); } } $( function () { /* ── Fix missing icon on "My blog" ─────────────────────── */ var blogLink = document.querySelector( '#pt-simpleblog_myblog a' ); if ( blogLink && !blogLink.querySelector( '.vector-icon' ) ) { var blogIcon = document.createElement( 'span' ); blogIcon.className = 'vector-icon mw-ui-icon-article mw-ui-icon-wikimedia-article'; blogLink.insertBefore( blogIcon, blogLink.firstChild ); } /* ── Build toggle pill ──────────────────────────────────── */ var btn = document.createElement( 'button' ); btn.id = 'vm-toggle'; btn.className = 'vm-toggle'; btn.addEventListener( 'click', toggle ); updateBtn(); /* Inject into .vector-user-links-main, before the dropdown */ var target = document.querySelector( '.vector-user-links-main' ) || document.querySelector( '.vector-user-links' ); if ( target ) { target.insertBefore( btn, target.firstChild ); } } ); }() );
返回
MediaWiki:Gadget-ViewerMode.js
。