MediaWiki talk:Gadget-HotCat.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search


Could a warning popup appear when adding a DAB cat while using HotCat?[edit]

The problem: If you try to add a Disambiguation category (DAB category) to a file or category using HotCat, you cannot see that it is a DAB category. It is undesirable to have files or categories in DAB categories. So a lot of DAB categories have files and/or subcategories, see Category:Non-empty disambiguation categories (not only due to HotCat). This problem is being discussed on Commons:Village pump#How to make a structural solution for not empty disambigious pages?, issue 2.

Possible solution: If you try to add a DAB cat via the edit tab, a warning pop-up appears. Could such a warning pop-up also appear when you try to add a DAB cat via HotCat? JopkeB (talk) 04:55, 20 October 2022 (UTC)Reply[reply]

Yes, it’s technically possible. The question is only whether there will be someone who implements it. 🙂 —Tacsipacsi (talk) 22:11, 20 October 2022 (UTC)Reply[reply]
How can we reach people who might implement this request? JopkeB (talk) 04:27, 21 October 2022 (UTC)Reply[reply]

I have made a proposal on the Wishlist 2023, see meta:Community Wishlist Survey 2023/Multimedia and Commons#A warning popup when adding a DAB cat while using HotCat. --JopkeB (talk) 05:25, 25 January 2023 (UTC)Reply[reply]

we actually dont need a warning.--RZuo (talk) 19:55, 20 March 2023 (UTC)Reply[reply]
RZuo: Why do we not need a warning? It happens to me regularly that I add unintentionally a DAB category using HotCat, and many more editors do so. I would like to prevent that from happening. --JopkeB (talk) 05:28, 21 March 2023 (UTC)Reply[reply]
It is requested that an edit or modification be made to this protected page.
Administrators: Please apply <nowiki> or {{Tl}} to the tag after the request is fulfilled.

Pigsonthewing

change line 87 to disambig_category: 'Disambiguation categories',
because some jokers did these without announcing them to the whole commons community https://commons.wikimedia.org/w/index.php?title=Template:Disambig&diff=prev&oldid=582141057 https://commons.wikimedia.org/w/index.php?diff=582136498 . RZuo (talk) 19:55, 20 March 2023 (UTC)Reply[reply]
@Jon (WMF) could you please help with changing line 87? thx! RZuo (talk) 08:12, 21 May 2023 (UTC)Reply[reply]
I’ll try to summarize the status of this edit request as I understand it:
  • HotCat has a feature to warn when adding categories that are marked as disambiguation categories.
  • The feature, I assume, used to work as intended (and as requested above) on Commons.
  • Later, Category:Disambiguation categories was split off from Category:Disambiguation on Commons, which broke the feature.
  • For a while, nobody realized this had happened.
  • People started to realize again that this would be a useful feature to have; this edit request was made, and eventually even added to the community wishlist survey, without (apparently?) anybody realizing (or at least mentioning) that the feature already existed and used to work.
  • Either Category:Disambiguation categories needs to be merged back into Category:Disambiguation on Commons, or HotCat needs to use Category:Disambiguation categories rather than Category:Disambiguation as the marker category on Commons.
“On Commons” is a key phrase in that last bullet point – I assume that we should not change this on other wikis. But I don’t understand the HotCat config system well enough to judge whether the edit suggested by RZuo would have that effect or not; therefore, I won’t be applying this edit request at this time. But I hope that this clarification enables some other interface admin more familiar with HotCat to fix the situation. Lucas Werkmeister (talk) 20:54, 5 November 2023 (UTC)Reply[reply]
@Lucas Werkmeister they always have localised settings "on other wikis", because except enwp all others dont write in english. for example, Category:Disambiguation pages (Q1982926).
line 42 Localize these messages to the main language of your wiki.
lines 83-85 are the instructions for disambig_category.
disambig_category is used only in lines 991 and 997. i assume that's the part of the dab functionality. RZuo (talk) 21:04, 5 November 2023 (UTC)Reply[reply]

Cursor jumping to the end (discussion restored from Archive 04)[edit]

