With include.ai, you can define custom javascript functions as part of a superpower to be executed. Below is some tips and documentation for writing these functions

Execution Context

📝 Summary: Two ways to run javascript functions as part of a superpower: 1) Run in Chrome Extension Background, 2) Run in context of the page

The two ways to define custom javascript function are "Run Javascript Code" and "Run Javascript Code in Background".

Run Javascript Code

⚠️ Javascript runs in context of page instead of content script of extension

The defined javascript code would run in the context of the webpage itself. This means the javascript code would have access to the DOM tree, the window object of the page itself. Noticeably, this is not the same javascript context with the content script of the Chrome extension.

Here are a couple of tips for writing custom javascript in page:

Run Javascript Code in Background

Javascript runs in the background page of extension. Has access to chrome API

The defined javascript under "Run Javascript Code in Background" would run in the background page of the chrome extension. This means that javascript defined here would have access to the chrome API, which is very handy in managing tabs, web requests and etc. This also means that javascript here would not have access to the DOM itself.

Here are.a couple of tip[s for writing javascript in extension background