/*! * DisqusJS | v1.0.10 * Author: SukkaW * Link: https://github.com/SukkaW/DisqusJS * License: MIT */"use strict";function DisqusJS(s){var i=function(s,e,n){var t=new XMLHttpRequest;t.open("GET",encodeURI(s),!0),t.onload=function(){if(200<=t.status&&t.status<300||304===t.status){var s=JSON.parse(t.responseText);e(s)}else l()},t.timeout=4500,t.ontimeout=function(s){n(s)},t.onerror=function(s){n(s)},t.send()},e=function(s,e){try{localStorage.setItem(s,e)}catch(s){}},c=function(s){s=Date.parse(new Date(s));var e=(s=new Date(s+288e5)).getFullYear(),n=s.getMonth()+1;n=n<10?"0".concat(n):n;var t=s.getDate();t=t<10?"0".concat(t):t;var a=s.getHours();a=a<10?"0".concat(a):a;var o=s.getMinutes();return o=o<10?"0".concat(o):o,"".concat(e,"-").concat(n,"-").concat(t," ").concat(a,":").concat(o)};function n(){var s=document,e=s.createElement("script");s.getElementById("disqus_thread").innerHTML='
评论完整模式加载中...如果长时间无法加载,请针对 disq.us | disquscdn.com | disqus.com 启用代理,或使用 评论基础模式
',s.getElementById("dsqjs-force-dsqjs").addEventListener("click",d),e.src="https://"+u.config.shortname+".disqus.com/embed.js",e.setAttribute("data-timestamp",+new Date),(s.head||s.body).appendChild(e)}function r(){for(var s=["disqus.com","".concat(u.config.shortname,".disqus.com")],t=0,a=0,o=function(){s.length===t&&t===a?m():s.length===t&&d()},e=0;e
    加载更多评论
    ',s.getElementById("dsqjs-msg").innerHTML='评论基础模式加载中。如需完整体验请针对 disq.us | disquscdn.com | disqus.com 启用代理并 尝试完整 Disqus 模式 | 强制完整 Disqus 模式。',s.getElementById("dsqjs-reload-disqus").addEventListener("click",r),s.getElementById("dsqjs-force-disqus").addEventListener("click",m);var e="".concat(u.config.api,"3.0/threads/list.json?forum=").concat(u.config.shortname,"&thread=ident:").concat(u.config.identifier,"&api_key=").concat(u.config.apikey);i(e,function(s){var e=document;if(0===s.code&&1===s.response.length){var n=s.response[0];u.page={id:n.id,title:n.title,isClosed:n.isClosed,length:n.posts,comment:[]},e.getElementById("dsqjs-comment-num").innerHTML=u.page.length,u.config.siteName&&(e.getElementById("dsqjs-site-name").innerHTML=u.config.siteName),t()}else 0===s.code&&1!==s.response.length?(e.getElementById("dsqjs-msg").innerHTML='该 Thread 并没有初始化,是否 切换到完整 Disqus 模式 进行初始化?',e.getElementById("dsqjs-force-disqus").addEventListener("click",m)):l()},function(s){l()})}();var t=function e(s){var n=function s(){t.removeEventListener("click",s),e(u.page.next)},t=document.getElementById("dsqjs-load-more");if(s){s="&cursor=".concat(s);a=function(){t.classList.remove("dsqjs-disabled"),t.innerHTML="加载更多评论失败,点击重试"}}else{s="";var a=function(){l()}}t.classList.add("dsqjs-disabled");var o="".concat(u.config.api,"3.0/posts/list.json?forum=").concat(u.config.shortname,"&thread=").concat(u.page.id).concat(s,"&include=approved&include=deleted&api_key=").concat(u.config.apikey);i(o,function(s){if(0===s.code&&0尝试完整 Disqus 模式 | 强制完整 Disqus 模式。',e.getElementById("dsqjs-header").classList.remove("dsqjs-hide"),e.getElementById("dsqjs-post-container").innerHTML='
    这里冷冷清清的,一条评论都没有
    ',e.getElementById("dsqjs-reload-disqus").addEventListener("click",r),e.getElementById("dsqjs-force-disqus").addEventListener("click",m)}else a()},function(s){a()})},a=function(s){var e=[],o=[];return s.forEach(function(s){(s.parent?o:e).push(s)}),e.map(function(s){return{comment:s,author:s.author.name,isPrimary:!!u.config.admin&&s.author.username===u.config.admin,children:function s(e){if(0===o.length)return null;for(var n=[],t=0;t'),s.comment.authorEl='")):(s.comment.avatarEl=''),s.comment.authorEl='")),u.config.adminLabel&&s.isPrimary&&(s.comment.authorEl+=''.concat(u.config.adminLabel,"")),s},d=function(s){if(s.isDeleted)var e="",n="此评论已被删除";else e="".concat(s.authorEl,''),n=s.message;var t,a,o;return'
    '.concat(s.avatarEl,'
    ').concat(e,'
    ').concat((t=n,a=new RegExp(/(.+?)<\/a>/gi),o=new RegExp(/href=\"(.+?)\"/gi),(t.match(a)||[]).map(function(s){var e=s.match(o)[0].replace(/href=\"https:\/\/disq.us\/url\?url=/g,"").replace(/(.*)"/,"$1");e=(e=decodeURIComponent(e)).replace(/(.*):(.*)cuid=(.*)/,"$1"),t=t.replace(s,'').concat(e,""))}),t=t.replace(/href=/g,'target="_blank" href=')),"
    ")},e="";(s=a(s)).map(function(s){s.children&&(s.nesting=1),s=o(s),e+='
  • ').concat(d(s.comment)).concat(function e(s){var n=s.nesting,t=s.children||[];if(t){var a=n<4?'
      ':'
        ';return t.map(function(s){(s=o(s)).nesting=n+1,a+='
      • ').concat(d(s.comment)).concat(e(s),"
      • ")}),0!==(a+="
      ").length?a:void 0}}(s),"")});var n=document;n.getElementById("dsqjs-header").classList.remove("dsqjs-hide"),n.getElementById("dsqjs-msg").innerHTML='你可能无法访问 Disqus,已启用评论基础模式。如需完整体验请针对 disq.us | disquscdn.com | disqus.com 启用代理并 尝试完整 Disqus 模式 | 强制完整 Disqus 模式。',n.getElementById("dsqjs-post-container").innerHTML=e,n.getElementById("dsqjs-reload-disqus").addEventListener("click",r),n.getElementById("dsqjs-force-disqus").addEventListener("click",m)}}function l(){var s=document;s.getElementById("dsqjs-msg").innerHTML='评论基础模式加载失败,是否 重载尝试完整 Disqus 模式 ?',s.getElementById("dsqjs-reload-dsqjs").addEventListener("click",t),s.getElementById("dsqjs-reload-disqus").addEventListener("click",r)}function d(){e("dsqjs_mode","dsqjs"),t()}function m(){e("dsqjs_mode","disqus"),n()}var a,u=[];u.config=s,u.config.api=u.config.api||"https://disqus.skk.moe/disqus/",u.config.identifier=u.config.identifier||document.location.origin+document.location.pathname+document.location.search,u.config.url=u.config.url||document.location.origin+document.location.pathname+document.location.search,u.page=[],window.disqus_config=function(){this.page.url=u.config.url,this.page.identifier=u.config.identifier},u.mode=(a="dsqjs_mode",localStorage.getItem(a)),"disqus"===u.mode?n():"dsqjs"===u.mode?t():r()}Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _default=DisqusJS;exports.default=_default;