# Right-click Google Scholar Search

{% hint style="info" %}
🍎 Before you begin this tutorial, make sure you've completed the [Developer Quick Start Guide](https://docs.pixiebrix.com/quick-start/mod-developer).
{% endhint %}

In this tutorial, we'll automate a simple process: searching for the text you highlight in Google Scholar.

We'll use this [PBS](https://www.pbs.org/wnet/americanmasters/duke-ellington-about-duke-ellington/586/) page to develop our workflow, but afterward, you’ll be able to use this on any website.

✅Want to start using this mod rather than building it from scratch? You can [activate this mod](https://www.pixiebrix.com/marketplace/6754635f-ce81-4829-8349-90c831c1b7c5/search-highlighted-text-in-google-scholar/) with a few clicks from our marketplace.

### 1. Configure a Right-click Button <a href="#block-979b8c0590424c40bb35288d17f9cf62" id="block-979b8c0590424c40bb35288d17f9cf62"></a>

#### Open the Page Editor <a href="#block-2b7574dc7a024dcdbf878fc6b4bbdef1" id="block-2b7574dc7a024dcdbf878fc6b4bbdef1"></a>

Start by navigating your browser to this PBS article: [A Duke Named Ellington](https://www.pbs.org/wnet/americanmasters/duke-ellington-about-duke-ellington/586/). Then, [open the PixieBrix Page Editor](https://docs.pixiebrix.com/platform-overview/page-editor/open-the-page-editor).

#### Grant Access <a href="#block-28b92df4fccf4068beb0992af0e7928c" id="block-28b92df4fccf4068beb0992af0e7928c"></a>

The first time you open the Page Editor on a new webpage, you need to grant PixieBrix access to the page. You can grant permanent access by either:

* Clicking **Grant Permanent Access**, or
* Granting temporary access by clicking on the PixieBrix extension in the Chrome Extensions dropdown and then refreshing the page

![image](https://images.spr.so/cdn-cgi/imagedelivery/j42No7y-dcokJuNgXeA0ig/95e38dc4-91bf-43b7-b9bc-fa345ebfad82/Untitled/w=640,quality=80)

{% hint style="info" %}
🚨If you had the Page Editor open before navigating to the PBS page, you'd need to close it by clicking the X in the top right corner and re-open it to provide access.
{% endhint %}

#### Configure a Context Menu Item <a href="#block-ffcaf88f4edf48b18cf2628894d9328d" id="block-ffcaf88f4edf48b18cf2628894d9328d"></a>

* Click **New Mod** in the top left of the Page Editor and choose Context Menu, and select **Context Menu**<br>

  <figure><img src="https://2274778196-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fq123bF1HPQPV35s5vHa1%2Fuploads%2F6L8nY0ix1w4kwfQ8GZ1e%2FCleanShot%202024-10-16%20at%2009.31.38.png?alt=media&#x26;token=f3459ffd-b13d-4c99-964d-65654d11fa3c" alt=""><figcaption></figcaption></figure>
* In the Title field, replace "Context Menu Item" with "%s - Google Scholar"

{% hint style="info" %}
💡 The "%s" portion will configure the caption to dynamically change based on the text you highlight. Note this convention is different than the mustache braces {{ used in other places in PixieBrix. It's because *Chrome* is filling in the selected text, not PixieBrix.
{% endhint %}

To test your context menu configuration:

1. Highlight Duke Ellington on the webpage
2. Right click to expand the context menu. It should look like this

   <figure><img src="https://images.spr.so/cdn-cgi/imagedelivery/j42No7y-dcokJuNgXeA0ig/18d35105-87cf-4ef6-bb9e-eb128e468370/Untitled/w=3840,quality=80" alt=""><figcaption></figcaption></figure>

#### Configure Where the Context Menu Appears <a href="#block-e4d6fb17ece1402aa7ae2110a722464d" id="block-e4d6fb17ece1402aa7ae2110a722464d"></a>

* In the Sites field, click **All URLs**. This tells PixieBrix to show the context menu item on any webpage you visit

<figure><img src="https://images.spr.so/cdn-cgi/imagedelivery/j42No7y-dcokJuNgXeA0ig/a784ae0b-fbfb-4fc0-a267-7491f2f76d48/Untitled/w=3840,quality=80" alt=""><figcaption></figcaption></figure>

* Scroll down to the **Advanced Configuration**. In the Advanced Permission section, click **All URLs**. This gives PixieBrix access to a page without you first clicking the context menu

### 2. Search Google Scholar <a href="#block-b856e7bcdb804251b79521105138456c" id="block-b856e7bcdb804251b79521105138456c"></a>

#### Define Your Search Parameters <a href="#block-273b8fdb288e42b7bd97348c86f3a53e" id="block-273b8fdb288e42b7bd97348c86f3a53e"></a>

Next, we'll figure out how to construct a search URL for Google Scholar.

In a separate tab, go to the [Google Scholar](https://scholar.google.com/) homepage and search for "Louis Armstrong"

![](data:image/svg+xml,%3csvg%20xmlns=%27http://www.w3.org/2000/svg%27%20version=%271.1%27%20width=%27480%27%20height=%27155.144157814871%27/%3e)![image](https://images.spr.so/cdn-cgi/imagedelivery/j42No7y-dcokJuNgXeA0ig/88eb34ff-6a92-4b33-81e3-94e57497e036/Screen_Shot_2021-06-21_at_7.10.40_PM/w=1080,quality=80)

After you click "Enter," you will be taken to the search results page, which has this URL:

Copy the following:

```javascript
https://scholar.google.com/scholar?hl=en&as_sdt=0%2C33&q=Louis+Armstrong&btnG=
```

Toward the end of the URL, you will see `q=Louis+Armstrong`. Google Scholar uses "q" as the search parameter.

#### Configure the Search <a href="#block-a555af29196a4914b93791bc6b0d91b3" id="block-a555af29196a4914b93791bc6b0d91b3"></a>

We'll first need to add the “Open a tab” brick. Click the **+** icon to add a brick.

![image](https://images.spr.so/cdn-cgi/imagedelivery/j42No7y-dcokJuNgXeA0ig/f21a6830-3988-431d-afe7-d658b67472b4/Untitled/w=828,quality=80)

Search "open a tab" and choose it

<figure><img src="https://images.spr.so/cdn-cgi/imagedelivery/j42No7y-dcokJuNgXeA0ig/cdfcd949-213f-4d52-8a75-fcab02940166/Untitled/w=3840,quality=80" alt=""><figcaption></figcaption></figure>

In the URL, put `https://scholar.google.com/scholar?`

In the params field, click the arrow next to the “**x**” at the end of the row, then select “**Object properties**”

Click **Add a Property**. Delete `property` and replace it with `q`, the search parameter we identified in the URL.

In the Value text box type `@input.selectionText`

<figure><img src="https://images.spr.so/cdn-cgi/imagedelivery/j42No7y-dcokJuNgXeA0ig/16470f40-8000-41dd-b863-04ac06f60f72/Untitled/w=3840,quality=80" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Context Menus always include a "Context menu reader" that provides the `documentUrl` and information about the selected element. In our case, `selectionText` will provide the selected text
{% endhint %}

### 3. Test Your Search <a href="#block-bb34f62c330a45efb8d8db9e3e609073" id="block-bb34f62c330a45efb8d8db9e3e609073"></a>

To test your Search, highlight "Duke Ellington" in the PBS article, and click. A new tab should open to the following URL: <https://scholar.google.com/scholar?q=Duke+Ellington>. Click **Save** in the Page Editor, and try different searches on different web pages.

Clicking the **Save** icon will bring up a modal for [packaging-a-mod](https://docs.pixiebrix.com/developing-mods/sharing-mods/packaging-a-mod "mention"). Set an alias if you haven't already and give the mod a unique ID and description, then click **Create**.

{% hint style="info" %}
🙋Need some help with building? [Head over to the Slack Community](https://slack.pixiebrix.com/), and we’ll gladly help you!
{% endhint %}
