Wikipedia:User scripts/Requests/Archive 9

From Wikipedia, the free encyclopedia
Archive 5 Archive 7 Archive 8 Archive 9

Feedback on user script chatbot

After selecting text, the control panel on the right is used to give instructions. The responses by the AI model are presented in the chat panel on the left.

I wrote a user script called WikiChatbot to assist editors. It can summarize, reformulate, copyedit, and provide suggestions on additional topics, images, and wikilinks as well as assess factual accuracy and bias. It is used by selecting text in an article and then clicking one of the buttons on the right to enquire about the selected text. The chatbot can also be used by typing specific questions about the selected text or the topic in general in the chat panel.

The script uses the AI model GPT 3.5. It requires an API key from OpenAI. New OpenAI accounts can use it freely for the first 3 months with certain limitations. The AI model was not designed to assess or improve encyclopedic articles. Editors should always question its responses and rely on their own judgment and reliable sources instead. For a more detailed description of all these issues and examples of how the script can be used, see the documentation at User:Phlsph7/WikiChatbot.

I was hoping to get some feedback on the script in general and how it may be improved. I'm not sure how difficult it is to follow the instructions so it would be great if someone could try to set up the script, use it, and explain which steps were confusing. My OpenAI account is already older than 3 months so I was not able to verify the claims about the free period and how severe the limitations are. If someone has a younger account or is willing to open a new account to try it, that would be helpful. Other feedback on the idea in general, its problems, new features to implement, or the documentation is also welcome. Phlsph7 (talk) 07:45, 16 July 2023 (UTC)

@Phlsph7: You may want to ask for feedback at WP:VPM because I'm afraid this page isn't very heavily watched. CX Zoom[he/him] (let's talk • {CX}) 08:00, 19 July 2023 (UTC)
Thanks for letting me know. I followed your suggestions, see Wikipedia:Village_pump_(miscellaneous)#Feedback_on_user_script_chatbot. Phlsph7 (talk) 09:08, 19 July 2023 (UTC)

byte filter on contributions page

I found this from 2008 while searching for a script for this: Wikipedia:User scripts/Requests/Archive 2#Watchlist filter for + and - bytes ?

Is there a script to make same thing on Special:Contributions page? Tehonk (talk) 10:03, 22 July 2023 (UTC)

@Tehonk Never felt the need to do/have something like that, but one could use pl:User:Nux/LongTableFilters.js as a base for that.
  • The `prepareTable` would need to be changed (especially `itemProperty` and selector in `init`).
  • `itemToText` is overcomplicated there. It could simply return number of edits there.
I guess I should publish ViewFilter to npm... Somedaytm ;). Nux (talk) 11:01, 22 July 2023 (UTC)

Calculation bot for editors contributions to an article for credits

This came up in a discussion at ITN on the idea of crediting updaters. I'd say top 3 or all above 20% but it might help to first find a broader consensus who is to be credited. Paradise Chronicle (talk) 05:44, 25 July 2023 (UTC)

@Paradise Chronicle: This page is for requesting scripts only. You should try asking in Wikipedia:Bot requests. – MaterialWorks 10:35, 25 July 2023 (UTC)
Uhh, thanks Paradise Chronicle (talk) 10:48, 25 July 2023 (UTC)

PROD review tool

Reviewing proposed deletions comes with a lot of secondary tasks, and it would be great to have a userscript to help automate the process. I am suggesting something like User:Jackmcbarn/editProtectedHelper, where the script activates whenever a page has an active PROD, and provides the reviewer with buttons for the actions they can take, such as seconding the PROD or contesting the PROD.

If you second the PROD, the script should add {{prod 2}} to the page and update the {{old prod}} on the talk page accordingly. If you contest the PROD, it should remove the PROD template from the article, notify the nominator on their Talk page with {{Deprod}}, and again update the {{old prod}} on the talk page accordingly.

It doesn't need to cover the PROD nomination process since that can already be automated through Twinkle. ––FormalDude (talk) 01:16, 3 August 2023 (UTC)

One other small point, contesting should remove {{prod}} and any {{prod 2}} instances (zero or more of these may exist) from the article. ~Kvng (talk) 02:07, 3 August 2023 (UTC)

external css for a user script?

Is that possible?

This question comes from User talk:Trappist the monk/HarvErrors § Color style cannot be overridden in common.css. It is possible to override the styling applied by that script but to do so requires the !important keyword. Is it possible to get a .js to read an external stylesheet?

If yes, how is that done? My .js skills are rudimentary at best so a detailed answer would be much appreciated. Extending this just a bit, would it be possible to use a .css TemplateStyles page so that the .css could be shared by a lua module?

