MediaWiki:Gadget-removeAccessKeys.js

MediaWiki系统消息页面

注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
  • Opera:Ctrl-F5
jQuery(document).ready(function($) {
    if (mw.config.get('skin') == 'vector') {
        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();
        }
    }
}