Wikipedia talk:User scripts
![]() | To help centralize discussions and keep related topics together, Wikipedia talk:User scripts/List and Wikipedia talk:User scripts/Ranking redirect here. |
![]() | This project page does not require a rating on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||||||||
|
This page has archives. Sections older than 90 days may be automatically archived by Lowercase sigmabot III when more than 4 sections are present. |
![]() | See here for a complete list of archives and other subpages from the deprecated WikiProject User scripts. |
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)