Post your user script-related request or idea for a new user script (or gadget) as a new section below. Discussion in each section is encouraged. Note that most gadgets started out as mere user scripts. This page is intended for new user scripts, which affect the appearance of the site and may add additional functionality. Fully automated bots should be requested at
Wikipedia:Bot requests instead.
All user script-related requests are welcome, whether they be for assistance writing an existing user script, desire for a new user script that does what you want, etc. Ideas for new user scripts are welcome too!
Before you request a script, please make sure it does not already exist. For a list of user scripts, see
this list.
If you have been helped, please let us know, so that we may archive the request.
This page has archives. Sections older than 250 days may be automatically archived by Lowercase sigmabot III when more than 4 sections are present.
Script to convert numeric ref names created by VE into standard names
Please write a script to alter
numeric ref names created by the
WP:Visual Editor into reasonable reference names, such as Lastname-YYYY. For example, operating on the article
Male gaze, it would change (among others), the reference
<ref name=":62">{{Cite book|last1=Christiansen|first1=Keith|title=Orazio and Artemesia Gentileschi|last2=Mann|first2=Judith|publisher=Metropolitan Museum of Art|year=2001}}</ref>
into
<ref name="Christiansen-2001">. . .</ref>
Two additional options would be very welcome:
a throttle (perhaps, |max=N), in order to keep the total number of changes down to a configurable number per edit; this is because as the number gets higher, diffs become increasingly difficult to read and interpret.
numeric (or named) parameters which could be used to override the automatic use of Lastname-YYYY, for a given numeric refname value. This would be useful, in cases where a named reference doesn't use one of the {{
citation}} templates (such as, ref ":1" at
Male gaze), or where the last name or year is not available (such as ref ":1" at
Charles de Gaulle). In the latter case, including the parameter |1=Election-1958 would result in the code
<ref name=":1">{{cite web |title=Assemblée nationale. . .</ref>
<ref name="Election-1958">{{cite web |title=Assemblée nationale. . .</ref>
regardless if a different name and year were found, or if none were found. However, the basic functionality of just repairing numeric ref names without any other bells and whistles would be very welcome. See
WP:VE/NAMEDREFS for phab tickets about this, and other related info.
Mathglot (
talk) 07:03, 19 December 2022 (UTC)reply
While I can't contribute to this at all, this would be fantastic! I know the VE ref names have been a persistent problem. ThadeusOfNazereth(he/him)Talk to Me! 19:17, 19 December 2022 (UTC)reply
This seems to be working great - I used it on a page w/100+ references and there were zero issues! ThadeusOfNazereth(he/him)Talk to Me! 17:03, 7 February 2023 (UTC)reply
Wow. A very impressive piece of software. Great job Nardog. –
Novem Linguae (
talk) 18:42, 7 February 2023 (UTC)reply
"Wow" is right; truly amazing. Thank you so much for this; it is going to be incredibly useful and helpful, a huge timesaver, and big improvement for the project. It went beyond what I imagined, and worked great at
Male gaze and
Charles de Gaulle. Don't worry about going overboard with options, they are wonderful. That said, I had to stare at the panel a bit to try to understand all the features, and for a couple of things it wasn't entirely clear right away. I've added a section at the script talk page with some
§ Questions/suggestions for you. But if you've had enough for now, don't worry; it's great as is! Thanks again,
Mathglot (
talk) 03:10, 9 February 2023 (UTC)reply
I've been attempting to put a naming protocol in place. I built it into a function in my
Sources script whereby names for bare refs can be generated. Perhaps we could work together to create a coherent set of rules to give names to bare or VE-named ref tags7.-- Ohc revolution of our times 20:50, 23 September 2023 (UTC)reply
Not a gadget, but
Module:Check for unknown parameters is used in thousands of templates. It puts pages in a tracking category when they have unsupported parameters. –
Jonesey95 (
talk) 14:28, 22 July 2023 (UTC)reply
@
GryffindorD: I made a tool that sorts articles by use of template parameters. Among others it lists unknown parameters. I recently expanded it to work on other wikis too. You can access it by visiting
this page. Lmk if you encounter any bugs.
Ivi104 (
talk) 01:52, 22 March 2024 (UTC)reply
Mass patrol new pages by a user
Admins assign editors
autopatrolled based on a
WP:PERM request or because they show up in automated reports. As part of that process, we review their creations as a whole and decide that they don't need to be manually patrolled. It would therefore make sense to be able to mark all their prior unreviewed creations as patrolled, rather than either tediously clicking through them all, or leaving another NPPer to do a now-pointless second review.
It would also be useful for non-admin NPPers for e.g. runs of noncontroversial stubs by the same trusted user.
Alternatively, there could be a tool which patrols all pages in a user's filtered
Special:NewPagesFeed (which can be filtered by user). But I think that could be quite dangerous if you mess up your filters... –
Joe (
talk) 13:58, 12 September 2023 (UTC)reply
I feel like a patch to
User:MusikAnimal/userRightsManager.js to do this automatically when granting autopatrol might be better than creating a new script. If needed, it could be controlled by a checkbox that the user ticks. Pinging @
MusikAnimal –
Novem Linguae (
talk) 14:17, 12 September 2023 (UTC)reply
Sounds like a great idea! I might be able to work on this soon, but by all means if you want to code it @
Novem Linguae then please do (create a fork and I'll help test). While we're at it, maybe it's time we gadgetize userRightsManager and move the code to
https://github.com/wikimedia-gadgets/. Enough people use it that I feel it should be in the community's hands and not solely my own. — MusikAnimaltalk 16:29, 12 September 2023 (UTC)reply
Thanks for the quick reply. Finding time is the tricky part! Will add it to my list of possible future hacking projects. –
Novem Linguae (
talk) 14:24, 13 September 2023 (UTC)reply
See what is adding a category to a page
Is there a way to see what exactly is adding a certain category to a page?
There are cases where you want to remove a category from a page but you quickly understand that it is being added by a template and not a manual category. Problem is that they may be countless of templates in the said page, each with different intricacies and transclusions. Is there a way or a script to see where categories are being added from? -
Klein Muçi (
talk) 12:50, 22 September 2023 (UTC)reply
Special:ExpandTemplates should help you. Doing this accurately would require substing the templates one by one so I doubt there's an efficient way.
Nardog (
talk) 16:25, 22 September 2023 (UTC)reply
Nardog, would your suggestion help in solving
this case if it wasn't solved? :P —
Klein Muçi (
talk) 19:51, 22 September 2023 (UTC)reply
I can't tell because it's been fixed. But if you had pasted the source of the article onto
sq:Special:ExpandTemplates (be sure to fill in the context title) the category would have showed up near the cause of the error.
Nardog (
talk) 05:11, 23 September 2023 (UTC)reply
Nardog, I see. Maybe in the future we can have that as tool that does that all the time for all categories at a click of a button beside them in pages. Assuming other people may encounter it as a problem. For me, this is enough as this is only the second time ever in 10 years I encounter such problem. Thank you!
—
Klein Muçi (
talk) 10:28, 23 September 2023 (UTC)reply
Infobox reformatting
I generally want large templates to have the source "block" formatted – one parameter per line and generally with some whitespace. I often encounter infoboxen that have been created all-in-one-line. Is there, or could there be, a userscript to help with this reformatting? (Also asked at
WP:VPT) —
GhostInTheMachinetalk to me 15:16, 8 November 2023 (UTC)reply
It's a hack, but have you tried editing the lead section of the article in question using the Visual Editor? Add &veaction=edit to the edit page link. If the infobox's TemplateData is correctly set to "block", VE might do the formatting for you. –
Jonesey95 (
talk) 15:55, 8 November 2023 (UTC)reply
It does work, but the process is tedious – change config to use VE, dummy edit in the text of the infobox, reset config, fix the dummy edit, then do what I wanted to do. The script below is so much better —
GhostInTheMachinetalk to me 19:44, 8 November 2023 (UTC)reply
It does!! Thank you! This is the script I was looking for. The script is simply awesome and awesomely simple to use. Sometimes it gets a bit befuddled about a mix of spaces and not-spaces after a bar, but generally a second run solves that —
GhostInTheMachinetalk to me 19:44, 8 November 2023 (UTC)reply
Script for highlighting redirects with possibilities
I'd like a user script that highlights links in articles that go to redirects tagged with {{
R with possibilities}}, indicating that they have been identified as candidates for new articles. Such a script, if adopted widely, might help encourage the creation of such articles (or, if tagged incorrectly, the removal of the possibilities tag).
Given that such articles are technically blue links but in spirit red links, I'd propose a red dashed border, as in Example, as the visual design. But someone more graphically capable than me might be able to come up with something better.
Cheers, {{u|Sdkb}}talk 05:05, 8 December 2023 (UTC)reply
If you use Anomie's
link classifier, you can add custom category-based highlighting very easily. Headbomb {
t ·
c ·
p ·
b} 21:46, 8 December 2023 (UTC)reply
@
Headbomb, thanks for pointing me to that! It looks like it should work, given that (nearly) all redirects with possibilities are in
Category:Redirects with possibilities. But the documentation is unfortunately not good enough for me to figure out how to use it. The hook to adjust the list of categories is I think what I want, but it's not clear what is a core part of the script versus something I need to customize, and I'm not sure where to plug in the <span style="border: 1.5px dashed #d33; padding: 3px;">[[Example]]</span>. Would you be able to help? {{u|Sdkb}}talk 17:31, 9 December 2023 (UTC)reply
As shown in the doc, add something like this in
your common.js before calling importScript():
mw.hook('LinkClassifier').add(function(linkClassifier){linkClassifier.cats'redirect-with-possibilities'='Category:Redirects with possibilities'].sort();});
No need to modify the script itself at all. Then in
your common.css you can add a rule like this to style it:
Would it be possible to create a script that would identify unnecessary piped links and simplify them?
The advice given at
WP:NOPIPE and
MOS:NOPIPE is that piped links are to be avoided when a redirect exists that fits well into the context of the displayed text.
N[[Wolfgang Amadeus Mozart|Mozart]]
Y[[Mozart]]
What I'd like is a script that will scan an article for links of the first type and replace them with links of the second type: that is, where a link of the form [[A|B]] can be replaced with a link of the form [[B]], where [[B]] is a valid pre-existing redirect to [[A]], or where both [[A]] and [[B]] redirect to some other page [[C]].
User:Nardog/Unpipe.js. It's kind of a proof of concept and it might be overeager at replacing links.
Nardog (
talk) 05:00, 2 January 2024 (UTC)reply
Sortkeys in lists
I recently
went through an article that has a list of organizations and added sortkeys so that all the ones with "the" in their name didn't sort alphabetically by T. It wasn't quite a long enough list to be worth composing a RegEx find and replace to do the whole thing automatically, but it strikes me as a common enough situation that it might be helpful to have a script that can do it. {{u|Sdkb}}talk 15:40, 12 January 2024 (UTC)reply
Could you provide the RegEx? That’s sort of what
Wikipedia:AutoEd does: regex find and replaces. We could write an AutoEd module with it.
Aaron Liu (
talk) 17:01, 12 January 2024 (UTC)reply
The RegEx query for the find part would be something like \| The \[\[(\w*), and the replace part would be something like \| data-sort-value="$1" \| The \[\[$1. There would be another find-and-replace for instances in which the the is within the link: \| \[\[The (\w*) → \| data-sort-value="$1" \| \[\[The $1. Cheers, {{u|Sdkb}}talk 23:42, 12 January 2024 (UTC)reply
@
SdkbUser:Aaron Liu/SortKeyDeThe.js now does this, though it won't do things if the relevant entry isn't at the start of its line to eliminate some false positives.Also, I seem to have misread you, sorry. I thought you said that you already had a regex :p
Aaron Liu (
talk) 02:52, 14 January 2024 (UTC)reply
Maybe a data-sort-type="..." could be created for this form of alphabetical sorting? See:
Hello, I was suggested by @
Tamzin on the discord to post this here, basically the inverse to
User:Edward/Find_link, where instead of finding pages that could be linked to a given page, it instead finds pages that could be linked with the current text on the article. There are two different methods i can think of achieving this, either by basically making a permutation set/concordance of the article's text against title search, or just taking the categories/wikiprojects that a page belongs to and checking the articles titles on those categories/wikiprojects to see if they match text on the given page. there's pros and cons to both methods and the best would be able to implement both and automatically use one method or another given on whatever is considered less expensive computationally, or at least letting the user decide which method they'd like to use for a given search.
Akaibu (
talk) 14:37, 12 February 2024 (UTC)reply
In my opinion, this isn't a very good idea. Linking should be done when something isn't very understandable by most people, which is an easy enough criteria for people to manually do drive-by links.
Aaron Liu (
talk) 22:32, 27 February 2024 (UTC)reply
Increased Watchlist size
I watch many (currently 3,044 articles), meaning the 1,000 changes, 30 day limit can be annoying sometimes. Could there be a script created to allow for an increase? Thanks.
Kew Gardens 613 (
talk) 07:27, 16 February 2024 (UTC)reply
That links does show 2,000 changes if you use the non-JavaScript interface.
Nardog (
talk) 23:54, 27 February 2024 (UTC)reply
Script to show move-protection lock?
I couldn't find anything from a search through the list, and I've tried to engineer one myself but I'm not exactly sure where to start, but essentially I want to display the move-protection lock icon on my side when I view pages with move protection (but no edit protection). The icon itself was removed from displaying on most reader-visible pages since it means nothing to a reader, but I still find myself wanting to quickly be able to glance at the top and see that a page is protected in some way.
EggRoll97(
talk) 20:20, 4 March 2024 (UTC)reply
I've made
User:Aaron Liu/MoveTop.js, though it currently disregards whether the page is protected from editing and adds the padlock regardless, which would display alongside the other padlock.
Aaron Liu (
talk) 03:34, 5 March 2024 (UTC)reply
Would it be possible to create a script that would delink repeated links, as well as one that would be able to find the first mention of a phrase matching the title of a link further in the article, linking that and delinking all subsequent links to that title? ‑‑
Neveselbert (
talk·contribs·email) 20:17, 8 March 2024 (UTC)reply
@
Aaron Liu: yes, I've been using that, it just takes a lot of time, especially in cases where the first mention of a phrase isn't linked but a later one has been. I'd have thought it possible to create a script to make a note of all links duplicated (by virtue of your script), and search the article for all exact matches of linked article titles, linking the first mention, then delinking those subsequent. @
Nardog: do you think this could work? Thanks all, ‑‑
Neveselbert (
talk·contribs·email) 15:10, 9 March 2024 (UTC)reply
It is possible, but I think that'd result in too many false positives. Often a phrase isn't stated exactly the same as the article title, so the actual first mention would be delinked. Just the automatic delinking part would be possible, though it'd be much more complicated if we needed to follow redirects.
Aaron Liu (
talk) 16:08, 9 March 2024 (UTC)reply
Yes, I thought about that, though I know that I would double-check the edit to make sure there were no false positives. I think following a redirect could be considered eventually, but for the moment, I think the script should just focus on exact matches to avoid any of these false positives, so if the phrase matches the title exactly, it's delinked. ‑‑
Neveselbert (
talk·contribs·email) 16:10, 9 March 2024 (UTC)reply
WikiDefcon User Script
I'm requesting a user script that adds a WikiDefcon marker to the top bar for Vector 2022, ideally placed next to the notifications/alerts tabs using
Template:Vandalism information. This would assist greatly in counter-vandalism tasks. Possibly, it could use these images, similar to the relevant topicon. Thanks,NeuropolTalk 15:37, 2 April 2024 (UTC)reply
@
Neuropol: Hi. I'm working on it. Can you please choose a target page for when we click on the icon? Thanks.
JeeputerTalk 16:15, 2 April 2024 (UTC)reply
@
Neuropol: Ok it's done and ready to use:
User:Jeeputer/defconIndicator.js. If you click on the icon, it will update the image used to show the current level of vandalism. the script itself updates the icon every 2 minutes. I can change the interval if it's too fast.
JeeputerTalk 19:30, 2 April 2024 (UTC)reply
Works great. Thank you so much! Thanks,NeuropolTalk 22:17, 2 April 2024 (UTC)reply