Content deleted Content added
Polygnotus (talk | contribs) No edit summary |
Polygnotus (talk | contribs) m Polygnotus moved page User:Polygnotus/test2.js to User:Polygnotus/Scripts/WikiTypoInterface.js |
||
(9 intermediate revisions by the same user not shown) | |||
Line 1:
(function() {
function removeElements() {
const elementsToRemove = [
'#editpage-specialchars', '#mw-userconfigdangerous', '.editpage-head-copywarn'
elementsToRemove.forEach(selector => {
const element = document.querySelector(selector);
if (element) element.remove();
}
function addCustomCSS() {
style.textContent = `
▲ #mw-page-base, /* Top header */
▲ {
display: none !important;▼
}▼
body {
padding-top: 0 !important;
Line 20 ⟶ 23:
}
#content {
margin-top: 0 !important;
}
#bodyContent {
margin-top: 1em;
▲ }
#custom-top-buttons {
margin-bottom: 15px;
}
#custom-top-buttons .oo-ui-buttonElement {
}
`;
document.head.appendChild(style);
}
function addCustomButtons() {
const buttonContainer = document.createElement('div');
buttonContainer.id = 'custom-top-buttons';
buttonContainer.className = 'editButtons';
const buttons = [
{ text: 'Publish changes', id: 'wpSave', className: 'oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-buttonElement oo-ui-buttonElement-framed oo-ui-labelElement oo-ui-flaggedElement-progressive oo-ui-flaggedElement-primary oo-ui-buttonInputWidget' },
{ text: 'Show preview', id: 'wpPreview', className: 'oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-buttonElement oo-ui-buttonElement-framed oo-ui-labelElement oo-ui-buttonInputWidget' },
{ text: 'Show changes', id: 'wpDiff', className: 'oo-ui-widget oo-ui-widget-enabled oo-ui-inputWidget oo-ui-buttonElement oo-ui-buttonElement-framed oo-ui-labelElement oo-ui-buttonInputWidget' }
];
buttons.forEach(btn => {
const buttonSpan = document.createElement('span');
buttonSpan.className = btn.className;
const button = document.createElement('input');
button.type = 'button';
button.value = btn.text;
button.className = 'oo-ui-inputWidget-input oo-ui-buttonElement-button';
button.addEventListener('click', () => {
document.getElementById(btn.id).click();
});
buttonSpan.appendChild(button);
buttonContainer.appendChild(buttonSpan);
});
const bodyContent = document.getElementById('bodyContent');
const currentAction = mw.config.get('wgAction');
if (['edit', 'submit', 'diff'].includes(currentAction) && bodyContent) {
bodyContent.insertBefore(buttonContainer, bodyContent.firstChild);
}
}
function init() {
removeElements();
addCustomCSS();
addCustomButtons();
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded',
} else {
}
})();
|