# Theme Developer Tutorial: 6. Using the JS API

**URL:** https://meta.discourse.org/t/theme-developer-tutorial-6-using-the-js-api/357801
**Category:** Developer Guides
**Created:** [March 18, 2025, 3:59pm UTC](https://meta.discourse.org/t/theme-developer-tutorial-6-using-the-js-api/357801 "2025-03-18T15:59:11Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [April 14, 2025, 8:45pm UTC](https://meta.discourse.org/t/theme-developer-tutorial-6-using-the-js-api/357801/2 "2025-04-14T20:45:00Z")

</div>

> [@system](#):
>
> A simple example which appends content to every post would look like:

I want to affect posts only in a particular category. I can’t figure out a way to tell if an element is in a given category. I thought I might use `element.parentElement` and work my way up to the `body`, but that doesn’t seem to work. Before I’ve solved this problem when I realized that I could tell if I wanted to change things if the **user** was in a particular group, so I could use `currentUser`, but right now, I’m doing this:

```plaintext
if (!cooked.innerHTML.includes(newFormText)) {
      console.log("fixSubmittedForm no new form text");
      return;
    }

```

Searching all of every post to decide if I want to change it seems bad, right? It’s a hosted customer or I’d have solved this problem a bunch of ways with a plugin.

---

_[View the full topic](https://meta.discourse.org/t/theme-developer-tutorial-6-using-the-js-api/357801)._