Trappist the monk (talk) 23:21, 20 August 2023 (UTC)

In my less-than-rudimentary js, what if we had two classes on the error message line, with the first class defined in a <style> block inserted onto the page by the script (right before </head>?) and defining the default color, leaving the second class undefined and available for override at common.css, is that doable in js so that an external sheet wouldn't be needed? Mathglot (talk) 00:02, 21 August 2023 (UTC)
You can use mw.loader.load('/w/index.php?title=...&action=raw&ctype=text/css', 'text/css'). But that means loading an extra resource after the script is loaded, so I for one prefer just embedding the CSS within the script with mw.loader.addStyleTag(). Nardog (talk) 02:50, 21 August 2023 (UTC)
Doc pages: mw.loader load method, mw.loader Methods, and mw.loader addStyleTag method. Mathglot (talk) 03:12, 21 August 2023 (UTC)
mw.loader.addStyleTag() was the easier so I did that; see lines 5–8. Seems to work except that to override the default color in user css the !important keyword is still required. Any way around that?
Trappist the monk (talk) 15:18, 21 August 2023 (UTC)
See my message of 00:02: I believe if you change your style tags in the new code to blah_blah_dflt, and change line 32:
mw.loader.addStyleTag ('.ttm_harv_err_dflt {color:DarkOrange}'); // no target error message default color
 . . .
