Skip to content

Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.

Improved injectJQuery() docs

Jan Curn9ef8aa4b2710
diff --git a/src/puppeteer_utils.js b/src/puppeteer_utils.js
index ec6f53e5c..65c08c32f 100644
--- a/src/puppeteer_utils.js
+++ b/src/puppeteer_utils.js
@@ -82,6 +82,18 @@ const injectFile = async (page, filePath) => {
* Beware that the injected jQuery object will be set to the `window.$` variable and thus it might cause conflicts with
* libraries included by the page that use the same variable (e.g. another version of jQuery).
*
+ * Example usage:
+ * ```javascript
+ * await Apify.utils.puppeteer.injectJQuery(page);
+ * const title = await page.evaluate(() => {
+ * return $('head title').text();
+ * });
+ * ```
+ *
+ * Note that `injectJQuery()` does not affect the Puppeteer's
+ * <a href="https://pptr.dev/#?product=Puppeteer&show=api-pageselector" target="_blank"><code>Page.$()</code></a>
+ * function in any way.
+ *
* @param {Page} page
* Puppeteer <a href="https://pptr.dev/#?product=Puppeteer&show=api-class-page" target="_blank"><code>Page</code></a> object.
* @return {Promise}