User:Euphoria/common.js: Difference between revisions
From Test Wiki
Content deleted Content added
fix |
fix |
||
| Line 3: | Line 3: | ||
const pagePrefix = 'User:Euphoria/TestVfD/'; |
const pagePrefix = 'User:Euphoria/TestVfD/'; |
||
if (mw.config.get('wgPageName').startsWith(pagePrefix)) { |
if (mw.config.get('wgPageName').startsWith(pagePrefix) && mw.config.get('wgAction') === 'view') { |
||
// |
// Wait until DOM is fully loaded |
||
document.addEventListener('DOMContentLoaded', function () { |
|||
| ⚫ | |||
// Find all section headings (h2) |
|||
| ⚫ | |||
const sectionName = headline.textContent.trim(); |
const sectionName = headline.textContent.trim(); |
||
| ⚫ | |||
| ⚫ | |||
// Only add buttons to sections that match your criteria (optional) |
|||
container.style.marginLeft = '10px'; |
|||
['delete', 'keep', 'no consensus'].forEach(function (action) { |
|||
| ⚫ | |||
const |
const btn = document.createElement('a'); |
||
btn.href = '#'; |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
const topText = '{{subst:vt|' + action + '. --~~~~}}\n==' + sectionName + '==\n'; |
|||
| ⚫ | |||
const bottomText = '\n{{subst:vb}}'; |
|||
const |
const summary = 'Closed section "' + sectionName + '" as ' + action; |
||
btn.href = '#'; |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
localStorage.setItem('vfdPrefillContent', JSON.stringify({ top: topText, bottom: bottomText })); |
|||
localStorage.setItem('vfdPrefillSummary', summary); |
|||
const summary = 'Closed section "' + sectionName + '" as ' + action; |
|||
window.location.href = mw.util.getUrl(mw.config.get('wgPageName'), { action: 'edit' }); |
|||
| ⚫ | |||
window.location.href = mw.util.getUrl(mw.config.get('wgPageName'), { action: 'edit' }); |
|||
| ⚫ | |||
container.appendChild(btn); |
|||
}); |
}); |
||
| ⚫ | |||
| ⚫ | |||
headline.parentNode.appendChild(container); |
|||
headline.parentNode.appendChild(container); |
|||
| ⚫ | |||
}); |
}); |
||
| ⚫ | |||
| ⚫ | |||
// Edit page prefill (same as before) |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
if (textbox) { |
|||
| ⚫ | |||
| ⚫ | |||
// Edit page prefill (unchanged) |
|||
| ⚫ | |||
const { top, bottom } = JSON.parse(stored); |
|||
const textbox = document.getElementById('wpTextbox1'); |
|||
| ⚫ | |||
| ⚫ | |||
if (textbox) { |
|||
const stored = localStorage.getItem('vfdPrefillContent'); |
|||
| ⚫ | |||
} |
|||
if (stored) { |
|||
const { top, bottom } = JSON.parse(stored); |
|||
const content = textbox.value.replace(/^\s+/, '').replace(/\s+$/, ''); |
|||
| ⚫ | |||
if (summaryBox && storedSummary) { |
|||
| ⚫ | |||
} |
} |
||
| ⚫ | |||
| ⚫ | |||
} |
} |
||
} |
} |
||
} |
} |
||
}); |
}); |
||
//</nowiki> |
//</nowiki> |
||