Expand all categories of a Wikipedia category tree

Deadly 提交于 2019-12-14 02:43:18

问题


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?


回答1:


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?



来源:https://stackoverflow.com/questions/12494905/expand-all-categories-of-a-wikipedia-category-tree

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!