$(elem.parentNode).append(" ", $("<span class=\"ttm_harv_err_dflt ttm_harv_err\">Harv error: link from " + href + " doesn't point to any citation.</span>")); //start with dflt, allow user override
it should work without !important; i.e., this should be sufficient in common.js:
.ttm_harv_err {color:darkseagreen}
Naturally, the other defaults and error lines to be done similarly. Mathglot (talk) 17:35, 21 August 2023 (UTC)
Trying it in html, and didn't work as expected; trying something else... Mathglot (talk) 17:52, 21 August 2023 (UTC)
Ported your script to User:Mathglot/HarvErrors.js and tried a couple of things there; failed in the same way (that is, it doesn't work without !important, but your original version already did that). Still thinking, but so far at least, I don't see a way to work around the style priority cascade *without* !important. Mathglot (talk) 22:08, 21 August 2023 (UTC)
Take addStyleTag() outside the callback to mw.hook( 'wikipage.content' ).add(). Otherwise it would be adding the tags every time the hook is fired (e.g. previewing). You also don't need it for each declaration, it should be just one tag. Nardog (talk) 00:33, 22 August 2023 (UTC)
Thanks for that tip. Done.
Trappist the monk (talk) 01:06, 22 August 2023 (UTC)
The reason you can't just override the styles is that the script adds them after user CSS. I guess you could make it not take precedence by passing e.g. whatever is the first <style> in the document as the second argument to addStyleTag(), but that seems overkill; instructing those who want to override the default styles to use higher specificity (e.g. body .ttm_harv_err {...}) strikes me as the obvious solution, as that's the usual way of overriding CSS so it's applicable in most other situations. Nardog (talk) 00:49, 22 August 2023 (UTC)
More specificity works without !important:
body .ttm_harv_err {color:black; background-color:cornsilk}
Could make it even more specific, right? Something like this:
.mw-parser-output .ttm_harv_err {color:black; background-color:cornsilk}
That is be more in keeping with cs1|2 overrides (Help:CS1 errors § Error and maintenance messages).
Thank you.
Trappist the monk (talk) 01:06, 22 August 2023 (UTC)
.mw-parser-output .ttm_harv_err is in fact less specific than body .ttm_harv_err because .mw-parser-output is subordinate to body, but as long as it's more specific than whatever the script inserts, it works. Nardog (talk) 01:12, 22 August 2023 (UTC)
I was starting to look at adding two lines to load two css files, one the default, living with the script, and the other, a user file (if it exists) something like this:
loadcssfile("HarvErrors.css", "css") //dynamically load the default .css file loadcssfile("Special:MyPage/HarvErrors.css", "css") //dynamically load user's .css file (if exists)
where loadcssfile would be a function adapted mostly from lines 7–14 here, so that the default css defined in the script userspace is loaded first, followed by the user css (if it exists) at [[Special:MyPage]]/HarvErrors.css. Is this still worth pursuing at all, or is the approach that you (@Nardog and Trappist the monk:) are developing close to bearing fruit (or already there)? Btw, I don't know how to interpret [[Special:MyPage]] in js, do I just add brackets around it, as usual? Escape them? Mathglot (talk) 01:34, 22 August 2023 (UTC)
Not worth it. Querying the server if a page exists and then loading an external resource on top of the script itself would be unnecessarily slow and traffic-wasting. Nardog (talk) 01:39, 22 August 2023 (UTC)
Thank you. Mathglot (talk) 01:46, 22 August 2023 (UTC)

Script similar to Green Redirects but for piped links

Green Redirects makes redirects green. Please write a similar script for piped links (making piped links green). Thanks. --Mann Mann (talk) 07:51, 16 January 2023 (UTC)

@Mann Mann: Hi. Try User:Jeeputer/highlightPiped. You can use This page for testing. If you have GreenRedirects installed, or have Preferences → Gadgets → check Display links to disambiguation pages in orange enabled, piped links to redirect and/or disambiguation pages will appear like "|Link" and "|Link" respectively. Note that links like [[Ship]]s are also considered as piped links as there's no way for the script to distinguish them from piped links. Let me know if you have any suggestions or encountered any problems. Jeeputer Talk 06:25, 24 August 2023 (UTC)
Hi. Thank you very much. Cheers! --Mann Mann (talk) 12:44, 24 August 2023 (UTC)
@Mann Mann: You're very welcome. :) I also added custom color. See User:Jeeputer/highlightPiped#Custom color. Jeeputer Talk 01:12, 25 August 2023 (UTC)

Reforder

Hi! I was wondering if we could have a script that automatically changed the refs in an article to be in numerical order. So [6][41][1] becomes [1][6][41] etc Lee Vilenski (talkcontribs) 15:02, 23 August 2023 (UTC)

Is that something recommended by PAG? As both a reader and editor I prefer and expect clusters of refs to be ordered according to the relevance to the statement being supported or to the order in which the cited pieces of information appear in the statement, not to the order in which the refs appear in the whole article. Nardog (talk) 15:11, 23 August 2023 (UTC)
I think almost every FAC I've been involved in suggests doing so. There is a (large) discussion about this being an automated process before - see WP:REFORDER, however, a tool that you can run to make this happen, rather than something to attach a large amount of articles is helpful.
I've never found the argument that the first ref should be the one that is most relevant to be misguided, because if the second ref isn't as helpful, it shouldn't be there, or, it should be moved to only cite parts that it actually covers. Lee Vilenski (talkcontribs) 15:16, 23 August 2023 (UTC)
You cite multiple sources not necessarily because not all information appears in the first but usually because they demonstrate the statement together.
Besides, the numbers constantly change as named refs are removed in certain parts but not from the page altogether and as paragraphs are shuffled around. Strikes me as a pointless endeavor. Nardog (talk) 15:25, 23 August 2023 (UTC)
You shouldn't really use references to show information as a combination of the information between them (see WP:SYNTH). Maybe this needs a wider discussion, but it's very common for this to be requested upon review. Lee Vilenski (talkcontribs) 15:39, 23 August 2023 (UTC)
As a reader and as an editor, I prefer She was born in New York City in 1991.[8][3] over She was born in New York City[8] in 1991.[3], and I would hate if the place of birth was in the second ref and the year in the first. Nardog (talk) 15:45, 23 August 2023 (UTC)
If fixing the citation order is the norm at FAC, then that seems like sufficient consensus to me to make this user script. Just need to find a programmer with enough time. –Novem Linguae (talk) 09:22, 25 August 2023 (UTC)
That's my impression too. I've had it asked repeatedly to be done, and it's not something particularly simple to do without a script. Lee Vilenski (talkcontribs) 12:33, 27 August 2023 (UTC)
If it matters, as a common FAC/FLC reviewer, I prefer the refs to be in numerical order- think there's definitely value in this idea. MyCatIsAChonk (talk) (not me) (also not me) (still no) 12:34, 27 August 2023 (UTC)
Reviewers shouldn't be imposing what they "prefer". If you think the order should be in a particular way, you should seek consensus to make it part of our MoS. Nardog (talk) 12:40, 27 August 2023 (UTC)
I fail to see where it says in our MOS that we put citations in "relevance" order either. I'm happy to start up a formal discussion on the subject, as I had always thought that the continual requests to put this into numerical order was standard. Lee Vilenski (talkcontribs) 12:44, 27 August 2023 (UTC)
False equivalence. I never demanded others follow my preference. Nardog (talk) 12:47, 27 August 2023 (UTC)
I've started up a conversation at Wikipedia talk:Citing sources#Reference order for wider input. I'm happy to not change the references, but we also need a discussion to point to that shows that is the community view. Lee Vilenski (talkcontribs) 12:52, 27 August 2023 (UTC)