Wikipedia talk:User scripts/Archive 7
![]() | This is an archive of past discussions on Wikipedia:User scripts. 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 talk page. |
Archive 1 | ← | Archive 5 | Archive 6 | Archive 7 |
"Same as the above" style descriptions are not ideal
There are a number of descriptions written with some variation of "same as the above" / "see above" / "like the above" which presumes that the linear list organization of the current page is static (or at least consistently ordered) and that records will not be copied individually to other locations. The introduction of the toolinfo.json scraper for this data breaks that assumption. I would like to suggest that folks update their descriptions to be somehow less dependent on reading order. Each case will of course be slightly different, but one typical solution could be to replace the "above" mentions in descriptions with the names of the scripts being extended or adapted to new use cases. --BDavis (WMF) (talk) 17:36, 8 November 2021 (UTC)
- @BDavis (WMF): Started to do this with Special:Diff/1059750942 ― Qwerfjkltalk 11:25, 11 December 2021 (UTC)
Should we recommend script-installer?
Right now all the installation instructions use the manual method. script-installer is pretty simple, though... maybe we should just point people towards that? Enterprisey (talk!) 06:42, 28 September 2021 (UTC)
- Yes. – SD0001 (talk) 11:32, 28 September 2021 (UTC)
- I've thought about removing the installation instructions from the list altogether. As much as I do prefer the new layout, the instructions stick out like a sore thumb (as did they in the old layout). While we're at it, I wish script-installer didn't rely on IDs (see User talk:Enterprisey/script-installer#id vs data-). Nardog (talk) 12:16, 28 September 2021 (UTC)
- Yes those "How to install" links are atrocious. It's better to generalize the installation instructions, rather than include it for every script. – SD0001 (talk) 15:46, 28 September 2021 (UTC)
- Absolutely. There's no reason for people to be mucking about editing js files by hand. The more standardized and automated you can make this, the better. -- RoySmith (talk) 16:04, 28 September 2021 (UTC)
- Yes those "How to install" links are atrocious. It's better to generalize the installation instructions, rather than include it for every script. – SD0001 (talk) 15:46, 28 September 2021 (UTC)
- @Enterprisey @Nardog @RoySmith @SD0001 I think script installer can been run from the documentation page with a link like https://en.wikipedia.org/wiki/Wikipedia_talk:User_scripts/Archive_7.js?withJS=MediaWiki:Gadget-script-installer.js[1], which doesn't require script installer to be installed. ― Qwerfjkltalk 18:33, 28 September 2021 (UTC)
- Very true; I think recommending that people actually install script-installer would still be helpful, because of course it allows them to easily uninstall and otherwise manage the scripts. Enterprisey (talk!) 07:24, 29 September 2021 (UTC)
- @Enterprisey: Using some styling Ed6767 made, I created {{Script install button}}. ― Qwerfjkltalk 11:30, 11 December 2021 (UTC)
- @Qwerfjkl, cool. It's very red, though... I always thought of installing scripts as more of a blue or green action, y'know? Enterprisey (talk!) 07:20, 12 December 2021 (UTC)
- @Enterprisey: I just moved the styling to Template:TemplateStyles sandbox/script-installer button.css. Feel free to edit either the styling or the template as much as you want, I don't mind. ― Qwerfjkltalk 13:04, 12 December 2021 (UTC)
- Enterprisey, {{Script installer link}}. Also, if you can add a display:none class to script-installer a link like that could be added to {{Infobox Wikipedia user script}} and subsequently hidden if script-installer is enabled. — Alexis Jazz (talk or ping me) 13:11, 12 December 2021 (UTC)
- @Qwerfjkl, cool. It's very red, though... I always thought of installing scripts as more of a blue or green action, y'know? Enterprisey (talk!) 07:20, 12 December 2021 (UTC)
- @Enterprisey: Using some styling Ed6767 made, I created {{Script install button}}. ― Qwerfjkltalk 11:30, 11 December 2021 (UTC)
- Very true; I think recommending that people actually install script-installer would still be helpful, because of course it allows them to easily uninstall and otherwise manage the scripts. Enterprisey (talk!) 07:24, 29 September 2021 (UTC)
Done. Nardog (talk) 00:47, 29 September 2021 (UTC)
References
- ^ The actual link is
https://en.wikipedia.org/wiki/{{FULLPAGENAMEE}}.js?withJS=MediaWiki:Gadget-script-installer.js
nocreate-missing
Hi, I keep on getting this error when trying to submit an edit (from this script). What does this error mean? ― Qwerfjkltalk 10:55, 11 December 2021 (UTC)
- Got a screenshot, or steps to reproduce? –Novem Linguae (talk) 11:16, 11 December 2021 (UTC)
- @Novem Linguae: To reproduce: install the script, go to Wikipedia:Database reports/Unused templates, click delete (note that this will tag the page for deletion, it's just the user notification edit that fails). I can disable the editing if you want to test this. ― Qwerfjkltalk 11:25, 11 December 2021 (UTC)
- Thanks. Where's the delete link? –Novem Linguae (talk) 11:30, 11 December 2021 (UTC)
- @Novem Linguae: Oops. I meant Wikipedia:Database reports/Empty categories. ― Qwerfjkltalk 11:32, 11 December 2021 (UTC)
- Looks like
window.unusedCategoriesPageCreator
is undefined. So at line 179, when you try to donew mw.Api().edit('User_talk:'+window.unusedCategoriesPageCreator, function() {
, it sends a page title that doesn't exist. So the API responds with'nocreate-missing' => array('code' => 'missingtitle', 'info' => "The article you tried to edit doesn't exist")
. –Novem Linguae (talk) 11:51, 11 December 2021 (UTC)- Thanks, I changed the variable to a local variable but forgot to change that. Fixed now. ― Qwerfjkltalk 12:31, 11 December 2021 (UTC)
- Looks like
- @Novem Linguae: Oops. I meant Wikipedia:Database reports/Empty categories. ― Qwerfjkltalk 11:32, 11 December 2021 (UTC)
- Thanks. Where's the delete link? –Novem Linguae (talk) 11:30, 11 December 2021 (UTC)
- @Novem Linguae: To reproduce: install the script, go to Wikipedia:Database reports/Unused templates, click delete (note that this will tag the page for deletion, it's just the user notification edit that fails). I can disable the editing if you want to test this. ― Qwerfjkltalk 11:25, 11 December 2021 (UTC)
- @Novem Linguae: Do you know how to check if a page exists? ― Qwerfjkltalk 15:46, 27 December 2021 (UTC)
- @Qwerfjkl, an API query for prop=revisions should do the trick. Something like (untested, let me know if you need me to debug it):
- –Novem Linguae (talk) 16:10, 27 December 2021 (UTC)
async function pageExists(title) { let api = new mw.Api(); let response = await api.get( { "action": "query", "format": "json", "prop": "revisions", "titles": title } ); return Object.entries(response.query.pages); }
- You don't need
revisions
, just response.query.pages[n] will havemissing
if missing (and alsoknown
if it's a file on Commons or a user page on Meta that exists). Nardog (talk) 16:28, 27 December 2021 (UTC)
- You don't need
User script working intermittently
Hello. One of my user scripts, User:Novem Linguae/Scripts/NotSoFast.js, is only working intermittently. What it is supposed to do is highlight times at Special:NewPagesFeed red or yellow if they were published within the last hour. I suspect a race condition. The algorithm I am using is 1) to fire it onready $(function() {
, and then 2) fire it again when $('body').on('DOMNodeInserted', '.mwe-pt-list-item', function() {
. Any ideas how to fix? Thanks. –Novem Linguae (talk) 05:16, 8 March 2022 (UTC)
Temperamental script loading
User:Qwerfjkl/scripts/CFDlister.js seems to load temperamentally, and I've had to undo and redo changes to get it (and XFDCloser) to work. I suspect this is due to how it adds links to section headers - is there a better way of doing this? — Qwerfjkltalk 19:38, 19 October 2022 (UTC)
Someone who is not me might explore that recent tool. If you regard it as safe amd helpful they might add it to Wikipedia:User scripts/List. Greetings -- PerfektesChaos (talk) 21:39, 16 August 2022 (UTC)
- @PerfektesChaos. Looks fine to me. You are welcome to self-add it. Couple of additional tips: 1) consider changing "JavaScript gadget" to "JavaScript user script", since it's not an enwiki gadget. 2) Consider adding {{Infobox user script}} to the page, which will add a big blue "Install" button for the many of us who have User:Enterprisey/script-installer installed. –Novem Linguae (talk) 23:15, 16 August 2022 (UTC)
- Thanks for your kind comment.
- As I stated above, I won’t advertise myself.
- English Wikipedia is a gracious host of most of my codes, but my scripts are not directed to English Wikipedia itself.
- Therefore no documentation will include any installation helpers for particular wikis only.
- Some wikis are offering access to some of my scripts as a gadget.
- Globally >150 users are loading my tools.
- Greetings --PerfektesChaos (talk) 16:32, 4 September 2022 (UTC)
- @PerfektesChaos, a script I forked from someone else (to whom I should probably add attribution), User:Qwerfjkl/scripts/cleanup.py, might interest you. It attempts to clean up ref names produced by VE.
I may be mistaken, but can't you have different documentation on different wikis? — Qwerfjkltalk 20:48, 4 September 2022 (UTC)
MassRevert
Hello! Can someone help me by showing me a user script that can do mass reverts? Lately in my homewiki my robot malfunctioned and now I need to revert around 1500 edits. I can revert them with AWB by doing the reverse of that edit 1500 times I suppose but it would be better if I can do 1500 reverts with "a click of a button". — Klein Muçi (talk) 14:50, 8 October 2022 (UTC)
- I have a massRollback script which is pretty widely-used, I think: User:Writ Keeper/Scripts/massRollback.js. Writ Keeper ⚇♔ 16:36, 8 October 2022 (UTC)
- @Klein Muçi, Wikipedia:Kill-It-With-Fire can be used for mass undo, which works when the page has already been edited. — Qwerfjkltalk 16:57, 8 October 2022 (UTC)
- Qwerfjkl, @Writ Keeper, thank you both! — Klein Muçi (talk) 22:39, 8 October 2022 (UTC)
User_script/List states only tested on Vector
Still True? Wikipedia:User_scripts Wakelamp d[@-@]b (talk) 09:55, 9 October 2022 (UTC)
Announcing script RefRenamer: replaces VE numeric refs with reasonable ref names
For those of you who have been bedeviled by those annoying numeric ref names generated by the Visual Editor such as ":0", ":1" and so forth, it's my honor to announce a new script created by User:Nardog.
Script User:Nardog/RefRenamer will convert all VE numeric names on a page to useful named references (default: Lastname-YYYY). There are many addditional options to customize how you want it done. This has worked flawlessly on pages containing more than a hundred numeric references; here's an example where it made about 136 changes at Generation Z (diff).
The script doesn't stop the VE problem from occurring, but it is a complete solution for converting one page that you're working on to reasonable ref names. Mathglot (talk) 21:40, 9 February 2023 (UTC)
- You know Nardog added it to the list already right?
Fred Gandt · talk · contribs
22:33, 9 February 2023 (UTC)- Hm, no, I didn't. There seem to be two "References" subsections, and I added mine to the one under section "Namespace-specific" which seems like the right place. Or maybe it should be in both places, just to be sure. Mathglot (talk) 00:19, 10 February 2023 (UTC)
- I'd defer to Nardog; frankly I find the whole list quite confusing these days 🤷♀️
Fred Gandt · talk · contribs
01:04, 10 February 2023 (UTC)
- I'd defer to Nardog; frankly I find the whole list quite confusing these days 🤷♀️
- Hm, no, I didn't. There seem to be two "References" subsections, and I added mine to the one under section "Namespace-specific" which seems like the right place. Or maybe it should be in both places, just to be sure. Mathglot (talk) 00:19, 10 February 2023 (UTC)