Jump to content

Wikipedia:User scripts/Requests/Archive 5

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Lowercase sigmabot III (talk | contribs) at 06:17, 6 March 2021 (Archiving 1 discussion(s) from Wikipedia:User scripts/Requests) (bot). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Archive 1Archive 3Archive 4Archive 5Archive 6Archive 7Archive 9

Eswatini vs. Swaziland sortkeys

Hello!

The country of Swaziland changed its name to Eswatini in 2018. Nearly all Wikipedia articles and categories that needed renaming have been moved to the new name, see e.g. Wikipedia:Categories for discussion/Log/2018 November 5 § Swaziland.

However, I noticed that this renaming may have left sortkeys that need correction. E.g. I found Category:Wealth in Eswatini in Category:Wealth by country and Category:Wealth in Africa with sortkey Swaziland, which left Eswatini in sequence between Sri Lanka and Sweden. I corrected them manually to Eswatini.

Is there a way to find all such sortkeys and have them corrected by a bot? That's how I would do it:

  • Look for every article or category that has Eswatini as part of its name
  • Look for category sortkey (found by [[Category:<whatever>|<sortkey>]], sometimes small-case category) or defaultsort ({{DEFAULTSORT:<sortkey>}}):
    • If exactly Swaziland or a prefix (such as Sw or Swaz, except just the letter S), replace by Eswatini exactly
    • If a longer sortkey includes Swaziland, not necessarily in the beginning (such as Swaziland, Economy of or Economy of Swaziland)
    • For sortkeys that are exactly the letter S (and we know that such sortkeys are found quite often), create a list of such occurrences for later manual treatment.

I think it's pretty safe to replace all the cases I have listed because we limit ourselves to titles that have been renamed to a name explicitly including Eswatini, so we would not affect content such as Category:Treaties extended to Swaziland (protectorate), for which Eswatini is anachronical, or Times of Swaziland, which is a proper noun. I think other namespaces (such as Template:) may be better left out for manual action.

Is there any bot master able to fulfill this request? Place Clichy (talk) 10:32, 29 May 2020 (UTC)

Place Clichy, I made a little script to do them, they should all be fixed now. BrandonXLF (talk) 06:49, 3 June 2020 (UTC)
@BrandonXLF: thanks, this looks very good! Were you by any chance able to look up partial prefix matches (such as |Swazi), even just to build a list that I could manually take care of later? Place Clichy (talk) 08:26, 3 June 2020 (UTC)
@BrandonXLF: Do you see any reason why e.g. Category:Immigrants to Eswatini was missed? Place Clichy (talk) 00:56, 14 June 2020 (UTC)
Place Clichy, because it's a category, I didn't have the namespace selected to search, my bad. There seems to be at least 382 categories that need fixing, see [1] and [2]. BrandonXLF (talk) 02:48, 14 June 2020 (UTC)

Introduction helper

Following up on discussion with Sdkb for a sandbox option. Currently they are using a link such as this one. I'm looking at ditching the random number part - but would want the button to have a link with a script (from ?withJS=) that will:

  1. Wait for the page to load in editing mode
  2. Clear the entire editing box
  3. Populate the editing box with some text (a template subst)
  4. Add an edit summary
  5. Possibly submit the edit as well; understand that the script would need to be in mediawiki ns. Example of another button that include a script: Wikipedia:Dispute resolution noticeboard/request.

xaosflux Talk 16:19, 27 June 2020 (UTC)

Should be doable - will work on this in the next few days if no one beats me to it DannyS712 (talk) 21:02, 27 June 2020 (UTC)
So I took a crack at it, and the existence of codemirror and wikieditor make it a lot harder than I thought, sorry DannyS712 (talk) 06:15, 28 June 2020 (UTC)
@DannyS712: will ditching the publish/submit help? Would be fine to have a dif script for vedit/srcedit. — xaosflux Talk 12:32, 28 June 2020 (UTC)
The issue is trying to select and manipulate the content of the textbox - preload only works for new pages / new sections, unfortunately. That being said, if it would always be a specific page I have an idea - can you provide an example page and the content that should be on it? DannyS712 (talk) 12:36, 28 June 2020 (UTC)
@DannyS712: the destination would be fixed, and so would the content - so "preload" can be ditched. Preferably the page could be specified with a link, to be an arbitrary page, so to make the requirements a bit simpler:
  1. Be able to follow a edit or vedit links such as these:
    1. 1
    2. 2
  2. After the page loads, in the respective edit mode:
    1. Clear the entire page
    2. Drop some static text (hard coded in script) in to the edit summary
    3. Drop some static text (hard coded in script) in to the editor
  3. Optional if needed: For the visual editor mode, if it has to start in traditional editor, do the work, then use JS to switch to vedit that could be OK.
xaosflux Talk 15:31, 28 June 2020 (UTC)
I meant can you link to a specific revision with the text you want? Because then you can have the user edit that permalink, and the text will already be set DannyS712 (talk) 15:34, 28 June 2020 (UTC)
Hmm, that may work too - scriptless at least. — xaosflux Talk 16:18, 28 June 2020 (UTC)
@Sdkb: going on that, if you just want an "empty" sandbox - or even one with some content that can be edited, would revision edit links solve your use case as well? example source edit link that could be used. — xaosflux Talk 16:20, 28 June 2020 (UTC)