跳转到内容

MediaWiki:Gadget-removeAccessKeys.js

维基百科,自由的百科全书
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
// **********************************************************************
// **                 ***WARNING GLOBAL GADGET FILE***                 **
// **             changes to this file affect many users.              **
// **           please discuss on the talk page before editing         **
// **                                                                  **
// **********************************************************************
// Imported from version as of: 2007-04-17T22:22:27
// Deactivating access keys, see [[Wikipedia talk:WikiProject User scripts/Scripts/removeAccessKeys|talk page]]

jQuery( document ).ready( function( $ ) {
 if (mw.config.get('skin') === 'vector' || mw.config.get('skin') === 'vector-2022') {
  var head = document.getElementById('mw-head');
  if(head) removeKeys(head.getElementsByTagName('a'));
  var panel = document.getElementById('mw-panel');
  if(panel) removeKeys(panel.getElementsByTagName('a'));
 } else {
  var columnOne = document.getElementById('column-one');
  if (!columnOne) columnOne = document.getElementById('mw_portlets');
  if (!columnOne) return;
  removeKeys(columnOne.getElementsByTagName('a'));
  var cactions = document.getElementById('p-cactions');
  if(cactions) removeKeys(cactions.getElementsByTagName('a'));
  var personal = document.getElementById('p-personal');
  if(personal) removeKeys(personal.getElementsByTagName('a'));
 }
 removeKeys(document.getElementsByTagName('input'));
 removeKeys(document.getElementsByTagName('label'));
} );

function removeKeys(nodeList){
  var el;
	for (var i = 0; i < nodeList.length; i++) {
		el = nodeList[i];
    if (!el.accessKey) continue;
    if (!window.removeAccessKeys || removeAccessKeys.indexOf(el.accessKey) >= 0) {
      el.accessKey = ''; // el.setAttribute('accessKey', ''); 
      $(el).updateTooltipAccessKeys();
    }
  }
}