Don't always embed Disqus
This commit is contained in:
+30
-11
@@ -11,19 +11,38 @@
|
||||
{% assign disqus_id = site.xaymar.comments.disqus.identifier %}
|
||||
<div id="disqus_thread"></div>
|
||||
<script>
|
||||
var disqus_config = function () {
|
||||
this.page.url = "{{ disqus_url }}/";
|
||||
this.page.identifier = "{{ disqus_page_url }}/";
|
||||
};
|
||||
(function() { // DON'T EDIT BELOW THIS LINE
|
||||
var d = document, s = d.createElement('script');
|
||||
s.defer = true;
|
||||
s.src = 'https://{{ disqus_id }}.disqus.com/embed.js';
|
||||
s.setAttribute('data-timestamp', +new Date());
|
||||
(d.head || d.body).appendChild(s);
|
||||
})();
|
||||
function load_disqus_comments() {
|
||||
var disqus_config = function () {
|
||||
this.page.url = "{{ disqus_url }}/";
|
||||
this.page.identifier = "{{ disqus_page_url }}/";
|
||||
};
|
||||
|
||||
document.querySelector(".comments > .content > .privacy").style.display = "none";
|
||||
|
||||
var d = document, s = d.createElement('script');
|
||||
s.defer = true;
|
||||
s.src = 'https://{{ disqus_id }}.disqus.com/embed.js';
|
||||
s.setAttribute('data-timestamp', +new Date());
|
||||
(d.head || d.body).appendChild(s);
|
||||
}
|
||||
</script>
|
||||
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
|
||||
<div class="privacy">
|
||||
<button class="once">Allow embedded Disqus widget once</button>
|
||||
<button class="always">Always allow embedded Disqus Widget</button>
|
||||
</div>
|
||||
<script>
|
||||
document.querySelector(".comments > .content > .privacy > .once").addEventListener("click", (ev) => {
|
||||
load_disqus_comments();
|
||||
});
|
||||
document.querySelector(".comments > .content > .privacy > .always").addEventListener("click", (ev) => {
|
||||
document.cookie = "allow_disqus_embed=true";
|
||||
load_disqus_comments();
|
||||
});
|
||||
if (document.cookie.indexOf("allow_disqus_embed") !== -1) {
|
||||
load_disqus_comments();
|
||||
}
|
||||
</script>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user