Wikipedia:User scripts/Requests/Archive 11
| This is an archive of past discussions on Wikipedia:User scripts/Requests. Do not edit the contents of this page. If you wish to start a new discussion or revive an old one, please do so on the current main page. |
| Archive 5 | ← | Archive 9 | Archive 10 | Archive 11 |
Spam-only account tagging and reporting
I've seen that often while dealing with spam only accounts, I have to tag their pages for CSD G11 with Twinkle and then report them to AIV. It might be nice to have a script that enables you to choose pages created by a certain account to tag with CSD G11, notifies the user of the CSDs and reports them to AIV all at the same time for convenience purposes. I was thinking something like a dropdown menu with options of whether to tag each page created by a user for CSD G11, warn the user and/or report to AIV (like Twinkle) would be pretty useful in such a script. ~deltasock (talk • cont) 12:53, 29 October 2025 (UTC)
- @~deltasock: Is it really necessary to
{{db-spamuser}}/{{db-spam}}all (or even multiple) pages created by an obviously spam-only account if you're reporting them to AIV anyway? The reviewing admin will handle them regardless. — DVRTed (Talk) 12:28, 30 October 2025 (UTC)
Track event dates of new pages
Just wanted to make a request for a script to help out with Wikinews users with these things:
- Specify an event date for a page without having to edit a JSON or table.
- Generate a list of pages with an event date specified and a comment.
- Ability to remove the date tag when no longer needed.
Petarkco (talk) 22:51, 14 October 2025 (UTC)
Move section script for teahouse/refdesk/helpdesk/various noticeboards
It would be cool to have a script that allows one to move a section to the appropriate page, leaving behind a {{moved discussion to}} template and optionally notifying OP on their talkpage that the discussion has been moved.
E.g. I ask something on the helpdesk that can be answered on a refdesk. Polygnotus (talk) 17:11, 12 November 2025 (UTC)
- The person who makes this earns the eternal gratitude of my brother ColinFine. Polygnotus (talk) 17:18, 12 November 2025 (UTC)
- Missed this on my radar because you replied to the thread yourself, but this sounds fun; I'll try coding something to test on the test wiki. — DVRTed (Talk) 17:34, 13 November 2025 (UTC)
- @Polygnotus: is there a "Your thread has been moved" template? — DVRTed (Talk) 19:06, 13 November 2025 (UTC)
- @DVRTed I think what we got is Template:Moved_discussion_to#See_also Polygnotus (talk) 20:11, 13 November 2025 (UTC)
- Ah, in that case: it'll have to be something like this: testwiki:User talk:DVRTed#Discussion moved. — DVRTed (Talk) 21:01, 13 November 2025 (UTC)
- Exactly, looks good. Polygnotus (talk) 22:23, 13 November 2025 (UTC)
- Ah, in that case: it'll have to be something like this: testwiki:User talk:DVRTed#Discussion moved. — DVRTed (Talk) 21:01, 13 November 2025 (UTC)
- @DVRTed I think what we got is Template:Moved_discussion_to#See_also Polygnotus (talk) 20:11, 13 November 2025 (UTC)
- @Polygnotus: is there a "Your thread has been moved" template? — DVRTed (Talk) 19:06, 13 November 2025 (UTC)
- It's a thing now: User:DVRTed/move-talk-section. — DVRTed (Talk) 09:59, 14 November 2025 (UTC)
- @DVRTed Woah! That is very cool! Please add it to Wikipedia:User scripts/List and Wikipedia:Scripts++! Polygnotus (talk) 18:30, 15 November 2025 (UTC)
Script for adding a References section
I have tried to make a script for inserting a References section when editing. But it doesn't work. According to the console log, the text is inserted, but the textarea has no visible changes. Can anyone please explain what is going wrong with the script?
mw.loader.using('mediawiki.util', function () {
mw.hook('wikipage.content').add(function () {
var textarea = document.getElementById('wpTextbox1');
if (!textarea) {
// This isn't an edit page
return;
}
// Don't make the link more than once
if (document.getElementById('pt-insert-refsection')) {
return;
}
// Insert a link in the tool menu
var link = mw.util.addPortletLink(
'p-tb',
'#',
'Insert References',
'pt-insert-refsection',
'Insert a References section at the cursor'
);
// Listen for clicks
link.addEventListener('click', function (e) {
console.log('Link clicked');
e.preventDefault();
var textarea = document.getElementById('wpTextbox1');
if (!textarea) {
console.error("wpTextbox1 not found, can't insert text.");
return;
}
var textToInsert = '\n\n== References ==\n{{Reflist}}\n';
// Fetch the cursor's start and end position
const startPos = textarea.selectionStart;
const endPos = textarea.selectionEnd;
console.log (startPos, endPos);
console.log (textarea.value);
// Make new value for textarea
const textBefore = textarea.value.substring(0, startPos);
const textAfter = textarea.value.substring(endPos, textarea.value.length);
// Set the new value
textarea.value = textBefore + textToInsert + textAfter;
// Move the cursor to the end of the inserted text
const newCursorPos = startPos + textToInsert.length;
textarea.selectionStart = newCursorPos;
textarea.selectionEnd = newCursorPos;
// Set focus
textarea.focus();
});
});
});
Thanks, Dipsacus fullonum (talk) 13:44, 21 November 2025 (UTC)
- @Dipsacus fullonum: You've probably enabled the beta feature "Improved Syntax Highlighting" that hides the #wpTextbox1 textarea and creates its own editable DOM element; see mw:Extension:CodeMirror#JavaScript. A simple fix to make it work both with and without CM would be, starting from line 34:
var textToInsert = '\n\n== References ==\n{{Reflist}}\n';
$(textarea).textSelection("encapsulateSelection", {
pre: textToInsert,
});
// Set focus
textarea.focus();
- Regards, — DVRTed (Talk) 14:45, 21 November 2025 (UTC)
- @DVRTed: Thank you very much. That solved the problem for me. Dipsacus fullonum (talk) 15:04, 21 November 2025 (UTC)