Wikipedia talk:WikiProject JavaScript: Difference between revisions

Content deleted Content added
Notifying WikiProject of move discussion on Talk:GNOME
 
(28 intermediate revisions by 14 users not shown)
Line 1:
{{Talk header |shortcut=WT:JS }}
{{WikiProject banner shell|
{{WikiProject JavaScript}}
}}
{{archive box}}
 
Line 6 ⟶ 8:
 
Feel free to share the details of your user script projects, your problems, your ideas, and your JavaScript-related technological fantasies on this page. :) [[User talk:The Transhumanist|<i>The&nbsp;Transhumanist</i>]] 01:10, 14 April 2017 (UTC)
 
==Discussion at [[Wikipedia:Village pump (technical)#Creating and saving a preloaded page with one click]]==
[[File:Farm-Fresh eye.png|15px|link=|alt=]]&nbsp;You are invited to join the discussion at [[Wikipedia:Village pump (technical)#Creating and saving a preloaded page with one click]]. <span style="color:#AAA"><small>&#123;{u&#124;</small><span style="border-radius:9em;padding:0 5px;background:#088">[[User:Sdkb|<span style="color:#FFF">'''Sdkb'''</span>]]</span><small>}&#125;</small></span> <sup>[[User talk:Sdkb|'''talk''']]</sup> 19:42, 14 June 2020 (UTC){{Z48}}<!-- [[Template:Please see]] -->
 
== Looking for a userscript demonstrating a function ==
Line 21 ⟶ 20:
::It's certainly fine to have this script parse wikitext only while editing if that makes things easier. But since the script is only useful interacting with a few specific templates, it's completely reasonable to just program the templates with custom HTML classes for the script data. I would assume that would vastly simplify extracting those values. [[User:Vanisaac|Van]][[User talk:Vanisaac|Isaac]]<sub><small>[[WP:WikiProject Writing systems|WS]]</small></sub><sup style="margin-left:-3.0ex">[[Special:Contributions/Vanisaac|cont]]</sup> 18:04, 25 June 2020 (UTC)
 
A little late, but is it supposed to scroll down to where the template is and open up a screen, then load the parameters? <div style="background-color: #fef1d5;width:200px;font-size:1.25em;">[[User:SikiWtideI|'''SikiWtideI's user page''']]<div style="clear:both;"></div> [[User talk:SikiWtideI|<sup>'''Talk'''<sub>to the backwards police</sub></sup>]] </div> 00:37, 15 January 2023 (UTC)
== Proposal ==
 
Hello all. I have made a proposal over at the village pump which you may be interested in regarding user scripts. See [[Wikipedia:Village_pump_(proposals)#Proposal_regarding_a_user_script_approval_process]] [[User:Ed6767|<span style="font-family:'Roboto',sans-serif;font-weight:300;color:red;text-shadow: 2px 2px 10px black;">Ed6767</span>]] [[User talk:Ed6767|<span style="color:black;"><strong>talk!</strong></span>]] 02:29, 26 June 2020 (UTC)
 
== Help with auth to Toolforge? ==
 
Anyone know how I can authenticate a request from a user script to a Toolforge tool? I'm not sure OAuth would work, since I figure that uses cookies (but I would be happy to be wrong about that). I could always have the user script make an edit or a log entry and pass the diff/log entry ID with the request, but that seems spammy. [[User:Enterprisey|Enterprisey]]&nbsp;([[User talk:Enterprisey|talk!]]) 07:12, 3 July 2020 (UTC)
:OAuth doesn't use cookies... see [[mw:OAuth/For Developers#OAuth_in_a_nutshell]] - <u>'''[[User:Evad37|Evad]]''37'''''</u>&nbsp;<span style="font-size:95%;">&#91;[[d:w:User talk:Evad37|talk]]]</span> 08:13, 3 July 2020 (UTC)
::{{u|Evad37}}, so I was thinking that I would send a request from the user script to the tool, and the tool would then query rest.php/oauth2/resource/profile to see if the user is logged in. That's not the correct use of OAuth, I think (because I would be sending a token associated with the user to /profile, so the answer (barring token expiration) would always be "yes, the user's logged in"). I'm not sure how else to validate that a user is logged in without somehow making a request from the tool that carries the en.wp session cookies. [[User:Enterprisey|Enterprisey]]&nbsp;([[User talk:Enterprisey|talk!]]) 08:30, 3 July 2020 (UTC)
:::{{re|Enterprisey}} Hmmm... What's this for anyway? Maybe there's a different approach you could use. - <u>'''[[User:Evad37|Evad]]''37'''''</u>&nbsp;<span style="font-size:95%;">&#91;[[d:w:User talk:Evad37|talk]]]</span> 09:26, 3 July 2020 (UTC)
::::A tool for watchlisting a section (a user can subscribe/unsubscribe to a section). I don't want to store subscription lists onwiki because sections can move, be merged, etc, which would require a bot to update them. Also, just as watchlists aren't public, section watchlists shouldn't be, either. Thus, I want the userscript to make authenticated requests to a tool that stores the subscription lists in a database. [[User:Enterprisey|Enterprisey]]&nbsp;([[User talk:Enterprisey|talk!]]) 00:15, 4 July 2020 (UTC)
:{{u|Enterprisey}}, do you mean editing on behalf of a user or just authenticating that the user is that user? For the latter, I've already had some ideas about this for RW - so the script would generate a random token on the user side (the private token), have that be passed to toolforge which will store the token and also hand back a public token string which will then be used to make a public edit on Wikipedia somewhere, be it a config file or authentication page (similar to the way [[WP:DISCORD]] authenticates users). Then, the script will give the private token and the revision ID which will then link the user who made that edit to the owner of both the public and private token. From then on, the requests would be authenticated by including the private token in the request which is only known to the server and the client - the private token would be stored in a cookie or document storage so it's never made public, and when it expires the process will just run again - but this isn't the most secure solution, but I'd say its more ideal over handing auth cookies. Doing this means that authentication would be far less often. [[User:Ed6767|<span style="font-family:'Roboto',sans-serif;font-weight:300;text-shadow: 2px 2px 10px black;color:black;">Ed<span style="color:red;">6767</span></span>]] [[User talk:Ed6767|<span style="color:black;"><strong>talk!</strong></span>]] 18:09, 3 July 2020 (UTC)
::Made this horrible infographic too: [[File:RWToolforgeAuthDiagram.png|center|frameless]] [[User:Ed6767|<span style="font-family:'Roboto',sans-serif;font-weight:300;text-shadow: 2px 2px 10px black;color:black;">Ed<span style="color:red;">6767</span></span>]] [[User talk:Ed6767|<span style="color:black;"><strong>talk!</strong></span>]] 18:20, 3 July 2020 (UTC)
:::Looks good, and thanks for the infographic! (Very high-effort!) I will probably end up trying this if I can't find an existing solution. [[User:Enterprisey|Enterprisey]]&nbsp;([[User talk:Enterprisey|talk!]]) 01:31, 4 July 2020 (UTC)
:::Please [https://security.stackexchange.com/questions/168261/what-does-dont-roll-your-own-security-mean don't roll your own authentication system], it rarely ends well. --[[User:Tgr|Tgr]] ([[User talk:Tgr|talk]]) 20:01, 4 July 2020 (UTC)
::::Indeed - for people stumbling across this - this should be noted as a very basic sketch in my head, untested verification system and should never ever ever ever be used as authentication of to carry any sort of sensitive info. OAuth2 or another existing system is always ideal. [[User:Ed6767|<span style="font-family:'Roboto',sans-serif;font-weight:300;text-shadow: 2px 2px 10px black;color:black;">Ed<span style="color:red;">6767</span></span>]] [[User talk:Ed6767|<span style="color:black;"><strong>talk!</strong></span>]] 22:07, 4 July 2020 (UTC)
:Further discussion, by the way, including another (component of a) solution, at [[meta:Tech#Authenticating a request from a user script to a toolforge tool]] ([[meta:Special:Permalink/20243665#Authenticating a request from a user script to a toolforge tool|permalink]]). [[User:Enterprisey|Enterprisey]]&nbsp;([[User talk:Enterprisey|talk!]]) 05:51, 4 July 2020 (UTC)
 
== Calling for volunteers for [[WP:RedWarn|RedWarn]] - a fast growing new JavaScript counter-vandalism tool ==
Line 45 ⟶ 28:
== OneClickUnarchiver ==
 
It's not uncommon to need to restore a discussion from a talk venue archive, but it's not easy to do it correctly and exceeds the ability of many editors. I wonder if anyone would be interested in creating a restore-from-archive script modeled after [[Wikipedia:One click archiving|OneClickArchiver]]. Instead of clicking an "Archive" link on a talk page, one would click a "Restore" link on an archive page. The coding would be a little simpler than OneClickArchiver, which has to worry about whether it's time to create a new archive page. Any taker? &#8213;[[User:Mandruss|<span style="color:#775C57;">'''''Mandruss'''''</span>]]&nbsp;[[User talk:Mandruss|<span style="color:#888;">&#9742;</span>]] 22:08, 27 November 2020 (UTC)
 
== Proposal to change the user scripts header message ==
== JS on wikimedia is currently too antiquated to ever bloom ==
 
The [[Mediawiki:Clearyourcache]] message should link "scripts" to [[WP:US]]. I made a proposal at [[Template talk:Script doc auto#Proposal: link to WP:US]]. [[User:Enterprisey|Enterprisey]]&nbsp;([[User talk:Enterprisey|talk!]]) 21:50, 13 December 2020 (UTC)
I would love to contribute code to wikipedia, but I'm once again failing at the same obstacle I did 6 months ago. Wikimedia is geared to a now over 10 years old version of JavaScript. Let's put that in perspective: Wikimedia is geared to a version of JavaScript that's that was released the same year as Windows 7! Back then I was barely a teenager. JQuery is now not much more than a relic, and all it does now is encouraging sloppy code-style and making debugging a lot harder. Combine this with the relatively large API of Wikimedia and the complete lack of modern comforts like Intellisense and TypeScript it becomes nearly unsurmountable to produce a functional script while keeping your sanity for someone who has become accustomed to the modern ways.
:So I did this, and then out of curiosity looked at the pageviews stats for WP:US. Looks like they went from 60-80ish daily earlier this year, and then plunged at the beginning of May to 20-40ish daily, where they remain. Did it get de-linked from somewhere big? (pinging people from the discussion at TT:Script doc auto, who definitely didn't ask to get pinged but I figure might still be interested: {{ping|Sj|SD0001|DannyS712|prefix=|p=}}) [[User:Enterprisey|Enterprisey]]&nbsp;([[User talk:Enterprisey|talk!]]) 09:25, 19 December 2020 (UTC)
:: Interesting. Can't think of a reason... <span style="color:#666">&ndash;&nbsp;[[User:Sj|SJ]][[User Talk:Sj|<span style="color:#f90;">&nbsp;+</span>]]</span> 03:12, 24 December 2020 (UTC)
 
== Moving snippets to user space ==
There is sadly no easy way to remedy this...
The changes necessary would be large enough to warrant an essentially total rewrite of the MediaWiki software. And while this would open up some awesome opportunities, I won't blame anyone breaking out in cold sweat when they just imagine it.
 
Hi there! I am going to suggest moving [[Wikipedia:User scripts#Snippets|these user script "snippets"]] formerly managed by WikiProject User scripts to be migrated to user space. This brings multiple advantages, but mainly improves security (they would be interface-admin protected essentially), and readability / ease-of-use (the pages that are not currently marked as JS in terms of content model would be able to be installed using scripts like scriptinstaller). [[User:EpicPupper|🐶 EpicPupper]] <sup>(he/him &#124; [[User talk:EpicPupper|talk]])</sup> 19:13, 13 March 2022 (UTC)
Any opinions on this? [[User:SkSlick|SkSlick]] ([[User talk:SkSlick|talk]]) 01:08, 13 December 2020 (UTC)
:True. [[WP:RedWarn]] ran into this issue (cc {{u|Ed6767}}). Would be nice if you could specify some build options to be applied to a JS/TS file after you hit "Save", so we could at least use Babel. Or maybe the devs could give us a few checkboxes with various transpilers (Babel, TS compiler) for each user script. Shouldn't be that tough to add. [[User:Enterprisey|Enterprisey]]&nbsp;([[User talk:Enterprisey|talk!]]) 17:01, 13 December 2020 (UTC)
::{{small|(not Ed, but)}} Hard agree with the sentiments here. As a developer more skilled with modern web technologies, trying to piece together code for Wikipedia has been a hassle. Old MediaWiki JavaScript has been quite the problem for RedWarn, especially now when we're rewriting RedWarn from the ground up using TypeScript. MediaWiki's codebase not having type definitions is another pain in the rear, since every time we want to use a function or property within MediaWiki's <code>mw</code>, we've had to place whatever we need in a [https://gitlab.com/redwarn/redwarn-web/-/raw/dev-rwTS/src/mediawiki.d.ts declaration file] that has been expanding even more and more as progress goes on. I've tried to automatically grab the types based on the provided JSDoc inside of the source, but to no avail, as it it extremely complicated to do so. Since a rewrite of MediaWiki's JavaScript parts is ''(unfortunately)'' out of the question (unless WMF wants to spend some funds to make that happen), we've had to deal with this old and clunky method. My best advice would be to have the [https://doc.wikimedia.org/mediawiki-core/master/js/ MW JS documentation] at hand whenever making scripts, and just rely on your best senses to see which goes with which. Sure, it's a strong timesink, but once you're used to the extremely old and aging JavaScript codebase, it shouldn't really be a problem. Babel/TS transpilers don't sound that bad, but that might raise some security or performance issues. I guess the only way to find out if that's the case would be to actually bring that suggestion to the Phab. But if there's anything that Wikipedia has taught me about its developers, it's that there's a lot of people who are overly attached to old processes and tech, and that introducing changes as big as these (especially when it uses newer technologies) is commonly met with a lot of criticism. <span style="background:#ffff00;color:#00159c;">'''''[[User:Chlod|Chlod]]'''''</span>&nbsp;<small style="font-size:calc(1em - 2pt)">([[User talk:Chlod|say&nbsp;hi!]])</small> 17:31, 13 December 2020 (UTC)
:::See {{phab|T232285}} for a spirited discussion about using Babel for this specifically; I imagine some arguments there also apply to TS. TS declarations themselves are {{phab|T263914}}; a front-end build step in MediaWiki itself is {{phab|T199004}}. [[User:Enterprisey|Enterprisey]]&nbsp;([[User talk:Enterprisey|talk!]]) 18:05, 13 December 2020 (UTC)
::::They're finally converting JSDuck to JSDoc? 🎉 Finally! It's a bit disappointing that the Babel idea was shot down, though. It would have provided a universally better experience for writing user scripts. <span style="background:#ffff00;color:#00159c;">'''''[[User:Chlod|Chlod]]'''''</span>&nbsp;<small style="font-size:calc(1em - 2pt)">([[User talk:Chlod|say&nbsp;hi!]])</small> 18:11, 13 December 2020 (UTC)
:::I wrote about the issue on [[Wikipedia:Village pump (technical)#Proper ECMAScript support|Wikipedia:Village pump (technical)#Proper ECMAScript support]], and there are discussions ongoing {{phab|T75714}}. Some people are so afraid of new technology, to quote from an issue written just a few days ago: ''"JS is a hazard and was a mistake."''. For me there is just no way I can justify the amount of work and time needed to produce even the smallest thing. It's really a shame because I think this is a major hindrance for the loads of skilled JS/ES/TS devs who regularly contribute to OSS projects that may be interested in contributing here... [[User:SkSlick|SkSlick]] ([[User talk:SkSlick|talk]]) 20:57, 13 December 2020 (UTC)
 
==Help: IllWill.js==
:::And see [https://github.com/azatoth/twinkle/pull/1220 here] for a spirited discussion on upgrading Twinkle to use TypeScript as part of a rewrite for localizability (spoiler: it doesn't seem to be going well).
There is a problem with the behaviour of [[User:Cobaltcigs]]'s [[User:Cobaltcigs/IllWill.js|IllWill.js]]: If I fill in the edit summary as I go along editing an article, and then invoke that script, it overwrites my edit summary with its own. I'm no expert in JavaScript, but it occurs to me that changing in line 162 the operator <code>=</code> to <code>+=</code> would fix that. Then again, it might need more elaborate coding. I [[Special:diff/1235258054|left a message]] on the user's talk page, but he hasn't edited for some months, so I would appreciate it if someone here could fix this. -- [[User:Michael Bednarek|Michael Bednarek]] ([[User talk:Michael Bednarek|talk]]) 07:11, 31 July 2024 (UTC)
:::{{re|Chlod}} Actually just a few weeks ago I too started out writing a [https://github.com/siddharthvp/twinkle/blob/xfd-rewritten/types/mediawiki.d.ts mediawiki.d.ts file]. It seems my raw coverage is greater, but I have put in just the types and not doc-comments. Can we please collaborate on this so that the same definitions can be used across Twinkle and Redwarn and hopefully, many more scripts/gadgets to come? Open to setting up a separate repo for this that can be published to npm. – [[User:SD0001|<span style="font-weight: bold; color: green">SD0001</span>]] ([[User talk:SD0001|talk]]) 14:47, 17 December 2020 (UTC)
::::@[[User:SD0001|SD0001]], sounds good :)
::::On another note, I also think it might be useful to make a project on Meta-Wiki where we do this, and additionally can provide warning/xfd/tag definitions in a standard format that can be used across all bots/scripts/tools/etc. It'd make things much easier for everyone just having one standard library that can be installed via NPM, or the raw JSON data that can be fetched/stored locally. It'd also mean Wiki localisation would be so much easier, and all the tools can provide the same templates. What do you think? 🎄🎄 [[User:Ed6767|<span style="font-family:'Roboto',sans-serif;font-weight:300;text-shadow: 2px 2px 10px black;color:black;">Ed</span>]] [[User talk:Ed6767|<span style="color:black;"><strong>talk!</strong></span>]] 🎄🎄 15:48, 17 December 2020 (UTC)
:::::{{re|Ed6767}} That would be a nice thing to aim for. But I'm not sure if that's straightforward as all that data isn't easily represented in JSON form. [https://github.com/wikimedia-gadgets/twinkle/blob/l10n/src/tag-data.ts Here's] the file for tag data. 95% of it is JSON, but it gets tricky to stay within JSON limits for the data on what inputs to ask the user for each tag. – [[User:SD0001|<span style="font-weight: bold; color: green">SD0001</span>]] ([[User talk:SD0001|talk]]) 17:46, 18 December 2020 (UTC)
::::::@[[User:SD0001|SD0001]], it'd just take a rework of the way the data is processed and the logic works, which is a plus if anything as you wouldn't have to write/copy more code if you needed to add a different tag with similar functionality. We could provide example code to aid any new tool developers with this. 🎄🎄 [[User:Ed6767|<span style="font-family:'Roboto',sans-serif;font-weight:300;text-shadow: 2px 2px 10px black;color:black;">Ed</span>]] [[User talk:Ed6767|<span style="color:black;"><strong>talk!</strong></span>]] 🎄🎄 18:59, 18 December 2020 (UTC)
 
== [[:React (JavaScript library)]] listed at Requested moves==
== Proposal to change the user scripts header message ==
[[File:Information.svg|30px|left]]A [[Wikipedia:Requested moves|requested move]] discussion has been initiated for [[:React (JavaScript library)]] to be moved to [[React (software)]]. This page is of interest to this WikiProject and interested members may want to participate in the discussion [[Talk:React (JavaScript library)#Requested move 8 November 2024|here]].<!-- Talk:React (JavaScript library)#Requested move 8 November 2024 crosspost --> —[[User:RMCD bot|RMCD bot]] 03:50, 8 November 2024 (UTC)
:<small>To opt out of RM notifications on this page, transclude {{tlp|bots|2=deny=RMCD bot}}, or set up [[Wikipedia:Article alerts|Article alerts]] for this WikiProject.</small>
 
== [[:A-Frame (virtual reality framework)]] listed at Requested moves==
The [[Mediawiki:Clearyourcache]] message should link "scripts" to [[WP:US]]. I made a proposal at [[Template talk:Script doc auto#Proposal: link to WP:US]]. [[User:Enterprisey|Enterprisey]]&nbsp;([[User talk:Enterprisey|talk!]]) 21:50, 13 December 2020 (UTC)
[[File:Information.svg|30px|left]]A [[Wikipedia:Requested moves|requested move]] discussion has been initiated for [[:A-Frame (virtual reality framework)]] to be moved to [[A-Frame (extended reality framework)]]. This page is of interest to this WikiProject and interested members may want to participate in the discussion [[Talk:A-Frame (virtual reality framework)#Requested move 18 April 2025|here]].<!-- Talk:A-Frame (virtual reality framework)#Requested move 18 April 2025 crosspost --> —[[User:RMCD bot|RMCD bot]] 08:12, 18 April 2025 (UTC)
:<small>To opt out of RM notifications on this page, transclude {{tlp|bots|2=deny=RMCD bot}}, or set up [[Wikipedia:Article alerts|Article alerts]] for this WikiProject.</small>
 
== [[:GNOME]] listed at Requested moves==
[[File:Information.svg|30px|left]]A [[Wikipedia:Requested moves|requested move]] discussion has been initiated for [[:GNOME]] to be moved to [[GNOME (desktop environment)]]. This page is of interest to this WikiProject and interested members may want to participate in the discussion [[Talk:GNOME#Requested move 7 July 2025|here]].<!-- Talk:GNOME#Requested move 7 July 2025 crosspost --> —[[User:RMCD bot|RMCD bot]] 12:01, 7 July 2025 (UTC)
:<small>To opt out of RM notifications on this page, transclude {{tlp|bots|2=deny=RMCD bot}}, or set up [[Wikipedia:Article alerts|Article alerts]] for this WikiProject.</small>