console.log("Codes uses GPL Licence");function setMask(){return document.getElementsByClassName("rmMask")[0]!=null?document.getElementsByClassName("rmMask")[0]:(mask=document.createElement("div"),mask.className="rmMask",mask.style.width=window.innerWidth+"px",mask.style.height=window.innerHeight+"px",mask.style.background="#fff",mask.style.opacity=".0",mask.style.position="fixed",mask.style.top="0",mask.style.left="0",mask.style.zIndex=998,document.body.appendChild(mask),document.getElementById("rightMenu").style.zIndex=19198,mask)}function insertAtCursor(t,e){if(document.selection)t.focus(),sel=document.selection.createRange(),sel.text=e,sel.select();else if(t.selectionStart||t.selectionStart=="0"){var n=t.selectionStart,o=t.selectionEnd,s=t.scrollTop;t.value=t.value.substring(0,n)+e+t.value.substring(o,t.value.length),s>0&&(t.scrollTop=s),t.focus(),t.selectionStart=n+e.length,t.selectionEnd=n+e.length}else t.value+=e,t.focus()}let rmf={};rmf.showRightMenu=function(t,e=0,n=0){let o=$("#rightMenu");o.css("top",e+"px").css("left",n+"px"),t?o.show():o.hide()},rmf.switchDarkMode=function(){(document.documentElement.getAttribute("data-theme")==="dark"?"dark":"light")==="light"?(activateDarkMode(),saveToLocal.set("theme","dark",2),GLOBAL_CONFIG.Snackbar!==void 0&&btf.snackbarShow(GLOBAL_CONFIG.Snackbar.day_to_night)):(activateLightMode(),saveToLocal.set("theme","light",2),GLOBAL_CONFIG.Snackbar!==void 0&&btf.snackbarShow(GLOBAL_CONFIG.Snackbar.night_to_day)),typeof utterancesTheme=="function"&&utterancesTheme(),typeof FB=="object"&&window.loadFBComment(),window.DISQUS&&document.getElementById("disqus_thread").children.length&&setTimeout(()=>window.disqusReset(),200)},rmf.yinyong=function(){var t=document.getElementsByClassName("el-textarea__inner")[0],e=document.createEvent("HTMLEvents");e.initEvent("input",!0,!0),t.value=d.value="> "+getSelection().toString()+` `,t.dispatchEvent(e),console.log(getSelection().toString()),document.getElementsByClassName("el-textarea__inner")[0].value="> "+getSelection().toString()+` `,Snackbar.show({text:"\u4E3A\u4FDD\u8BC1\u6700\u4F73\u8BC4\u8BBA\u9605\u8BFB\u4F53\u9A8C\uFF0C\u5EFA\u8BAE\u4E0D\u8981\u5220\u9664\u7A7A\u884C",pos:"top-center",showAction:!1})},rmf.copyWordsLink=function(){let t=window.location.href,e=document.createElement("textarea");e.value=t,document.body.appendChild(e),e.select(),document.execCommand("Copy"),document.body.removeChild(e),Snackbar.show({text:"\u94FE\u63A5\u590D\u5236\u6210\u529F\uFF01\u5FEB\u53BB\u5206\u4EAB\u5427\uFF01",pos:"top-right",showAction:!1})},rmf.switchReadMode=function(){const t=document.body;t.classList.add("read-mode");const e=document.createElement("button");e.type="button",e.className="fas fa-sign-out-alt exit-readmode",t.appendChild(e);function n(){t.classList.remove("read-mode"),e.remove(),e.removeEventListener("click",n)}e.addEventListener("click",n)},rmf.copySelect=function(){document.execCommand("Copy",!1,null)},rmf.scrollToTop=function(){document.getElementsByClassName("menus_items")[1].setAttribute("style",""),document.getElementById("name-container").setAttribute("style","display:none"),btf.scrollToDest(0,500)},rmf.translate=function(){document.getElementById("translateLink").click()},rmf.searchinThisPage=()=>{document.getElementsByClassName("local-search-box--input")[0].value=window.getSelection().toString(),document.getElementsByClassName("search")[0].click();var t=document.createEvent("HTMLEvents");t.initEvent("input",!1,!1),document.getElementsByClassName("local-search-box--input")[0].dispatchEvent(t)},rmf.downloadImage=function(t,e){btf.snackbarShow("\u6B63\u5728\u4E0B\u8F7D\u4E2D\uFF0C\u8BF7\u7A0D\u540E",!1,1e4),setTimeout(function(){let n=new Image;n.setAttribute("crossOrigin","anonymous"),n.onload=function(){let o=document.createElement("canvas");o.width=n.width,o.height=n.height,o.getContext("2d").drawImage(n,0,0,n.width,n.height);let l=o.toDataURL("image/png"),c=document.createElement("a"),i=new MouseEvent("click");c.download=e||"photo",c.href=l,c.dispatchEvent(i)},n.src=t,btf.snackbarShow("\u56FE\u7247\u5DF2\u6DFB\u52A0\u76F2\u6C34\u5370\uFF0C\u8BF7\u9075\u5B88\u7248\u6743\u534F\u8BAE"),rm.downloadimging=!1},"10000")},document.body.addEventListener("touchmove",function(t){},{passive:!1});function popupMenu(){window.oncontextmenu=function(t){if(t.ctrlKey)return!0;$(".rightMenu-group.hide").hide(),document.getSelection().toString()&&$("#menu-text").show(),(document.getElementById("post")||document.getElementById("page"))&&$("#menu-post").show();var e=window.document.body;e=t.target;var n=/^(?:http(s)?:\/\/)?[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\*\+,;=.]+$/;n.test(window.getSelection().toString())&&e.tagName!="A"&&$("#menu-too").show(),e.tagName=="A"&&($("#menu-to").show(),rmf.open=function(){e.href.indexOf("http://")==-1&&e.href.indexOf("https://")==-1||e.href.indexOf("yumetsuki.moe")!=-1?pjax.loadUrl(e.href):location.href=e.href},rmf.openWithNewTab=function(){window.open(e.href)},rmf.copyLink=function(){let i=e.href,a=document.createElement("textarea");a.value=i,document.body.appendChild(a),a.select(),document.execCommand("Copy"),document.body.removeChild(a)}),e.tagName=="IMG"?($("#menu-img").show(),rmf.openWithNewTab=function(){window.open(e.src)},rmf.click=function(){e.click()},rmf.copyLink=function(){let i=e.src,a=document.createElement("textarea");a.value=i,document.body.appendChild(a),a.select(),document.execCommand("Copy"),document.body.removeChild(a)},rmf.saveAs=function(){var i=e.src,a=i.split("/")[-1];rmf.downloadImage(i,a)}):(e.tagName=="TEXTAREA"||e.tagName=="INPUT")&&($("#menu-paste").show(),rmf.paste=function(){navigator.permissions.query({name:"clipboard-read"}).then(i=>{i.state=="granted"||i.state=="prompt"?navigator.clipboard.readText().then(a=>{console.log(a),insertAtCursor(e,a)}):Snackbar.show({text:"\u8BF7\u5141\u8BB8\u8BFB\u53D6\u526A\u8D34\u677F\uFF01",pos:"top-center",showAction:!1})})});let o=t.clientX+10,s=t.clientY,l=$("#rightMenu").width(),c=$("#rightMenu").height();return o+l>window.innerWidth&&(o-=l+10),s+c>window.innerHeight&&(s-=s+c-window.innerHeight),mask=setMask(),window.onscroll=()=>{rmf.showRightMenu(!1),window.onscroll=()=>{},document.body.removeChild(mask)},$(".rightMenu-item").click(()=>{document.body.removeChild(mask)}),$(window).resize(()=>{rmf.showRightMenu(!1),document.body.removeChild(mask)}),mask.onclick=()=>{document.body.removeChild(mask)},rmf.showRightMenu(!0,s,o),!1},window.addEventListener("click",function(){rmf.showRightMenu(!1)})}navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)||popupMenu();const box=document.documentElement;function addLongtabListener(t,e){let n=0;t.ontouchstart=()=>{n=0,n=setTimeout(()=>{e(),n=0},380)},t.ontouchmove=()=>{clearTimeout(n),n=0},t.ontouchend=()=>{n&&clearTimeout(n)}}addLongtabListener(box,popupMenu);