After selecting text, the control panel on the right is used to give instructions. The responses by the AI model are presented in the chat panel on the left.
I wrote a user script called WikiChatbot to assist editors. It can summarize, reformulate, copyedit, and provide suggestions on additional topics, images, and wikilinks as well as assess factual accuracy and bias. It is used by selecting text in an article and then clicking one of the buttons on the right to enquire about the selected text. The chatbot can also be used by typing specific questions about the selected text or the topic in general in the chat panel.
The script uses the AI model GPT 3.5. It requires an API key from OpenAI. New OpenAI accounts can use it freely for the first 3 months with certain limitations. The AI model was not designed to assess or improve encyclopedic articles. Editors should always question its responses and rely on their own judgment and reliable sources instead. For a more detailed description of all these issues and examples of how the script can be used, see the documentation at User:Phlsph7/WikiChatbot.
I was hoping to get some feedback on the script in general and how it may be improved. I'm not sure how difficult it is to follow the instructions so it would be great if someone could try to set up the script, use it, and explain which steps were confusing. My OpenAI account is already older than 3 months so I was not able to verify the claims about the free period and how severe the limitations are. If someone has a younger account or is willing to open a new account to try it, that would be helpful. Other feedback on the idea in general, its problems, new features to implement, or the documentation is also welcome. Phlsph7 (talk) 07:45, 16 July 2023 (UTC)
Reviewing proposed deletions comes with a lot of secondary tasks, and it would be great to have a userscript to help automate the process. I am suggesting something like User:Jackmcbarn/editProtectedHelper, where the script activates whenever a page has an active PROD, and provides the reviewer with buttons for the actions they can take, such as seconding the PROD or contesting the PROD.
If you second the PROD, the script should add {{prod 2}} to the page and update the {{old prod}} on the talk page accordingly. If you contest the PROD, it should remove the PROD template from the article, notify the nominator on their Talk page with {{Deprod}}, and again update the {{old prod}} on the talk page accordingly.
One other small point, contesting should remove {{prod}} and any {{prod 2}} instances (zero or more of these may exist) from the article. ~Kvng (talk) 02:07, 3 August 2023 (UTC)
If yes, how is that done? My .js skills are rudimentary at best so a detailed answer would be much appreciated. Extending this just a bit, would it be possible to use a .css TemplateStyles page so that the .css could be shared by a lua module?
In my less-than-rudimentary js, what if we had two classes on the error message line, with the first class defined in a <style> block inserted onto the page by the script (right before </head>?) and defining the default color, leaving the second class undefined and available for override at common.css, is that doable in js so that an external sheet wouldn't be needed? Mathglot (talk) 00:02, 21 August 2023 (UTC)
You can use mw.loader.load('/w/index.php?title=...&action=raw&ctype=text/css','text/css'). But that means loading an extra resource after the script is loaded, so I for one prefer just embedding the CSS within the script with mw.loader.addStyleTag(). Nardog (talk) 02:50, 21 August 2023 (UTC)
mw.loader.addStyleTag() was the easier so I did that; see lines 5–8. Seems to work except that to override the default color in user css the !important keyword is still required. Any way around that?
See my message of 00:02: I believe if you change your style tags in the new code to blah_blah_dflt, and change line 32:
mw.loader.addStyleTag('.ttm_harv_err_dflt {color:DarkOrange}');// no target error message default color...$(elem.parentNode).append(" ",$("<span class=\"ttm_harv_err_dflt ttm_harv_err\">Harv error: link from "+href+" doesn't point to any citation.</span>"));//start with dflt, allow user override
it should work without !important; i.e., this should be sufficient in common.js:
Ported your script to User:Mathglot/HarvErrors.js and tried a couple of things there; failed in the same way (that is, it doesn't work without !important, but your original version already did that). Still thinking, but so far at least, I don't see a way to work around the style priority cascade *without* !important. Mathglot (talk) 22:08, 21 August 2023 (UTC)
Take addStyleTag() outside the callback to mw.hook('wikipage.content').add(). Otherwise it would be adding the tags every time the hook is fired (e.g. previewing). You also don't need it for each declaration, it should be just one tag. Nardog (talk) 00:33, 22 August 2023 (UTC)
The reason you can't just override the styles is that the script adds them after user CSS. I guess you could make it not take precedence by passing e.g. whatever is the first <style> in the document as the second argument to addStyleTag(), but that seems overkill; instructing those who want to override the default styles to use higher specificity (e.g. body .ttm_harv_err {...}) strikes me as the obvious solution, as that's the usual way of overriding CSS so it's applicable in most other situations. Nardog (talk) 00:49, 22 August 2023 (UTC)
.mw-parser-output .ttm_harv_err is in fact less specific than body .ttm_harv_err because .mw-parser-output is subordinate to body, but as long as it's more specific than whatever the script inserts, it works. Nardog (talk) 01:12, 22 August 2023 (UTC)
I was starting to look at adding two lines to load two css files, one the default, living with the script, and the other, a user file (if it exists) something like this:
where loadcssfile would be a function adapted mostly from lines 7–14 here, so that the default css defined in the script userspace is loaded first, followed by the user css (if it exists) at [[Special:MyPage]]/HarvErrors.css. Is this still worth pursuing at all, or is the approach that you (@Nardog and Trappist the monk:) are developing close to bearing fruit (or already there)? Btw, I don't know how to interpret [[Special:MyPage]] in js, do I just add brackets around it, as usual? Escape them? Mathglot (talk) 01:34, 22 August 2023 (UTC)
Not worth it. Querying the server if a page exists and then loading an external resource on top of the script itself would be unnecessarily slow and traffic-wasting. Nardog (talk) 01:39, 22 August 2023 (UTC)
@Mann Mann: Hi. Try User:Jeeputer/highlightPiped. You can use This page for testing. If you have GreenRedirects installed, or have Preferences → Gadgets → Display links to disambiguation pages in orange enabled, piped links to redirect and/or disambiguation pages will appear like "|Link" and "|Link" respectively. Note that links like [[Ship]]s are also considered as piped links as there's no way for the script to distinguish them from piped links. Let me know if you have any suggestions or encountered any problems. JeeputerTalk06:25, 24 August 2023 (UTC)
Hi! I was wondering if we could have a script that automatically changed the refs in an article to be in numerical order. So [6][41][1] becomes [1][6][41] etc Lee Vilenski(talk • contribs)15:02, 23 August 2023 (UTC)
Is that something recommended by PAG? As both a reader and editor I prefer and expect clusters of refs to be ordered according to the relevance to the statement being supported or to the order in which the cited pieces of information appear in the statement, not to the order in which the refs appear in the whole article. Nardog (talk) 15:11, 23 August 2023 (UTC)
I think almost every FAC I've been involved in suggests doing so. There is a (large) discussion about this being an automated process before - see WP:REFORDER, however, a tool that you can run to make this happen, rather than something to attach a large amount of articles is helpful.
I've never found the argument that the first ref should be the one that is most relevant to be misguided, because if the second ref isn't as helpful, it shouldn't be there, or, it should be moved to only cite parts that it actually covers. Lee Vilenski(talk • contribs)15:16, 23 August 2023 (UTC)
You cite multiple sources not necessarily because not all information appears in the first but usually because they demonstrate the statement together.
Besides, the numbers constantly change as named refs are removed in certain parts but not from the page altogether and as paragraphs are shuffled around. Strikes me as a pointless endeavor. Nardog (talk) 15:25, 23 August 2023 (UTC)
You shouldn't really use references to show information as a combination of the information between them (see WP:SYNTH). Maybe this needs a wider discussion, but it's very common for this to be requested upon review. Lee Vilenski(talk • contribs)15:39, 23 August 2023 (UTC)
As a reader and as an editor, I prefer She was born in New York City in 1991.[8][3] over She was born in New York City[8] in 1991.[3], and I would hate if the place of birth was in the second ref and the year in the first. Nardog (talk) 15:45, 23 August 2023 (UTC)
If fixing the citation order is the norm at FAC, then that seems like sufficient consensus to me to make this user script. Just need to find a programmer with enough time. –Novem Linguae (talk) 09:22, 25 August 2023 (UTC)
Reviewers shouldn't be imposing what they "prefer". If you think the order should be in a particular way, you should seek consensus to make it part of our MoS. Nardog (talk) 12:40, 27 August 2023 (UTC)
I fail to see where it says in our MOS that we put citations in "relevance" order either. I'm happy to start up a formal discussion on the subject, as I had always thought that the continual requests to put this into numerical order was standard. Lee Vilenski(talk • contribs)12:44, 27 August 2023 (UTC)
Admins assign editors autopatrolled based on a WP:PERM request or because they show up in automated reports. As part of that process, we review their creations as a whole and decide that they don't need to be manually patrolled. It would therefore make sense to be able to mark all their prior unreviewed creations as patrolled, rather than either tediously clicking through them all, or leaving another NPPer to do a now-pointless second review.
It would also be useful for non-admin NPPers for e.g. runs of noncontroversial stubs by the same trusted user.
Alternatively, there could be a tool which patrols all pages in a user's filtered Special:NewPagesFeed (which can be filtered by user). But I think that could be quite dangerous if you mess up your filters... – Joe (talk) 13:58, 12 September 2023 (UTC)
Sounds like a great idea! I might be able to work on this soon, but by all means if you want to code it @Novem Linguae then please do (create a fork and I'll help test). While we're at it, maybe it's time we gadgetize userRightsManager and move the code to https://github.com/wikimedia-gadgets/. Enough people use it that I feel it should be in the community's hands and not solely my own. — MusikAnimaltalk16:29, 12 September 2023 (UTC)
Is there a way to see what exactly is adding a certain category to a page?
There are cases where you want to remove a category from a page but you quickly understand that it is being added by a template and not a manual category. Problem is that they may be countless of templates in the said page, each with different intricacies and transclusions. Is there a way or a script to see where categories are being added from? - Klein Muçi (talk) 12:50, 22 September 2023 (UTC)
I can't tell because it's been fixed. But if you had pasted the source of the article onto sq:Special:ExpandTemplates (be sure to fill in the context title) the category would have showed up near the cause of the error. Nardog (talk) 05:11, 23 September 2023 (UTC)
Nardog, I see. Maybe in the future we can have that as tool that does that all the time for all categories at a click of a button beside them in pages. Assuming other people may encounter it as a problem. For me, this is enough as this is only the second time ever in 10 years I encounter such problem. Thank you! — Klein Muçi (talk) 10:28, 23 September 2023 (UTC)
Script to convert numeric ref names created by VE into standard names
Please write a script to alter numeric ref names created by the WP:Visual Editor into reasonable reference names, such as Lastname-YYYY. For example, operating on the article Male gaze, it would change (among others), the reference
<ref name=":62">{{Cite book|last1=Christiansen|first1=Keith|title=Orazio and Artemesia Gentileschi|last2=Mann|first2=Judith|publisher=Metropolitan Museum of Art|year=2001}}</ref>
into
<ref name="Christiansen-2001">. . .</ref>
Two additional options would be very welcome:
a throttle (perhaps, |max=N), in order to keep the total number of changes down to a configurable number per edit; this is because as the number gets higher, diffs become increasingly difficult to read and interpret.
numeric (or named) parameters which could be used to override the automatic use of Lastname-YYYY, for a given numeric refname value. This would be useful, in cases where a named reference doesn't use one of the {{citation}} templates (such as, ref ":1" at Male gaze), or where the last name or year is not available (such as ref ":1" at Charles de Gaulle). In the latter case, including the parameter |1=Election-1958 would result in the code
<ref name=":1">{{cite web |title=Assemblée nationale. . .</ref>
<ref name="Election-1958">{{cite web |title=Assemblée nationale. . .</ref>
regardless if a different name and year were found, or if none were found. However, the basic functionality of just repairing numeric ref names without any other bells and whistles would be very welcome. See WP:VE/NAMEDREFS for phab tickets about this, and other related info. Mathglot (talk) 07:03, 19 December 2022 (UTC)
"Wow" is right; truly amazing. Thank you so much for this; it is going to be incredibly useful and helpful, a huge timesaver, and big improvement for the project. It went beyond what I imagined, and worked great at Male gaze and Charles de Gaulle. Don't worry about going overboard with options, they are wonderful. That said, I had to stare at the panel a bit to try to understand all the features, and for a couple of things it wasn't entirely clear right away. I've added a section at the script talk page with some § Questions/suggestions for you. But if you've had enough for now, don't worry; it's great as is! Thanks again, Mathglot (talk) 03:10, 9 February 2023 (UTC)
I've been attempting to put a naming protocol in place. I built it into a function in my Sources script whereby names for bare refs can be generated. Perhaps we could work together to create a coherent set of rules to give names to bare or VE-named ref tags7.-- Ohc revolution of our times20:50, 23 September 2023 (UTC)
I generally want large templates to have the source "block" formatted – one parameter per line and generally with some whitespace. I often encounter infoboxen that have been created all-in-one-line. Is there, or could there be, a userscript to help with this reformatting? (Also asked at WP:VPT) — GhostInTheMachinetalk to me15:16, 8 November 2023 (UTC)
It's a hack, but have you tried editing the lead section of the article in question using the Visual Editor? Add &veaction=edit to the edit page link. If the infobox's TemplateData is correctly set to "block", VE might do the formatting for you. – Jonesey95 (talk) 15:55, 8 November 2023 (UTC)
It does work, but the process is tedious – change config to use VE, dummy edit in the text of the infobox, reset config, fix the dummy edit, then do what I wanted to do. The script below is so much better — GhostInTheMachinetalk to me19:44, 8 November 2023 (UTC)
It does!! Thank you! This is the script I was looking for. The script is simply awesome and awesomely simple to use. Sometimes it gets a bit befuddled about a mix of spaces and not-spaces after a bar, but generally a second run solves that — GhostInTheMachinetalk to me19:44, 8 November 2023 (UTC)
Script for highlighting redirects with possibilities
I'd like a user script that highlights links in articles that go to redirects tagged with {{R with possibilities}}, indicating that they have been identified as candidates for new articles. Such a script, if adopted widely, might help encourage the creation of such articles (or, if tagged incorrectly, the removal of the possibilities tag).
Given that such articles are technically blue links but in spirit red links, I'd propose a red dashed border, as in Example, as the visual design. But someone more graphically capable than me might be able to come up with something better.
@Headbomb, thanks for pointing me to that! It looks like it should work, given that (nearly) all redirects with possibilities are in Category:Redirects with possibilities. But the documentation is unfortunately not good enough for me to figure out how to use it. The hook to adjust the list of categories is I think what I want, but it's not clear what is a core part of the script versus something I need to customize, and I'm not sure where to plug in the <span style="border: 1.5px dashed #d33; padding: 3px;">[[Example]]</span>. Would you be able to help? {{u|Sdkb}}talk17:31, 9 December 2023 (UTC)
As shown in the doc, add something like this in your common.js before calling importScript():
mw.hook('LinkClassifier').add(function(linkClassifier){linkClassifier.cats['redirect-with-possibilities']=['Category:Redirects with possibilities'].sort();});
No need to modify the script itself at all. Then in your common.css you can add a rule like this to style it:
Would it be possible to create a script that would identify unnecessary piped links and simplify them?
The advice given at WP:NOPIPE and MOS:NOPIPE is that piped links are to be avoided when a redirect exists that fits well into the context of the displayed text.
N[[Wolfgang Amadeus Mozart|Mozart]]
Y[[Mozart]]
What I'd like is a script that will scan an article for links of the first type and replace them with links of the second type: that is, where a link of the form [[A|B]] can be replaced with a link of the form [[B]], where [[B]] is a valid pre-existing redirect to [[A]], or where both [[A]] and [[B]] redirect to some other page [[C]].
I recently went through an article that has a list of organizations and added sortkeys so that all the ones with "the" in their name didn't sort alphabetically by T. It wasn't quite a long enough list to be worth composing a RegEx find and replace to do the whole thing automatically, but it strikes me as a common enough situation that it might be helpful to have a script that can do it. {{u|Sdkb}}talk15:40, 12 January 2024 (UTC)
The RegEx query for the find part would be something like \| The \[\[(\w*), and the replace part would be something like \| data-sort-value="$1" \| The \[\[$1. There would be another find-and-replace for instances in which the the is within the link: \| \[\[The (\w*) → \| data-sort-value="$1" \| \[\[The $1. Cheers, {{u|Sdkb}}talk23:42, 12 January 2024 (UTC)
@SdkbUser:Aaron Liu/SortKeyDeThe.js now does this, though it won't do things if the relevant entry isn't at the start of its line to eliminate some false positives.Also, I seem to have misread you, sorry. I thought you said that you already had a regex :p Aaron Liu (talk) 02:52, 14 January 2024 (UTC)
Maybe a data-sort-type="..." could be created for this form of alphabetical sorting? See:
Hello, I was suggested by @Tamzin on the discord to post this here, basically the inverse to User:Edward/Find_link, where instead of finding pages that could be linked to a given page, it instead finds pages that could be linked with the current text on the article. There are two different methods i can think of achieving this, either by basically making a permutation set/concordance of the article's text against title search, or just taking the categories/wikiprojects that a page belongs to and checking the articles titles on those categories/wikiprojects to see if they match text on the given page. there's pros and cons to both methods and the best would be able to implement both and automatically use one method or another given on whatever is considered less expensive computationally, or at least letting the user decide which method they'd like to use for a given search. Akaibu (talk) 14:37, 12 February 2024 (UTC)
In my opinion, this isn't a very good idea. Linking should be done when something isn't very understandable by most people, which is an easy enough criteria for people to manually do drive-by links. Aaron Liu (talk) 22:32, 27 February 2024 (UTC)
Increased Watchlist size
I watch many (currently 3,044 articles), meaning the 1,000 changes, 30 day limit can be annoying sometimes. Could there be a script created to allow for an increase? Thanks. Kew Gardens 613 (talk) 07:27, 16 February 2024 (UTC)
I couldn't find anything from a search through the list, and I've tried to engineer one myself but I'm not exactly sure where to start, but essentially I want to display the move-protection lock icon on my side when I view pages with move protection (but no edit protection). The icon itself was removed from displaying on most reader-visible pages since it means nothing to a reader, but I still find myself wanting to quickly be able to glance at the top and see that a page is protected in some way. EggRoll97(talk) 20:20, 4 March 2024 (UTC)
@GryffindorD: I made a tool that sorts articles by use of template parameters. Among others it lists unknown parameters. I recently expanded it to work on other wikis too. You can access it by visiting this page. Lmk if you encounter any bugs. Ivi104 (talk) 01:52, 22 March 2024 (UTC)
WikiDefcon User Script
I'm requesting a user script that adds a WikiDefcon marker to the top bar for Vector 2022, ideally placed next to the notifications/alerts tabs using Template:Vandalism information. This would assist greatly in counter-vandalism tasks. Possibly, it could use these images, similar to the relevant topicon. Thanks,NeuropolTalk15:37, 2 April 2024 (UTC)
Would it be possible to create a script that would delink repeated links, as well as one that would be able to find the first mention of a phrase matching the title of a link further in the article, linking that and delinking all subsequent links to that title? ‑‑Neveselbert (talk·contribs·email) 20:17, 8 March 2024 (UTC)
@Aaron Liu: yes, I've been using that, it just takes a lot of time, especially in cases where the first mention of a phrase isn't linked but a later one has been. I'd have thought it possible to create a script to make a note of all links duplicated (by virtue of your script), and search the article for all exact matches of linked article titles, linking the first mention, then delinking those subsequent. @Nardog: do you think this could work? Thanks all, ‑‑Neveselbert (talk·contribs·email) 15:10, 9 March 2024 (UTC)
It is possible, but I think that'd result in too many false positives. Often a phrase isn't stated exactly the same as the article title, so the actual first mention would be delinked. Just the automatic delinking part would be possible, though it'd be much more complicated if we needed to follow redirects. Aaron Liu (talk) 16:08, 9 March 2024 (UTC)
Yes, I thought about that, though I know that I would double-check the edit to make sure there were no false positives. I think following a redirect could be considered eventually, but for the moment, I think the script should just focus on exact matches to avoid any of these false positives, so if the phrase matches the title exactly, it's delinked. ‑‑Neveselbert (talk·contribs·email) 16:10, 9 March 2024 (UTC)
WP:LINKFIRST permits repeated links where helpful, and writing a script that determines whether something is helpful seems like an AI-hard problem. That said, I've seen articles that are absurdly overlinked, linking the same word repeatedly in a single sentence. Fixing was tedious; I think I've removed the lot with find/replace and then manually inserted a sane number of links, at least once.
Duplinks already ignores some links on the basis of placement. Using different colours to highlight, say the first and subsequent repeats of each link per major section, and say, links in lists, captions or tables where they duplicate the body text, would be doable. Would that help winnow down to the links that are most likely to be unhelpful? Then maybe one could look at the patterns, and decide, say, to remove all orange-highlighted links in the article automatically. Making this work for colourblind users might require a bit of extra effort. HLHJ (talk) 14:59, 24 May 2024 (UTC)
Works for me. I'd agree that it has kinda bad UI design I dunno how to fix though. You have to click the blue button to add the range. Aaron Liu (talk) 23:06, 6 June 2024 (UTC)
The checkbox appears for me on Vector 2022. Is there a specific page or revision range this is an issue on? Chlod (say hi!) 01:53, 7 June 2024 (UTC)
Hi! Do you think a script could be made that looks for |title= within references, and then changes everything inside it to either title case or sentence case? Lee Vilenski(talk • contribs)12:43, 7 June 2024 (UTC)
It would be possible, but I thought titles of sources were supposed to be capitalized as the source capitalizes it. Aaron Liu (talk) 12:50, 7 June 2024 (UTC)
from your browser console (in Firefox: right click anywhere on article history page > inspect > console tab).
The code simply hides the unblocked user contributions, so it will only show blocked users that were originally on the history page (a fraction of the last 500 edits should suffice, I assume). Ponor (talk) 08:28, 26 June 2024 (UTC)
@Ponor: I get to console tab and paste in your code to the box called "Filter output". Nothing changes in the contribution history. I'm using Bapaiya as it has a lot of blocked users. What am I doing wrong? --Bbb23 (talk) 13:10, 26 June 2024 (UTC)
Link to your test page: https://en.wikipedia.org/w/index.php?title=Bahuchara_Mata&action=history&useskin=vector. It works for me, with one caveat: if the edit summary includes a wikilink that mentions a blocked user, then that edit summary will also be included, even if the user is not blocked. For example, JalenFolf is not blocked, but he reverted an edit by blocked user Harihar Rawal, so that edit is included. Ponor could probably fix this by adding .history-user somewhere in the code above. –Novem Linguae (talk) 13:42, 26 June 2024 (UTC)
Oh, yes. Thanks, didn't have that case on the pages where I tested. So it's:
@Bbb23, it's not the "Filter output" field. There should be a prompt at the bottom of that window, i.e. console tab, where you can execute any code. This should be skin independent.
All of these things you're recommending are for FF developers, which I am not. I went a little deeper based on your link above, but I had to change developer settings, which I believe I did, and I still couldn't make the thing work. I'll wait for someone to come up with a simpler Wikipedia-based solution. If not, I'll live. Thanks for trying to help.--Bbb23 (talk) 13:45, 26 June 2024 (UTC)
There is one workflow that is absolutely not automated on Wikimedia sites: getting the rename history of a page. Digging through page logs looking for renaming records, especially when an article was renamed multiple times, often in a back and forth way, is terrible. A tool for that would be very helpful. Let's say, just a timeline with rename dates and new names.
75% of Wikipedia traffic is from mobile devices. Editors using a desktop device should be able to see how their version of a page will look on a mobile device before saving it.
This is to request a version of the Mobile sidebar preview widget that will show how the contents of the current edit window will look on a mobile device. Or, if this is simpler, for the existing Mobile sidebar preview widget to be enhanced so it works in edit mode, where it will display a mobile preview of the contents of the edit window. At some point, once fully tested and stable, it could be launched from the edit menu:
Script to show non-printing characters in edit fields
Is there a script that can show non-printing characters in edit fields? For example, Notepad++ can display many of these characters as black boxes with an abbreviation of the character's name (see e.g. File:Keylogger-software-logfile-example.jpg, which shows the BS character). In my quick testing, it appears that the C0 control codes do not survive a round-trip through the MediaWiki parser, but other non-printing characters do, and these characters show up surprisingly commonly in wikitext (the biggest offenders I've noticed are left-to-right marks and right-to-left marks, though I've come across a variety of them). Bonus points if the script can somehow distinguish various whitespace characters. 「ディノ奴千?!」☎ Dinoguy100012:58, 4 July 2024 (UTC)
Many wikis are using templates originally created on English Wikipedia. On my home wiki, we set Persian aliases for templates' parameters, but it's a long and time-consuming process for large templates like most of the infoboxes. I can really use any help for creating a script to easily set aliases for existing parameters. I've tried to start wriiting it here but got stuck as I am not a Javascript expert. Any help is really appreciated. JeeputerTalk22:46, 6 July 2024 (UTC)
@Aaron Liu: Can we use mw.loader.load() instead of importScript to load AutoEd? importScript tries to load "Wikipedia:AutoEd/core.js" from fawiki, which does not exist there, so... I get an error in my console when loading the script from enwiki. JeeputerTalk05:49, 9 July 2024 (UTC)
I don't think this exists as a script currently, but I was trying to view all edit filters using a user script to add a portlet to p-views. I've sort of started on it at User:EggRoll97/ExpandFilterView.js, and I've got a portlet to actually appear, but the problem I'm running into is that when I click the portlet, it goes to the desired link, but changes the link. Instead of going to Special:AbuseFilter/?deletedfilters=show&querypattern=&limit=5000 the portlet link goes to Special:AbuseFilter/%3Fdeletedfilters%3Dshow%26querypattern%3D%26limit%3D5000, which causes the page to only show the default amount of filters, instead of all 5000. Does anyone possibly have suggestions on what I might be missing? I've checked the guide, but I'm not seeing anything that might explain it. The other question I had was if it's possible to only have this portlet appear on Special:AbuseFilter, and to hide itself on other pages. EggRoll97(talk) 07:35, 20 July 2024 (UTC)
mw.util.getUrl('Special:AbuseFilter/',{deletedfilters:'show',querypattern:'',limit:'5000'}). Or you can just write '/w/index.php?title=Special:AbuseFilter/&deletedfilters=show&querypattern=&limit=5000' in place of getUrl(). Nardog (talk) 08:27, 20 July 2024 (UTC)
@Nardog and Jeeputer: Thanks! That does seem to fix the link problem, though I've tried the solution to the second question and it doesn't seem to be appearing on any page. I commented it out for now, but I'm not sure if I'm putting it in wrong. EggRoll97(talk) 20:02, 20 July 2024 (UTC)
Uncomment it, remove return and change !== to ===. return doesn't work because imported scripts execute in the global scope. Nardog (talk) 05:54, 21 July 2024 (UTC)
So, use this:
if(mw.config.get('wgPageName')==='Special:AbuseFilter'){mw.util.addPortletLink('p-views',mw.util.getUrl('Special:AbuseFilter/',{deletedfilters:'show',querypattern:'',limit:'5000'}),'Edit Filters','pt-expandedfilters','View all filters');}
@TheTechie Just a simple "respond" button with then additional buttons to select the template to change it to is all I would like to have :). Thanks so much for taking this one so quickly!! Cocobb8 (💬 talk • ✏️ contribs) 01:24, 30 May 2024 (UTC)
@TheTechie I don't mean to rush things at all, but I was just wondering what would be an estimated date for you to complete this script? Thanks so much! Cocobb8 (💬 talk • ✏️ contribs) 13:12, 6 June 2024 (UTC)
Not sure, kind of busy whilst trying to figure out an issue with the script and if it is possible (I'm trying to change the respond button to work for "help me" but the script has no comments, so some things are kind of obfuscated, per se). @Cocobb8thetechie@enwiki: ~/talk/$14:17, 6 June 2024 (UTC)
I'm not sure how possible this is, but it would be really nice to have a user script which adds a new icon to the top toolbar (where one's username is, notifications, watchlist, etc.) which could be customized using custom images + a custom link which it leads to. Thanks,NeuropolTalk12:48, 10 May 2024 (UTC)
This sounds feasible as it's just a portlet, but you may have to specify the link to the image yourself. Also, I'm assuming you don't want it to sticky. Aaron Liu (talk) 12:59, 10 May 2024 (UTC)
You can add a link that takes you to a page of your choice. See the "Add links at top for Tools page" section of User:Jonesey95/vector-2022.js. This makes a "Tools" link appear between "Sandbox" and "Preferences" for me. It's not an icon, but it is there any time I need it, on every page (after making the top bar sticky on all pages, of course). – Jonesey95 (talk) 20:36, 11 May 2024 (UTC)
Hello, the editor of this script has been retired for a long time. The script has an issue. While it includes a clear settings button, it lacks a confirmation box . Many times, I’ve accidentally clicked the clear settings button and lost my settings. Could someone please edit the script to add a confirmation box ? — Saqib (talk I contribs) 16:57, 15 August 2024 (UTC)
Precedent is to not edit userscripts unless they have a bug even if the user's been inactive. Thankfully, the script exposes every function globally. That means you can append the following to your common.js (probably after the part that loads the smart watchlist script) to work your magic:
SmartWatchlist.clearSettings=function(){if(confirm("Clear all of your settings?")){clearSettings.apply(this,arguments);}};
Aaron Liu, Thanks for your prompt help. Could you please check this if I’ve done it right, or let me know if I need to add it at line # 269 before I proceed with testing? And what is new JS interface? — Saqib (talk I contribs) 08:09, 16 August 2024 (UTC)
Erm, you're supposed to install scripts with importScript() (which will always fetch the latest versions) instead of copy-pasting it. But yeah, it should work.Nevermind my comment about the JS interface. I personally couldn't get the script to work even without the changes unless I selected "use non-JS interface". Aaron Liu (talk) 12:36, 16 August 2024 (UTC)
Yes you would. Like I said, the script exposes some functions so we could simply place the part I made after the importScript and it’ll work. Aaron Liu (talk) 14:29, 16 August 2024 (UTC)
This seems flawed in two ways: it would result in a ReferenceError because the global SmartWatchlist doesn't exist until the external script is loaded, which is asynchronous; and clearSettings is not a global so another ReferenceError when the new function actually runs. So you'd have to do something like:
mw.loader.getScript('/w/index.php?title=User:UncleDouggie/smart_watchlist.js&action=raw&ctype=text/javascript').then(function(){varclearSettings=SmartWatchlist.clearSettings;SmartWatchlist.clearSettings=function(){if(confirm("Clear all of your settings?")){clearSettings.apply(this,arguments);}};});
The code below extracts coordinates from Wikidata and prepares the wikitext for the coord template.
varqid=mw.config.get('wgWikibaseItemId')$.get('https://www.wikidata.org/w/rest.php/wikibase/v0/entities/items/'+qid).then(function(data){if(!data.statements.P625){alert('No coordinates on wikidata')return}varvalue=data.statements.P625[0].value.content;varlatitude=value.latitude;varlongitude=value.longitude;vartemplate='{{coord|'+latitude+'|N|'+longitude+'|W|display=inline,title}}';console.log(template)})
The problem is that I'm not much familiar with coordinates on Wikipedia and not sure if the values are correct and can be used on articles. For example, on Bidkhun-e Morghak this code outputs {{coord|29.11694444|N|57.88777778|W|display=inline,title}} which is a bit different from what is shown in the infobox and not sure if we should round (down/up?) those latitude and longitude values to N decimal places. I need some guidance on what the expected output looks like, then i will work on the rest of the script which includes inserting the output into the edit box. Thanks. JeeputerTalk00:25, 2 September 2024 (UTC)
I'm not sure why you say that WGS84 isn't always appropriate - Wikipedia:WikiProject Geographical coordinates#Geodetic system says "All coordinates specified through {{coord}} must be referenced to WGS84, or an equivalent datum." For a generic script, I feel like truncating to either 0.1′′ or 0.00001 precision should be fine, since those are the most precise but useful coordinates (someone can always make it less precise very easily if it's referring to, say, a town, but it's more work to make it more precise after the fact).
Also, does the Wikidata API always automatically output in dd.ddddd format, or is it sometimes in degrees-minutes-seconds? When I open the Wikidata page for the article you linked, it shows the coordinates in degrees-minutes-seconds for me. This would explain why the template on that article is formatted differently, since that's also in DMS.
And one last thing - I'm not sure why you've hard-baked N and W into the template output considering that's not a given. Either the coordinate numbers will have positive and negative possibilities (in which case the direction doesn't need to be specified) or they will have only positive possibilities and N/S and E/W have to be specified. Look at the documentation for {{coord}} for more info. Suntooooth, it/he (talk/contribs) 00:54, 2 September 2024 (UTC)
@Suntooooth: Not being familiar with coordinates is the answer, I'm a complete newbie in this context. :)
The property itself (P625, linked above) says that "only WGS84 coordinating system is supported at the moment". I think DMS is only the way it is parsed and shown there (hence the value itself is entered in DMS system). If you use the code above in your browser's console, the result is always in WGS83 system, giving lat and long values instead of degrees-minutes-seconds.
I read the documentation and I think something like {{coord|29.11694|57.88777|display=inline,title}} looks fine for a start. What do you think? JeeputerTalk20:35, 2 September 2024 (UTC)
That looks good, yeah! Check with some other articles to make sure specifying N/S and E/W isn't required (for example, check a location in South America - if specifying isn't required, both latitude and longitude will be negative, but if specifying is required they'll be positive). Suntooooth, it/he (talk/contribs) 20:47, 2 September 2024 (UTC)
@Suntooooth: I tested the code on Contando a féria and both latitude and longitude are negative. Looks good. I will continue writing the script and will let you know of the result. By the way I will round numbers to 5 decimal places. JeeputerTalk20:56, 2 September 2024 (UTC)
@Suntooooth: Coord Inserter is almost ready to use. There's an issue with copying the template to clipboard if |coord= not found. I will try to fix the issue tomorrow. But the script works fine with articles having the parameter (example edit).
@Aaron Liu: Thanks for your advice. it took me about an hour to find out how to insert the template into the text area. Btw can you help me with the problem I mentioned? I know that document.execCommand('copy') is deprecated, but there's a weird problem i can't understand. I can explain if you can help. Thanks. JeeputerTalk01:35, 3 September 2024 (UTC)
I ran the stuff in the console and got this:
document.execCommand(‘cut’/‘copy’) was denied because it was not called from inside a short running user-generated event handler.
Attach a click handler to the mw.notify that copies the thing.
<aside>The script you copied from seems really crufty. It creates an additional element for seemingly new reason and uses .setAttribute('value', new_url); instead of .value = new_url;.</aside> Aaron Liu (talk) 01:59, 3 September 2024 (UTC)
@Aaron Liu: The weird thing is that when I manually open the edit form of the page and then run the code there, the copy command works. I don't know how to use the clipboard API. Actually, I tried using the API, but as it asks for user's permission to read/write the clipboard, I think it's not the best solution. Attaching an event handler to mw.notify looks fine to me, I will test it. Thank you. JeeputerTalk10:54, 4 September 2024 (UTC)
And it's done, problem solved. The template syntax now gets inserted into the clipboard by clicking on the notification. Thank you. JeeputerTalk17:02, 4 September 2024 (UTC)
Oh, I really don't :P The scripts I've made have entirely been simple portlet links by following tutorials - I do computer science, but Javascript isn't one of the languages I know. Suntooooth, it/he (talk/contribs) 01:48, 3 September 2024 (UTC)
That seems to be what is the cause. I ran into a page where the timestamp link doesn’t work, and the user script is able to work. @Krinkle: Is there a script that can optionally disable that? 1989 (talk) 21:53, 18 August 2024 (UTC)
It's never a good idea to use something that's not going to be updated much. Like I said, I'd recommend Convenient Discussions (the JWBTH/CD link below). Aaron Liu (talk) 22:24, 18 August 2024 (UTC)
Check the oldest 10 edit summaries of the article for the word "translat" (i.e. translation, translated, etc.), case insensitive.
If 2 is present, check the wikicode of the talk page for the word "translat", case insensitive.
If 2 is present and 3 is not present, display a warning at the top of the page that says "Warning: This article is likely an unattributed translation. Please consider adding {{Translated from}} to the talk page." If you'd like an example of how I usually display page warnings in my user scripts, see User:Novem Linguae/Scripts/DetectG4G5.js, which displays a red bar at the top.
Undo any of your changes by double-clicking them in the preview window
Would it be possible to implement a feature similar to the one in AutoWikiBrowser, where you can preview your changes and then easily undo any of them by double-clicking in the preview window? I didn't see this feature available as a userscript. It would be very helpful, especially when using tools like Wikipedia:AutoEd for semi-automated editing, where multiple changes are made to a page and you sometimes need to quickly undo specific edits without having to scroll back and forth to the editing box. 2001:14BA:9C40:0:B1BC:5F0A:4848:2904 (talk) 22:27, 1 September 2024 (UTC)
Now that I think about it, I also really like another similar feature in AWB, where you can click (once) a change in the preview window, and it will automatically scroll to the corresponding line in the editing box, i.e., places your cursor at that line... :D (OP) 2001:14BA:9C40:0:21F1:9332:6D2D:A0BA (talk) 21:00, 20 September 2024 (UTC)
The script is used to create redirects to a given page. See for example wikispecies:Epipactis helleborine subsp. helleborine. When using the script, a first click on a toolbar link labeled "Create Redirects" highlights all potential redirects to be created; in this case, all the names in italics listed under the heading "Synonyms" are highlighted (e.g., Serapias helleborine var. latifolia, Cymbidium latifolium, etc.). It is possible to deselect some of them by clicking on the highlighted names. A second click on the link will then create the redirects to wikispecies:Epipactis helleborine subsp. helleborine.
When using the script, it no longer highlights potential redirects. Could someone help us understand why this script is no longer working? Thanks in advance, Korg (talk) 11:41, 3 October 2024 (UTC)