User:Euphoria/common.js: Difference between revisions
From Test Wiki
Content deleted Content added
fix |
Cleanup Tag: Blanked |
||
| (56 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
//<nowiki> |
|||
mw.loader.using('mediawiki.util', function () { |
|||
const pagePrefix = 'User:Euphoria/TestVfD/'; |
|||
if (!mw.config.get('wgPageName').startsWith(pagePrefix) || mw.config.get('wgAction') !== 'view') { |
|||
return; |
|||
} |
|||
// Wait until MediaWiki content is ready |
|||
mw.hook('wikipage.content').add(function ($content) { |
|||
$content.find('.mw-headline').each(function () { |
|||
const headline = this; |
|||
const sectionName = headline.textContent.trim(); |
|||
if (!sectionName) return; |
|||
const container = document.createElement('span'); |
|||
container.style.marginLeft = '10px'; |
|||
['delete', 'keep', 'no consensus'].forEach(function (action) { |
|||
const btn = document.createElement('a'); |
|||
btn.href = '#'; |
|||
btn.textContent = action.charAt(0).toUpperCase() + action.slice(1); |
|||
btn.style.marginRight = '5px'; |
|||
btn.style.fontSize = '90%'; |
|||
btn.addEventListener('click', function (e) { |
|||
e.preventDefault(); |
|||
const topText = '{{subst:vt|' + action + '. --~~~~}}\n==' + sectionName + '==\n'; |
|||
const bottomText = '\n{{subst:vb}}'; |
|||
const summary = 'Closed section "' + sectionName + '" as ' + action; |
|||
localStorage.setItem('vfdPrefillContent', JSON.stringify({ top: topText, bottom: bottomText })); |
|||
localStorage.setItem('vfdPrefillSummary', summary); |
|||
window.location.href = mw.util.getUrl(mw.config.get('wgPageName'), { action: 'edit' }); |
|||
}); |
|||
container.appendChild(btn); |
|||
}); |
|||
headline.parentNode.appendChild(container); |
|||
}); |
|||
}); |
|||
}); |
|||
//</nowiki> |
|||