Wikipedia talk:User scripts/Archive 7
![]() | This is an archive of past discussions. 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)
Can't find the right section
I can't find the appropriate section for my script User:Jeeputer/specialRandomPage on WP:US/L. The script opens a random page based on user options. It's some kind of a shortcut, but as the section's description mentions, it does not belong to that section. Can anyone please help me finding the right section? Thanks. Jeeputer Talk 07:33, 21 May 2023 (UTC)
- Just put it in "Site-wide". It has somewhat similar scripts like Cat next and GoToTitle. Nardog (talk) 07:53, 21 May 2023 (UTC)
- @Nardog: Thank you. Jeeputer Talk 07:58, 21 May 2023 (UTC)
- Just found out that Special:Edit/Special:RandomPage works. — Qwerfjkltalk 09:15, 21 May 2023 (UTC)
- That was a functionality I did not know about! Nice! Jeeputer Talk 09:59, 21 May 2023 (UTC)
- Just found out that Special:Edit/Special:RandomPage works. — Qwerfjkltalk 09:15, 21 May 2023 (UTC)
- @Nardog: Thank you. Jeeputer Talk 07:58, 21 May 2023 (UTC)
Should User:Moonythedwarf/extra-unreliable be added?
It seems based off of Headbomb's user script but it instead highlights URLs that have certain words in them in orange.
Also, user:GeneralNotability/unreliable-rules.js might be useful as an add-on to Headbomb's script. I know it's not meant as a public tool, but people are using it, and there's little reason we can't possibly fork the script. 137a (talk • edits) 19:26, 21 April 2023 (UTC)
- Should be OK to boldly add any useful user scripts you want to WP:US/L. The list doesn't have strict criteria. Optional but polite: you could ask the user script owners if it's OK to add their scripts for them, perhaps by pinging them to this discussion. Hope this helps. –Novem Linguae (talk) 20:02, 21 April 2023 (UTC)
- OK, thanks. I asked both of them. 137a (talk • edits) 15:48, 28 April 2023 (UTC)
- added Moonythedwarf's script, got no response 137a (talk • edits) 15:31, 24 May 2023 (UTC)
- OK, thanks. I asked both of them. 137a (talk • edits) 15:48, 28 April 2023 (UTC)
Some scripts already in user preferences.
Hi. I can't remember exactly which ones I saw, but I seem to recall a couple of scripts in the list that are already options in user preferences or global preferences, and I'm wondering if there might be conflicts, slowdowns or other problems created when a user doesn't realize they already have an option enabled in their preferences, and they re-install it through these scripts. Thanks. Huggums537 (talk) 02:00, 3 July 2023 (UTC)
An error occurs at Wikipedia:User scripts/Ranking
This help request has been answered. If you need more help, you can , contact the responding user(s) directly on their user talk page, or consider visiting the Teahouse. |
When I open the page, I find an error message saying that "Lua error in Module:User_scripts_table at line 22: attempt to index local 'jsContent' (a nil value)." It looks like a big red link, and when I click on it, it shows:
Lua error in Module:User_scripts_table at line 22: attempt to index local 'jsContent' (a nil value).
Backtrace:
- Module:User_scripts_table:22: in function "chunk"
- mw.lua:527: ?
- [C]: ?
I'm not sure whether this is my computer's error, but I list it here just to check whether this is the case. Sorry for disruption caused if this is my computer's error. The person who loves reading (talk) 01:42, 10 July 2023 (UTC)
- @The person who loves reading: It's not just you. I see it, too. But you'll need to go to a more technical help area to see whether there's a fix or whatever. I suggest WP:VPT. — jmcgnh(talk) (contribs) 03:16, 10 July 2023 (UTC)
- Fixed, though FWIW I don't think that page should be linked in navigation templates. It takes forever to load, and since it's not manually curated it has lots of noise like scripts that are broken, available as gadgets, or superseded by other maintainers. I'd be surprised if anyone finds utility in it. Nardog (talk) 03:31, 10 July 2023 (UTC)
Upcoming script article in the Signpost
Before it's out, I want to get early feedback from script coders on this piece to make sure I haven't said anything dumb, or overlooked something. I'm looking for comments on the substance, rather than grammar mistakes, since the piece is yet to be copy-edited. In particular.
@AManWithNoPlan, BrandonXLF, Trappist the monk, Svick, SuperHamster, Novem Linguae, The Earwig, Dispenser, Zhaofeng Li, Kaniivel, Ohconfucius, Nemo bis, and Pintoch:
Feel free to tweak your own script's section, and/or update your script's page if it's outdated. If you have comments, please put them here instead of on the talk page of that article. Headbomb {t · c · p · b} 20:40, 19 July 2023 (UTC)
- @Headbomb: Great article! Thanks for putting it together and including CiteUnseen. I expanded CiteUnseen's description a bit, and replaced the image with one that focuses more on the nature of sources since that's what CiteUnseen is geared towards. I might revise a bit more, and feel free to retouch my changes if needed. Thanks, ~SuperHamster Talk Contribs 05:51, 20 July 2023 (UTC)
- Many thanks
- Maybe you could mention that while Refill is a really useful useful tool, the script hasn't been maintained for several years. On my side, i haven't been very active of late but I still log in regularly, and I'm always open to suggestions and advice Ohc revolution of our times 06:04, 22 July 2023 (UTC)
@AManWithNoPlan, BrandonXLF, Trappist the monk, Svick, SuperHamster, Novem Linguae, The Earwig, Dispenser, Zhaofeng Li, Kaniivel, Ohconfucius, Nemo bis, and Pintoch: Now live, thanks everyone! Headbomb {t · c · p · b} 03:49, 1 August 2023 (UTC)
- Thanks Headbomb! The post also pushed me to make a bunch of updates to CiteUnseen (changelog here - new categories, more user config, better string matching, better citation capturing, and more). ~SuperHamster Talk Contribs 07:58, 1 August 2023 (UTC)
- Thanks, Headbomb! — The Earwig (talk) 13:16, 1 August 2023 (UTC)
Twinkle in there twice
I presume it's unintentional, that Twinkle is in the table twice? Mathglot (talk) 19:01, 20 August 2023 (UTC)
- What table? Nardog (talk) 19:12, 20 August 2023 (UTC)
- I suspect the one at WP:User scripts/Ranking, its talk page redirects here (as does the talk page of WP:User scripts/List). Mathglot, please confirm. --Redrose64 🌹 (talk) 21:26, 21 August 2023 (UTC)
- Yes, confirmed (rows #2 and 29. I'm so sorry; I just hate it when people write stuff with no links; don't know what happened—I deserve a trout. Mathglot (talk) 21:29, 21 August 2023 (UTC)
- I see. That page takes Wikipedia:User scripts/Most imported scripts and indiscriminately pulls content from associated pages. But Twinkle is now a gadget so it shouldn't be in a list of user scripts at all. This is why that page is useless: it doesn't care about duplicates or scripts that are broken or superseded by forks or gadgets. So it's not a mistake that it appears twice (or 5 times actually), it's a mistake that it appears at all or that that page exists. Nardog (talk) 01:30, 22 August 2023 (UTC)
- Those two pages provide useful data. It's good to know which user scripts have a lot of installs. In fact I shared one of those pages with someone at Wikimania who was trying to build a list of critical technology. –Novem Linguae (talk) 04:41, 22 August 2023 (UTC)
- I guess they serve your need if you're specifically looking for "which local scripts appear in local user .js most frequently" (NB comments are not ignored). /Ranking is IMO impractical at best (takes forever to render) and misleading at worst (contains obsolete scripts) for those looking for scripts that might be useful. Nardog (talk) 18:26, 22 August 2023 (UTC)
- It looks like /Ranking uses a module to pull its data from the other page, making the data identical. The difference, I think, is that /Ranking adds description and install links. Is that correct? If so then both lists contain the "obsolete scripts" flaw. Seems like an acceptable flaw to have in a report, since the remaining data is still useful. –Novem Linguae (talk) 18:40, 22 August 2023 (UTC)
- If you're a developer or wiki historian looking for statistics they're useful. /Most imported scripts provides the raw data and /Ranking descriptions on top of that. But they're impractical and inadvisable for end users looking for new scripts to install. Nardog (talk) 18:51, 22 August 2023 (UTC)
- Spot checking the two pages, they are not row-for-row identical. But according to the documentation at Module:User scripts table, they should be. I wonder why they are not identical. –Novem Linguae (talk) 18:41, 22 August 2023 (UTC)
- Look at line 22, it's excluding deprecated scripts (by seeing if they contain
mw.log.warn( 'You installed the userscript
). Nardog (talk) 19:00, 22 August 2023 (UTC)
- Look at line 22, it's excluding deprecated scripts (by seeing if they contain
- It looks like /Ranking uses a module to pull its data from the other page, making the data identical. The difference, I think, is that /Ranking adds description and install links. Is that correct? If so then both lists contain the "obsolete scripts" flaw. Seems like an acceptable flaw to have in a report, since the remaining data is still useful. –Novem Linguae (talk) 18:40, 22 August 2023 (UTC)
- I guess they serve your need if you're specifically looking for "which local scripts appear in local user .js most frequently" (NB comments are not ignored). /Ranking is IMO impractical at best (takes forever to render) and misleading at worst (contains obsolete scripts) for those looking for scripts that might be useful. Nardog (talk) 18:26, 22 August 2023 (UTC)
- Those two pages provide useful data. It's good to know which user scripts have a lot of installs. In fact I shared one of those pages with someone at Wikimania who was trying to build a list of critical technology. –Novem Linguae (talk) 04:41, 22 August 2023 (UTC)
- I see. That page takes Wikipedia:User scripts/Most imported scripts and indiscriminately pulls content from associated pages. But Twinkle is now a gadget so it shouldn't be in a list of user scripts at all. This is why that page is useless: it doesn't care about duplicates or scripts that are broken or superseded by forks or gadgets. So it's not a mistake that it appears twice (or 5 times actually), it's a mistake that it appears at all or that that page exists. Nardog (talk) 01:30, 22 August 2023 (UTC)
- Yes, confirmed (rows #2 and 29. I'm so sorry; I just hate it when people write stuff with no links; don't know what happened—I deserve a trout. Mathglot (talk) 21:29, 21 August 2023 (UTC)
- I suspect the one at WP:User scripts/Ranking, its talk page redirects here (as does the talk page of WP:User scripts/List). Mathglot, please confirm. --Redrose64 🌹 (talk) 21:26, 21 August 2023 (UTC)
Issue with the border of the "Snippets" box
If you click the [show] button to expand the list in the Snippets section, it becomes wider while the border around it stays the same width, causing it to overlap part of the border.
I don't know how to fix this myself (and couldn't edit the page even if I did). 91.129.104.148 (talk) 06:47, 20 November 2023 (UTC)
- 91.129.104.148, I've modified it to use {{cot}} and {{cob}}. Hope that helps. — Qwerfjkltalk 16:51, 20 November 2023 (UTC)
- Thanks. 91.129.104.148 (talk) 17:47, 20 November 2023 (UTC)
User scripts clash, dark mode not working, disruption of toolbars, editing interfaces
I have many user scripts installed in my common.js page, which seem to be clashing with each other. At the top of every page, some of the disrupting elements seem to be parts of RedWarn, but they are still appearing again and again even though I have uninstalled RedWarn from my common.js.
I don't know what's causing Volker E. (WMF)'s dark-mode.js to dysfunction. For some reason, the dark mode's toggle button appears 4 times on the top of every page, and one of the button says "light mode", while the rest say "dark mode".
Also, in desktop mode, the source editor initially does not show any article content, instead just displays "the below text may contain spoilers" with a [show] button at the right side.
What could have caused RedWarn's parts to appear again?
Can anyone help me to fix the dark mode at least? Other clashing scripts are more annoying, but I really need dark mode for visual contrast. — CrafterNova [ TALK ] [ CONT ] 12:56, 22 January 2024 (UTC)
- You're importing the script twice (one with
importScript
, the othermw.loader.load
) and then forking the script on top of that. I suggest you remove all that (lines 65–89), and enable the dark mode toggle gadget in Preferences if you haven't done so. Nardog (talk) 13:08, 22 January 2024 (UTC)- @Nardog: After doing that, dark mode works when a page is loading, but reverts to light mode after the page has loaded. — CrafterNova [ TALK ] [ CONT ] 16:18, 22 January 2024 (UTC)
- Maybe because you're also loading and forking it in your global.js? You really need to stop putting things you don't understand in your .js, they can steal information from you or make any edit on your behalf, hence all the warnings. Nardog (talk) 00:09, 23 January 2024 (UTC)
- @Nardog: After doing that, dark mode works when a page is loading, but reverts to light mode after the page has loaded. — CrafterNova [ TALK ] [ CONT ] 16:18, 22 January 2024 (UTC)
- The spoilers thing is coming from User:Anomie/hidespoilers, which is a script seemingly written as a joke or at best for demonstration way back in 2009 and currently imported by no one but you. I wonder how the hell you found it. Nardog (talk) 13:19, 22 January 2024 (UTC)
- Weird, I don't remember installing that one. — CrafterNova [ TALK ] [ CONT ] 14:31, 22 January 2024 (UTC)
Preview edits by a userscript
A userscript can automatically generate and publish an edit using mw.Api.postWithEditToken(...). This is possible to do from any Wikipedia page to any remote Wikipedia page.
Portlet links which use WP:TemplateScript allow to generate and preview an edit for a page, currently opened in the wikitext editor.
Is there any way for a userscript to show a preview for an automatic edit for a remote page? My particular use case is generating an edit to another user's talk page from their contributions page. That is, a portlet link on a page like Special:Contributions/Example should load a preview with an edit of User talk:Example. —andrybak (talk) 15:40, 10 February 2024 (UTC)
- Use parse API. Here's how Twinkle does it. If you want to be thorough, you can use MW's native live preview API. Nardog (talk) 19:49, 10 February 2024 (UTC)
- Nardog, thank you for the pointer, I'll look into it. Is there anything that allows opening the native editor on the remote page? Similar to how preload templates work? —andrybak (talk) 19:56, 10 February 2024 (UTC)
- You mean you want to open the remote page with certain wikitext instead of the current content? If so you can attach a form element and submit it, e.g. (There doesn't seem to be a way to suppress the preview.) Nardog (talk) 20:50, 10 February 2024 (UTC)
$('<form>').attr({ method: 'post', action: mw.util.getUrl('Wikipedia:Sandbox', { action: 'edit' }), enctype: 'multipart/form-data' }).append( $('<input>').attr({ name: 'wpTextbox1', type: 'hidden' }).val('foo') ).appendTo(document.body).trigger('submit').remove();
- Come to think of it, a simpler way is to just store the text in e.g. sessionStorage, open the page the normal way, and modify the textbox (use jquery.textSelection). Nardog (talk) 20:59, 10 February 2024 (UTC)
- Re:
There doesn't seem to be a way to suppress the preview.
– here are tweaked fields of the form to mimic "Show changes" instead of "Show preview":/* the data of the edit */ $('<input>').attr({ name: 'wpTextbox1', type: 'hidden' }).val(newWikitext), $('<input>').attr({ name: 'wpSummary', type: 'hidden' }).val(editSummary), /* show as a diff */ $('<input>').attr({ name: 'wpDiff', type: 'hidden' }).val(true), /* wpUltimateParam is needed to avoid the scary error * "Some parts of the edit form did not reach the server" */ $('<input>').attr({ name: 'wpUltimateParam', type: 'hidden' }).val(1)
- Just in case anyone else will find it useful. —andrybak (talk) 21:46, 10 February 2024 (UTC)
- Re:
- You mean you want to open the remote page with certain wikitext instead of the current content? If so you can attach a form element and submit it, e.g.
- Nardog, thank you for the pointer, I'll look into it. Is there anything that allows opening the native editor on the remote page? Similar to how preload templates work? —andrybak (talk) 19:56, 10 February 2024 (UTC)