Created
July 7, 2021 08:36
-
-
Save Itz-fork/737832bee3e4e45b48155c9563d1d089 to your computer and use it in GitHub Desktop.
Js file of cutr.ml :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var zp = document.getElementById("r2"); | |
zp.addEventListener('click', Lunc); | |
var zo = document.getElementById("expa"); | |
zo.addEventListener('click', unc); | |
function unc(){ | |
var x = document.getElementById("r1"); | |
if (x.style.display === "none") { | |
x.style.display = "block"; | |
} else { | |
x.style.display = "none"; | |
} | |
} | |
function Lunc(){ | |
var x = document.getElementById("r").required; | |
var y = document.getElementById("r1"); | |
var url = x.value | |
var alias = y.value | |
// var al = alias.slice(8); | |
var long = `https://cutr.ml/api/short?url=${url}&alias=${alias}` | |
var tag = document.createElement("input"); | |
tag.setAttribute('readonly', true) | |
tag.setAttribute('id', "tagg") | |
var xhttp = new XMLHttpRequest(); | |
xhttp.open("GET",long); | |
xhttp.onreadystatechange = function() { | |
// if(xhttp.readyState == 4) { | |
// if(xhttp.status == 200) { | |
result = xhttp.responseText; | |
js = JSON.parse(result) | |
if (js['err']){ | |
tag.setAttribute('value', `Error: ${js['err']}`) | |
return; | |
} | |
tag.setAttribute('value', js['shortUrl']) | |
// } //else { | |
// alert( " An error has occurred: " + xhttp.statusText); | |
// } | |
// } | |
} | |
xhttp.send(); | |
var but = document.createElement("input"); | |
but.setAttribute('type', 'button') | |
but.setAttribute('class', 'next action-button') | |
but.setAttribute('value', 'Copy') | |
but.setAttribute('onClick', "myFunction()") | |
function myFunction() { | |
/* Get the text field */ | |
var copyText = document.getElementById("tagg"); | |
/* Select the text field */ | |
copyText.select(); | |
copyText.setSelectionRange(0, 99999); /* For mobile devices */ | |
/* Copy the text inside the text field */ | |
document.execCommand("copy"); | |
/* Alert the copied text */ | |
alert("Copied the text: " + copyText.value); | |
} | |
var z = document.getElementById("r2"); | |
var xmlHttp = new XMLHttpRequest(); | |
if (x.style.display === "none") { | |
x.style.display = "block"; | |
} else { | |
x.style.display = "none"; | |
} | |
if (y.style.display === "none") { | |
y.style.display = "block"; | |
} else { | |
y.style.display = "none"; | |
} | |
var zo = document.getElementById("expa"); | |
if (zo.style.display === "none") { | |
zo.style.display = "block"; | |
} else { | |
zo.style.display = "none"; | |
} | |
if (z.style.display === "none") { | |
y.style.display = "block"; | |
} else { | |
z.style.display = "none"; | |
} | |
var element = document.getElementById("oi"); | |
element.appendChild(tag); | |
element.appendChild(but); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment