How can I create a Chrome bookmarklet to expand more examples links so I don't have to click each link separately:
http://www.learnersdictionary.com/definition/take
The bookmarklet should open all more examples links on a single click.
-
Are you asking how to make a bookmarklet or how to select and click on each *more examples* button – Andria Jul 07 '18 at 06:50
-
@chbchb55: How to make a bookmarklet to expand all the page links on a single click. – Jul 07 '18 at 06:51
2 Answers
.querySelectorAll
and .click
To click on all of these buttons, first, you need to know how to select them.
Upon inspection, the class
of the buttons' parents are vi_more
. So, to target the a
directly inside them we can do document.querySelectorAll('.vi_more>a')
. For more on document.querySelectorAll
, visit the MDN Web Docs.
After obtaining the NodeList
filled instances of HTMLAnchorElement
, we can iterate over them with .forEach
and click each one of them with link.click()
. For more on HTMLElement.click
, visit the MDN Web Docs.
Here is what your bookmarklet could look like:
javascript:document.querySelectorAll('.vi_more>a').forEach(link => link.click())

- 4,712
- 2
- 22
- 38
I assume you want to create a Chrome extension.
You would want to create a background script to capture the click on your chrome extension icon and then send a window message to your content script, which would be added to the page code. Then you can get the page elements you need, in this case the links and simulate a click on them.
You can get started with Chrome Extensions here.

- 113
- 1
- 6
-
"I assume you want to create a Chrome extension." Thanks for the answer, but as I said I need a Chrome [bookmarklet](https://en.wikipedia.org/wiki/Bookmarklet). – Jul 07 '18 at 07:00
-