# Abitlity to INJECT scripts in Head or Body

This PR adds the ability to inject JS scripts at the end of the `<head>` section instead of the `<body>` section, which may be useful to execute the script before the page finishes loading. For instance, recently, I tried to deactivate a button but since the page took quite some time to load completely, most users could still click on the button because my injected script had not yet been executed. The default behavior is still to inject at the bottom of the body section but I added an optional `location` parameter in `js_inject` to pick 'head' or 'body':

***Phishlet snippet:***

```
js_inject:
  - trigger_domains: ["lab.evilginx.dev"]
    trigger_paths: ["/"]
    location: "head"
    script: |
      function lp() {
        checkbox = document.querySelector("#rememberCheck");
        if (checkbox != null) {
          checkbox.checked = true;
          return;
        }
        setTimeout(lp, 100);
      }
      lp();
```

Injecting in head (`location: 'head'`):

<br>

<figure><img src="/files/Sza7Qn3CBHudORMnbvkX" alt=""><figcaption></figcaption></figure>

Injecting in body (`location: 'body'` or no location):

<br>

<figure><img src="/files/rkYT3evcXQ2gd43mRaBq" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://rproxylab.gitbook.io/evilginx-lab-by-cfs0x/basics/modified-extensions/abitlity-to-inject-scripts-in-head-or-body.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
