Wikipedia talk:User scripts/Archive 7
"Same as the above" style descriptions are not idealThere 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)
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)
Done. Nardog (talk) 00:47, 29 September 2021 (UTC) References
|
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)
CSS items
@Nardog I mean, that's what User:BrandonXLF/GreenRedirects is. I don't see why it'd be a worse idea than JS, which can actually compromise one's browser. Aaron Liu (talk) 02:54, 21 February 2024 (UTC)
- It's not. common.css and global.css are loaded automatically for the owners and they can put or remove whatever they want there at any time. If you intend some styles to be imported by other users, you should host it as a separate page. Nardog (talk) 03:01, 21 February 2024 (UTC)
- Also, importing an external CSS via JS causes FOUCs. Using
@import
doesn't, but can delay first paint. Nardog (talk) 06:12, 21 February 2024 (UTC)- Speaking about that... my @import doesn't seem to be working right now :p Aaron Liu (talk) 16:07, 21 February 2024 (UTC) Fixed that now! Aaron Liu (talk) 03:05, 22 February 2024 (UTC)