Expand all categories of a Wikipedia category tree Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Expand all categories of a Wikipedia category tree without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I am trying to do this via the Web Console (using Firefox, but I am willing to change if necessary of course).

What I want to do is to basically click all the “plus” signs on a page at once. For an example see here: http://de.wikipedia.org/wiki/Kategorie:Volkswirtschaftslehre (excuse me for linking a german site, but the english wikipedia seems to be employing a different system now, and I need to do it on the German one…)

This is how far I have gotten: When I enter

var = document.getElementsByClassName("CategoryTreeToggle");

I get the variable test that includes all the elements of CategoryTreeToggle. However, apparently there is no onclick routine defined for those.

Can anybody please help me and tell me where to go from there?


MediaWiki uses jQuery, which makes this easy:

$( '.CategoryTreeToggle' ).click();

Or, if you only want to click those toggles that are not already expanded:

$( '.CategoryTreeToggle[title="ausklappen"]' ).click();

But wouldn’t it be easier to just use CatScan?

We are here to answer your question about Expand all categories of a Wikipedia category tree - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji