djyde / cusdis

lightweight, privacy-friendly alternative to Disqus.
https://cusdis.com
GNU General Public License v3.0
2.58k stars 224 forks source link

Identifier 'e' has already been declared #230

Open BigBuckBunny opened 1 year ago

BigBuckBunny commented 1 year ago

Hi,

Using "@sveltejs/kit": "1.0.1", and your JS code, everything works great, except if I change routes to a different article, without even commenting, I get the following error with no comment section:

Uncaught SyntaxError: Identifier 'e' has already been declared (at cusdis.es.js:1:1)

So, first time I see the comment section, I can comment and the webhook works great on approval. But if I change to a different article without reloading the whole page I get that error.

Thanks

huyixi commented 7 months ago

I meet the same problem. Uncaught SyntaxError: Identifier 'e' has already been declared (at cusdis.es.js:1:1) I using cusdis in hugo. This is my code:

<div id="cusdis_thread" data-host="https://cusdis.com"
  data-app-id="-"
  data-page-id="{{ print .File.UniqueID .Site.Language.Lang }}"
  data-page-url="{{ .Permalink }}"
  data-page-title="{{ .Title }}"></div>
<script async defer src="https://cusdis.com/js/cusdis.es.js"></script>
steelcityamir commented 5 months ago

This appears to be a variable scoping issue.

When you have multiple obfuscated Javascript files loaded by the same page, it has the potential to collide and produce this type of error.

A fix is to wrap the code in braces. The downside is that you'll need to host the JS file yourself.

window.CUSDIS={};
{
  let e;
  ...
};