I can't help much with JS, but I should say that all per-site permissions are handled in Firefox by new Permissions manager, available at
about:Ñ€ermissions
No glue whether does it work or not, but you can open it and play with settings for your sites.
They should be stored in profile's permissions.sqlite, I think.
Cannot help more. If this doesn't have effect in KM - the
Forum:
Bugs