~glacambre/firenvim

7f8c020a080592542df479c0d6a55f1fec809032 — glacambre 2 months ago 3b5d2ed
Make sure we're only evaluating expressions, not statements
3 files changed, 3 insertions(+), 3 deletions(-)

M README.md
M src/testing/content.ts
M src/testing/frame.ts
M README.md => README.md +1 -1
@@ 248,7 248,7 @@ Mode names are defined in [Neovim's cursor_shape.c](https://github.com/neovim/ne

### Interacting with the page

You can execute javascript in the page by using `firenvim#eval_js`. Here's an example that creates a `:GithubComment` command that will click on the `Comment` button of Github issues:
You can execute javascript in the page by using `firenvim#eval_js`. The code has to be a valid javascript expression (NOT a statement). Here's an example that creates a `:GithubComment` command that will click on the `Comment` button of Github issues:

```vim
command GithubComment call firenvim#eval_js('document.getElementById("partial-new-comment-form-actions").getElementsByClassName("btn btn-primary")[0].click()')

M src/testing/content.ts => src/testing/content.ts +1 -1
@@ 9,5 9,5 @@ import { executeInPage } from "../utils/utils";
window.addEventListener("firenvim-updateSettings", () => {
    browser.runtime.sendMessage({ funcName: [ "updateSettings"] })
        .catch((): undefined => undefined)
        .then(() => executeInPage(`window.dispatchEvent(new Event("firenvim-settingsUpdated"));`));
        .then(() => executeInPage(`window.dispatchEvent(new Event("firenvim-settingsUpdated"))`));
});

M src/testing/frame.ts => src/testing/frame.ts +1 -1
@@ 5,4 5,4 @@
import { isReady } from "../NeovimFrame.ts";
import { page } from "../page/proxy";

isReady.then(() => page.evalInPage(`window.firenvimReady = true;`));
isReady.then(() => page.evalInPage(`(() => { window.firenvimReady = true })()`));