Currently content rules are supported in spaces only - not in web project. If you're running your js as a custom action configured via a content rule, it will only work in a space and not in the context of any web project. Within the Alfresco GUI, when you look at the single space Web Projects, that space is in reality a launch point into the AVM repository, which hosts sandboxes for site development and management, where each sandbox contains a collection of versioned files and directories. Since the Web Project root node is a normal Alfresco space, any content rule will work. All nodes underneath that are "special" nodes that at this point (coming in the short to medium-term) do not yet support content rules.
If you want to automate some action today within a web project, that is today done through workflow only. For lots of basic things, workflow is a bit heavy-handed. Like I said, we look to add support for content rules within the next few months (you can track this issue on our JIRA at: http://issues.alfresco.com/browse/WCM-49).