I keep having trouble with the cursor jumping to the end of the input. It seems that whenever it automatically uppercases the first letter or removes leading whitespace/underscores, it moves the cursor to the end regardless of where the cursor was before. For example, if the current name is "Example" and the cursor is at the beginning:

  • Pressing "a" turns into "AExample"
  • Pressing the delete key turns into "Xample"
  • Pasting a lowercase word like "another" turns into "AnotherExample"
  • Pressing the space bar removes the space

and then the cursor moves to the end.

It looks like the problem is caused by sanitizeInput and makeActive in the textchange function. The former changes the capitalisation and strips leading whitespace/underscores, and the latter moves the cursor to the end if actualValue.indexOf( expectedInput ) is false, which is the case when the values are the same (indexOf is 0) or when the capitalisation is different (indexOf is -1).

- Nikki (talk) 18:18, 27 July 2021 (UTC)Reply[reply]

+1, this bug is annoying. Let's hope it will be solved eventually. --Enyavar (talk) 13:58, 27 January 2022 (UTC)Reply[reply]
+1 indeed! -- Tuválkin 22:07, 28 January 2022 (UTC)Reply[reply]
+1 Can we please get some action on this - I mistakenly long thought it was an esoteric 'feature' PeterWD (talk) 11:01, 21 May 2022 (UTC)Reply[reply]
+1 This bug is indeed annoying. Please try to solve this. (Other than that it's a great tool!) JopkeB (talk) 04:18, 20 October 2022 (UTC)Reply[reply]

I have restored this topic discussion, that was archived by archiveBot on 24April2023. The historic bug remains unresolved, and I hope that someone can help fix it.PeterWD (talk) 08:13, 1 June 2023 (UTC)Reply[reply]

{{Edit request}} About 2100 lines into the script the following line of code can be found:

if ( this.text.value !== null && this.text.value !== v ) this.text.value = v;

This is what makes the cursor jump to the end. To avoid this please change it as follows:

if ( this.text.value !== null && this.text.value !== v ) {
	var cursorPos = this.text.selectionStart;
	this.text.value = v;
	this.text.setSelectionRange( cursorPos, cursorPos );
}

Requested via de:WP:Reparatursommer#HotCat. Additional notes: Works in all supported browsers. You might wonder why I don't use selectionEnd, i.e. why I collapse the selection to a single cursor position. This is intentional so the user doesn't overwrite more and more stuff when they continue typing. --Thiemo Kreuz (WMDE) (talk) 14:04, 25 September 2023 (UTC)Reply[reply]

✓ Done@Nikki, Enyavar, Tuvalkin, PeterWD, Ain92, and JopkeB: Should be fixed now, sorry for the delay. (I mainly react to edit requests via watching the category, so if the template is added or removed to a page that already has another edit request so that the category doesn’t actually change, I’m liable to miss it, I’m afraid. No idea if other interface admins deal with this differently.) --Lucas Werkmeister (talk) 21:46, 2 November 2023 (UTC)Reply[reply]
looks good at first test, thanks a lot! --Enyavar (talk) 21:54, 2 November 2023 (UTC)Reply[reply]
Thanks, it works now good. JopkeB (talk) 03:35, 3 November 2023 (UTC)Reply[reply]

Language suffix on translatable pages[edit]

Dear maintainers,

For multilingual wikis, it would be nice HotCat automatically adds {{#translations:}} after category name when someone adds a category on a translatable page.

I don’t know how to efficiently check whether the page is translatable from JS. -- Pols12 (talk) 14:38, 17 June 2023 (UTC)Reply[reply]

It’s quite easy to check whether the current page is translatable: mw.config.get('wgTranslatePageTranslation') === 'source'. However, {{#translation:}} (in singular!) should only be used if the category itself is also translatable (there may be categories that contain too few pages to make it sense to translate them), which may not be this easy and efficient. (However, efficiency is not that important for the second check – it runs only in the fraction of cases when the gadget is used on a translatable page.) —Tacsipacsi (talk) 19:09, 17 June 2023 (UTC)Reply[reply]
On Meta-Wiki, translation pages should ever been located in translation categories, even for small categories. I thought those recommendations were shared through WM multilingual wikis. -- Pols12 (talk) 23:11, 17 June 2023 (UTC)Reply[reply]
Customs slightly differ between wikis (e.g. the usage of /Translations categories is AFAIK unique to Meta), but even as a Meta translation administrator, I disagree that categories for translatable pages should always, without exception, be translatable. For example, m:Category:Photography contains several pages, so it makes sense to have a category, but only a single one of them is translatable, so creating language-specific categories would mean none of the language-specific categories could contain more than one page, no matter how much of Meta content is translated into that language. Creating categories that don’t have the potential to group similar pages (because there’s only one “similar” page) doesn’t help navigation but increases the number of pages that need to be created, checked for vandalism etc. In wikis that have just a handful of translatable pages (e.g. oldwikisource: has as few as 22 translatable pages, of which zero are categories), the probability of a such cases is even higher. —Tacsipacsi (talk) 20:29, 18 June 2023 (UTC)Reply[reply]
Automatically adding #translation: could create some issues, so I understand it was a bad idea.
However (out of topic), I disagree with your point of view: I don’t use #translation: expecting the category pages to be translated, I only want to clean the main category tree. In your example, m:Category:Photography, it is hard to notice “Whose Knowledge?/VisibleWikiWomen/2018” because it is lost in a forest of translation pages. -- Pols12 (talk) 21:47, 18 June 2023 (UTC)Reply[reply]
@Pols12: But if m:Whose Knowledge?/VisibleWikiWomen/ar was in m:Category:Photography/ar, one had no way to find m:Category:Photography or any of its parent categories without manually editing the URL (for which one needs to know that that’s the solution, which is far from being obvious). —Tacsipacsi (talk) 00:13, 5 July 2023 (UTC)Reply[reply]
Right. I didn’t think about this issue. So, in my opinion, translation pages should not be categorized, but display source page categories instead. -- Pols12 (talk) 09:37, 5 July 2023 (UTC)Reply[reply]

Utilize `wpIgnoreBlankSummary`[edit]

{{Edit request}} When the gadget is used with autocommit disabled, it displays the diff, showing changes that are to be saved. The summary field is pre-filled by HotCat and usually there's no need to alter it. However, MediaWiki prompts user that he hasn't entered the summary. This can be avoided if HotCat sends wpIgnoreBlankSummary=1 on its POST request to display the diff (documentation here). I'd be grateful if that field gets incorporated to the gadget (in function createCommitForm as far I as understand the code). Msz2001 (talk) 15:07, 21 June 2023 (UTC)Reply[reply]

@Msz2001: I looked into this a bit, but I’m not very familiar with HotCat and wasn’t able to reproduce the issue you described. When I disabled autocommit, removing a category from File:PNG_Test.png sent me to the edit form (which I think is the expected behavior of disabling autocommit?), and then I was able to directly submit the edit there (without touching any of the fields) – MediaWiki didn’t complain about the edit summary, as (IIUC) you described above. Can you describe the steps to reproduce in more detail for me? Then I’ll try to see if wpIgnoreBlankSummary=1 helps. Lucas Werkmeister (talk) 22:32, 3 November 2023 (UTC)Reply[reply]
@Lucas Werkmeister: You need to enable Prompt me when entering a blank edit summary (or the default undo summary) in your preferences. —Tacsipacsi (talk) 11:27, 5 November 2023 (UTC)Reply[reply]
@Tacsipacsi: Thanks – I’ve tried that, but still got the same behavior…
What I did:
  1. enabled Prompt me when entering a blank edit summary (or the default undo summary) in my preferences
  2. added window.hotcat_no_autocommit = true; to my common.js
  3. went to File: PNG Test.png
  4. clicked the “-” button after Category:ISA test
  5. on the resulting edit form, pressed Alt+Shift+S (s accesskey, i.e. save / publish)
and it was saved directly. Lucas Werkmeister (talk) 14:38, 5 November 2023 (UTC)Reply[reply]
@Lucas Werkmeister: Oh, I just realized – it’s not a problem on Commons, probably because the using [[Help:Gadget-HotCat|HotCat]] part of the edit summary is replaced by a tag, and removing that bit from the summary apparently counts as not using the “default undo summary”. Either you need to unset window.HotCat.changeTag, or test on a wiki where it’s not set (I believe it’s not set on dewiki, and I know for sure that it’s not set on huwiki). —Tacsipacsi (talk) 17:51, 5 November 2023 (UTC)Reply[reply]
@Tacsipacsi: I tried to reproduce the issue on dewiki (w:de:Benutzer:Lucas Werkmeister/common.js) but still wasn’t successful. If you can reproduce it on huwiki, and are able to test an edited version of the gadget yourself (if you can figure out where the wpIgnoreBlankSummary goes), I’d be willing to deploy that even if I can’t test the fix myself (assuming that the code change should be reasonably small). Lucas Werkmeister (talk) 19:09, 5 November 2023 (UTC)Reply[reply]
@Lucas Werkmeister Hi and sorry for not responding earlier. The request originally came from one of plwiki community members. Since we import HotCat from Commons, I posted it here (but, my bad, I didn't check that on Commons the summary logic works a bit different). The intent was to add another hidden input field to createCommitForm function (from line 3132). The modified version of HotCat (just forked) can be found on w:pl:Wikipedysta:Msz2001/HotCat.js. The only change is addition of line 3151. Msz2001 (talk) 20:09, 5 November 2023 (UTC)Reply[reply]
I see, thanks – I’m assuming that pl:Special:Diff/71715787 represents a successful test of the edited version. ✓ Done. --Lucas Werkmeister (talk) 20:17, 5 November 2023 (UTC)Reply[reply]
Yeah, exactly (didn't prompt for the summary, so went as expected after the changes). Msz2001 (talk) 20:21, 5 November 2023 (UTC)Reply[reply]

Enforced "advanced mode"[edit]

Hei hei! I reported an issue wrongly on Phabricator about this (details: phab:T340954), but due to gadget loading with the new mobile update, HotCat enforces "advanced mode" on mobile Wikipedia pages at least. Is there any way to prevent this from happening other than deactivating the gadget? 🤔 EdoAug (talk) 18:52, 3 July 2023 (UTC)Reply[reply]

Fixed now, apparently! EdoAug (talk) 23:50, 4 July 2023 (UTC)Reply[reply]
On a related note, the error message is not clear on what "AMC mode" is, or how you enable it. It took me several steps of Googling to figure out that it stands for "Advanced mobile contributions". Can we get an explanation added to the error (or at least a link to mw:Reading/Web/Advanced mobile contributions)? --Iiii I I I (talk) 03:00, 16 September 2023 (UTC)Reply[reply]

Enter key[edit]

Hi, I'm finding that when I hit enter after typing in a category the page refreshes but the category isn't saved. This doesn't happen when I click the 'OK' button. Blythwood (talk) 07:58, 25 September 2023 (UTC)Reply[reply]

@Blythwood: Not unexpected. When you are typing in the category text area you will see that the text field is highlighted, which is where an "enter" would apply, and as that doesn't make sense so nothing occurs. If you instead hit your tab key, you will see that the highlight will move from the text field to the OK button, from which the enter key will action that function. Two fields cannot be active at the same time, and the search ahead, selection function of the list in HotCat is the priority.  — billinghurst sDrewth 11:16, 25 September 2023 (UTC)Reply[reply]

Press somekey to add another category?[edit]

Hi! Is there any key (or key combination) to OK the current inputbox and show a new inputbox to enter another category? It is useful for new pages. --Lopullinen 08:53, 14 October 2023 (UTC)Reply[reply]

Intercepting HotCat to set watchlist expiry period[edit]

When using JavaScript to intercept the page edit that HotCat makes, is it possible to set the watchlist expiry period with code? I use a script that presets this for edits made with VE, but it would be nice if I could have HotCat work in a similar manner. StefenTower (talk) 22:53, 16 October 2023 (UTC)Reply[reply]

TypeError: ip.insertRow is not a function[edit]

@Jon (WMF): Why did you include && ip in this hotfix? If it was falsy, the function has already done an early return at line 2868.

By the way, I think the proper fix was removing || document.getElementById( 'wpDestFile' ) in line 2863 – #wpDestFile is an <input>, every other code path should find <table>s (and HTMLTableElement should have an insertRow method in all major browsers released in the past nine years). —Tacsipacsi (talk) 10:43, 28 October 2023 (UTC)Reply[reply]

HotCat adds page status and does strange things in de.wikisource[edit]

I created a new project-category for a text where this has been forgotten. Then I added the category via HotCat to the pages. Then something strange happened: The header and footer got shifted into the main textbox and an additional "Seitenstatus" was added... Both shouldn't have happened. Can someone look into it? Example: Diff-link --Jenne1504 (talk) 08:26, 30 November 2023 (UTC)Reply[reply]

This is the internal representation of a Page-namespace page: it begins with a <noinclude> section containing the <pagequality> element and the header, then the page body, then the footer in another <noinclude>. HotCat inserted the category below this <noinclude> section, which is certainly not good (the <noinclude> section should be at the very end).
Honestly I don’t see the point in categorizing Page-namespace pages (categories should be placed on the mainspace pages transcluding these Page-namespace pages), so I’d probably just disable HotCat in the Page namespace instead of putting probably considerable effort into fixing it. (But if anyone else thinks it’s worth being fixed, I’m not opposed to that.) —Tacsipacsi (talk) 21:20, 30 November 2023 (UTC)Reply[reply]
They are categorized so that one can get a quick overview about the status of a project (petscan-links are automatically put on every index-page; but that only works if all pages from a project are in one project-category. The page-category is added automatically if the category is put on the index page. But has to be added if someone forget to fill the field… Jenne1504 (talk) 21:54, 1 December 2023 (UTC)Reply[reply]

Deleting a category sortkey does not work[edit]

If I were to use HotCat to change "Abc|Foo" (Category:Abc, sortkey Foo) to "Abc" (Category:Abc, no sortkey), the edit would seemingly work, but no change would be made. Could someone please fix this? Thanks! —Ivi104 22:31, 30 December 2023 (UTC)Reply[reply]

@Ivi104 you need to leave "Abc|" in the input field and then click ok. if you enter "Abc", the gadget thinks you didnt modify the sortkey. "Abc|" means sortkey is changed to nothing. RZuo (talk) 12:52, 31 December 2023 (UTC)Reply[reply]

If one category is a redirect, other categories are not saved[edit]

Hi,
When you open a file in Commons and try to add two or more categories one of which is a redirect, only the redirect is added and other categories are ignored. Michgrig (talk) 19:11, 4 January 2024 (UTC)Reply[reply]

Can't scroll list if bangs into top[edit]

Here the user cannot scroll the list down. It has banged into the top...

The user tugs on the grey scrollbar, but alas...

Yes, the user has chosen to put the categories at the top of the page.

Jidanni (talk) 07:49, 7 January 2024 (UTC)Reply[reply]

Allow tool to operate on red categories (that don't exist yet.)[edit]

Let's say we click a red category link. OK, now we are editing a category that doesn't exist yet. It would be great if the tool appeared to help us assign this red category page to categories, so it would no longer be red. Currently one must manually place the first category in the category and save it to get the ball rolling, if you know what I mean. Jidanni (talk) 07:38, 14 January 2024 (UTC)Reply[reply]

The gadget works only in read view. If you enter the read view by exiting the editor (Cancel button in the wikitext editor, Escape key in the visual editor), you’ll be able to use HotCat to create categories. —Tacsipacsi (talk) 07:44, 15 January 2024 (UTC)Reply[reply]

Link from gadget itself[edit]

There should be a little link to this discussion area from the gadget itself.

Currently we must remember it is a gadget. And then we must look in our preferences under gadgets, and try to remember the name of this tool, to find the link.

I'm saying that right there, after the list of categories and + - signs, on every wiki page, there should be a link, to more information about the tool, including this discussion area. Jidanni (talk) 07:42, 14 January 2024 (UTC)Reply[reply]

Adds 10+ seconds of load time to Wikitionary pages[edit]

When I open Wiktionary in Chrome on a definition such as goose when I'm logged in with HotCat enabled, there's a good 10+ seconds after I open the page where I can't click on any links. Opening up the Performance tab in the Dev Tools I can see that it's running find_category for literally 10.8 seconds, the last call in the call graph is en_wiktionary_category_name_detect twice for 5 seconds each. Disabling HotCat fixes the issue. Akeosnhaoe (talk) 20:28, 6 February 2024 (UTC)Reply[reply]

Feature request: Ignore square brackets[edit]

If a user enters (e.g. by pasting from the clipboard) [[Category:Foobar]], HotCat should understand this as intended to be Foobar (as it does when the user enters Category:Foobar). Andy Mabbett (Pigsonthewing); Talk to Andy; Andy's edits 19:07, 8 February 2024 (UTC)Reply[reply]