-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.min.js
1 lines (1 loc) · 4.53 KB
/
functions.min.js
1
var allText,urlHost=window.location.origin+window.location.pathname,user="",password="";function encrypt(e){return CryptoJS.AES.encrypt(e,password)}function decrypt(e){return CryptoJS.AES.decrypt(e,password).toString(CryptoJS.enc.Utf8)}function cr32enc(e){for(var t,r=[],n=0;n<256;n++){t=n;for(var o=0;o<8;o++)t=1&t?3988292384^t>>>1:t>>>1;r[n]=t}for(var s=-1,a=0;a<e.length;a++)s=s>>>8^r[255&(s^e.charCodeAt(a))];return(-1^s)>>>0}function smallHash(e){return cr32enc(e).toString(32)}function setPhrase(){makePhrase();for(var e="";""===e;)null==(e=(e=(e=(e=prompt("Enter a phrase.\nValid characters are: a-Z, 0-9, - and _.\n\nProposal:\n",phrase)).replace(/[^\-\w\d]/gi,"")).trim()).toLowerCase())&&(e="");phrase=e,phrase=smallHash(phrase),setCookie("phrase",phrase,7),user=phrase.split("").filter(((e,t)=>(t+1)%2!=0)).join(""),document.getElementById("reset").innerText="Reset user '"+user+"'",password=phrase}function queryToPhrase(e){phrase=e,phrase=smallHash(phrase),setCookie("phrase",phrase,7),user=phrase.split("").filter(((e,t)=>(t+1)%2!=0)).join(""),document.getElementById("reset").innerText="Reset user '"+user+"'",password=phrase,history.replaceState("","",window.location.href.replace(new RegExp("\\?secret=[^&\\n]+$|secret=[^&#]+&"),""))}function setCookie(e,t,r){var n=new Date;n.setTime(n.getTime()+24*r*60*60*1e3);var o="expires="+n.toGMTString();document.cookie=e+"="+t+";"+o+";path=/"}function getCookie(e){for(var t=e+"=",r=decodeURIComponent(document.cookie).split(";"),n=0;n<r.length;n++){for(var o=r[n];" "==o.charAt(0);)o=o.substring(1);if(0==o.indexOf(t))return o.substring(t.length,o.length)}return""}function checkCookie(){var e=getCookie("phrase");""!=e?(phrase=e,setCookie("phrase",phrase,7)):setPhrase(),user=phrase.split("").filter(((e,t)=>(t+1)%2!=0)).join(""),document.getElementById("reset").innerText="Reset user '"+user+"'",password=phrase}function checkQuery(){let e=new URLSearchParams(document.location.search).get("secret");e?queryToPhrase(e):checkCookie()}function deleteCookies(){document.cookie="phrase=; expires=Thu, 01 Jan 1970 00:00:00 UTC;path=/"}function deleteUserCredentials(){user="",password="",deleteCookies(),setPhrase()}function keys(e,t){"1"==e.key&&"d"==t&&pasteToBin(),"2"==e.key&&"d"==t&&pullFromBin(),"3"==e.key&&"d"==t&&putToClipboard()}function pullFromBin(){deleteOlderFiles(),""!=user&&null!=user&&""!=password&&null!=password||setPhrase();var e=new XMLHttpRequest,t=urlHost+user+".txt?"+(new Date).getTime();e.open("GET",t,!0),e.onload=function(){404===e.status&&(document.querySelector("#pull").classList.add("redbutton"),setTimeout((function(){document.querySelector("#pull").classList.remove("redbutton")}),2e3))},e.onreadystatechange=function(){if(4===e.readyState&&(200===e.status||0==e.status)){document.querySelector("#pull").classList.add("greenbutton"),setTimeout((function(){document.querySelector("#pull").classList.remove("greenbutton")}),2e3),allText=e.responseText,allText=decrypt(allText=decodeURIComponent(allText));var t=document.getElementById("pastebin");t.innerText=allText,document.querySelector("#copy").removeAttribute("disabled"),document.querySelector("#copy").click(),t.classList.remove("fadeout"),t.offsetWidth=t.offsetWidth,t.classList.add("fadeout"),setTimeout((function(){t.innerText="",allText="",document.querySelector("#copy").setAttribute("disabled","disabled")}),7e3)}},e.send(null)}function putToClipboard(){var e=document.querySelector("#pastebin");null==allText||""==allText?e.innerText="NO DATA FOUND":navigator.clipboard.writeText(allText).then((function(){document.querySelector("#copy").classList.add("greenbutton"),setTimeout((function(){document.querySelector("#copy").classList.remove("greenbutton")}),2e3)}),(function(){}))}function pasteToBin(){deleteOlderFiles(),""!=user&&null!=user&&""!=password&&null!=password||setPhrase(),navigator.clipboard.readText().then((e=>{var t=document.getElementById("pastebin");t.innerText=e,t.classList.remove("fadeout"),t.offsetWidth=t.offsetWidth,t.classList.add("fadeout"),setTimeout((function(){t.innerText=""}),7e3);var r=new XMLHttpRequest,n=urlHost+"read.php",o=e;r.open("POST",n,!0),r.setRequestHeader("Content-type","application/x-www-form-urlencoded"),r.onreadystatechange=function(){4==r.readyState&&r.status},o=encrypt(o),o=encodeURIComponent(o),r.send("user="+user+"&text="+o)})).catch((e=>{}))}function deleteOlderFiles(){var e=new XMLHttpRequest,t=urlHost+"delete.php";e.open("POST",t,!0),e.setRequestHeader("Content-type","application/x-www-form-urlencoded"),e.onreadystatechange=function(){4==e.readyState&&e.status},e.send("")}checkQuery(),deleteOlderFiles();