Subscribe on html tags class, if has some class then add some another one

Hello developers, please sorry right away if my english bad, and if there some similar thread.
I recently started use atom, and i really liked it, especially that possibility modify everything. And i was has’nt problems really long time with it(modify atom such i want), but now, when i need write my own script for atom, i get some problem, well i tried to use init.cofffee but that language looks for me little bit weird, and i renamed that in init.js as wiki says i can use js if do, and here problem starts… that says “invalid or unexpected token”, and also im not shure this will work like i expect. I created this method with thinking this would attach “open” class to html tab with class “hovered” but… it is’nt will work right? needs somehow subscribe on html or?.. P.S just really recently started learn html&css and knows js only because this simillar to languages what i use, dont be mad on me xdd

function IfSelectedThenOpen() {
  var element = document.querySelector(".title-bar-replacer .app-menu .menu-label.hovered");
  if (element != null) {

just in case, with fixed “!==” still not work, just checked

Any answers with coffeescript also are welcome, me need just add a class “open” if class “hovered” in html tag(this changes dymamicly).

This what i tried on coffeescript, unfortunately does’nt work for me, this has sense ofcourse, but i cant understand how to subscribe on tags with “hovered” class

OpenWithHighlight = ->
  target = atom.workspace.views.getView(".title-bar-replacer .app-menu .menu-label.hovered")
  unless target == null