User:Zestwiki/eht.js
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
if (typeof(unsafeWindow) != 'undefined')
{
addPortletLink = unsafeWindow.addPortletLink;
collapseTable = unsafeWindow.collapseTable;
expandHiddenTemplates = expandHiddenTemplates;
toggleNavigationBar = unsafeWindow.toggleNavigationBar;
wgAction = unsafeWindow.wgAction;
}
if (typeof(expandHiddenTemplates) == 'undefined')
expandHiddenTemplates = {};
expandHiddenTemplatesMain = function()
{
var nodeText = document.getElementById('t-expand-hidden-templates').firstChild.firstChild.firstChild;
if (nodeText.nodeValue == 'Expand templates')
var action = 'expanding';
else
var action = 'collapsing';
// .collapseButton
var buttons = document.getElementsByClassName('collapseButton');
for (var i = 0; i < buttons.length; i++)
{
if (
(action == 'expanding' && buttons[i].childNodes[1].firstChild.nodeValue == 'show')
|| (action == 'collapsing' && buttons[i].childNodes[1].firstChild.nodeValue == 'hide')
)
buttons[i].childNodes[1].click(); // IE-only?
}
// .NavToggle
var toggles = document.getElementsByClassName('NavToggle');
for (var i = 0; i < toggles.length; i++)
{
if (
(action == 'expanding' && toggles[i].firstChild.nodeValue == '[show]')
|| (action == 'collapsing' && toggles[i].firstChild.nodeValue == '[hide]')
)
toggles[i].click(); // IE-only?
}
if (buttons.length == 0 && toggles.length == 0)
alert('There are no templates to expand on this page.');
else
{
if (action == 'expanding')
nodeText.nodeValue = 'Collapse templates';
else
nodeText.nodeValue = 'Expand templates';
}
}
expandHiddenTemplatesPortletLink = function()
{
if (addPortletLink)
{
if ((wgAction != 'view' && wgAction != 'submit' && wgAction != 'edit' && wgAction != 'purge') || navigator.appName.indexOf('Microsoft Internet Explorer') == -1)
return;
var buttons = document.getElementsByClassName('collapseButton');
var toggles = document.getElementsByClassName('NavToggle');
if (buttons.length + toggles.length == 0)
return;
if (typeof(expandHiddenTemplates) == 'undefined')
expandHiddenTemplates = {};
if (typeof(expandHiddenTemplates.addTab) == 'undefined')
expandHiddenTemplates.addTab = false;
if (typeof(expandHiddenTemplates.addToNavigation) == 'undefined')
expandHiddenTemplates.addToNavigation = false;
if (expandHiddenTemplates.addTab)
mw.util.addPortletLink('p-cactions', 'javascript:expandHiddenTemplatesMain()', 'Expand templates', 't-expand-hidden-templates', 'Expands or hides all collapsible templates');
if (expandHiddenTemplates.addToNavigation)
mw.util.addPortletLink('p-navigation', 'javascript:expandHiddenTemplatesMain()', 'Expand templates', 't-expand-hidden-templates', 'Expands or hides all collapsible templates');
if (!expandHiddenTemplates.addTab && !expandHiddenTemplates.addToNavigation)
mw.util.addPortletLink('p-tb', 'javascript:expandHiddenTemplatesMain()', 'Expand templates', 't-expand-hidden-templates', 'Expands or hides all collapsible templates');
}
}
if (typeof(unsafeWindow) == 'undefined')
addOnloadHook(expandHiddenTemplatesPortletLink);
else
expandHiddenTemplatesPortletLink();
if (typeof(unsafeWindow) != 'undefined')
unsafeWindow.expandHiddenTemplatesMain = expandHiddenTemplatesMain;
expandHiddenTemplates = {} ;
expandHiddenTemplates 。addToNavigation = true ;