Last active
July 5, 2023 13:14
-
-
Save znsstudio/cbf0cdcdd7ddcce70e1b84652886eb79 to your computer and use it in GitHub Desktop.
Piano Script Change
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
<script type="text/javascript"> | |
function setCookie(cname,cvalue,exdays) { | |
var d = new Date(); | |
d.setTime(d.getTime() + (exdays*24*60*60*1000)); | |
var expires = "expires=" + d.toGMTString(); | |
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/;SameSite=None; Secure"; | |
} | |
function getCookie(cname) { | |
var name = cname + "="; | |
var decodedCookie = decodeURIComponent(document.cookie); | |
var ca = decodedCookie.split(';'); | |
for(var i = 0; i < ca.length; i++) { | |
var c = ca[i]; | |
while (c.charAt(0) == ' ') { | |
c = c.substring(1); | |
} | |
if (c.indexOf(name) == 0) { | |
return c.substring(name.length, c.length); | |
} | |
} | |
return ""; | |
} | |
tp = window.tp || []; | |
// Set Application ID | |
tp.push(["setAid", 'B6sIXKLiin']); | |
// Is application in sandbox? | |
tp.push(["setSandbox", false]); | |
// Does application use legacy tinypass accounts? | |
tp.push(["setUseTinypassAccounts", false]); | |
// Does application use Piano ID? | |
tp.push(["setUsePianoIdUserProvider", true]); | |
// Do you need verbose debug console messages? | |
tp.push(["setDebug", false]); | |
// Execute when the page is first loaded | |
tp.push(["init", function () { | |
tp.experience.init(); | |
tp.push(["addHandler", "loginSuccess", function(data){ | |
setCookie('userToken', data.user_token, 31); | |
}]); | |
tp.push(["addHandler", "loginRequired", function(params) { | |
let localParams = getCookie('params'); | |
if(localParams === '') { | |
setCookie('params', JSON.stringify(params), 31); | |
} | |
if (userJwt === '' || userJwt === null) { | |
window.location.href = '/login'; | |
} else { | |
tp.push(["setExternalJWT", userJwt]); | |
localParams = JSON.parse(localParams); | |
tp.offer.startCheckout(localParams); | |
} | |
}]); | |
if (tp.pianoId.isUserValid()) { | |
document.getElementById("accountLink").classList.remove("hide"); | |
document.getElementById("accountStatus").innerText = "Logout"; | |
} else { | |
document.getElementById("accountStatus").innerText = "Sign\u00A0in"; | |
} | |
//reload the page after a successful purchase | |
tp.push(["addHandler", "checkoutComplete", function (conversion) { | |
location.reload(); | |
}]); | |
}]); | |
(function (src) { | |
var a = document.createElement("script"); | |
a.type = "text/javascript"; | |
a.async = true; | |
a.src = src; | |
var b = document.getElementsByTagName("script")[0]; | |
b.parentNode.insertBefore(a, b) | |
})("https://cdn.tinypass.com/api/tinypass.min.js"); | |
</script> | |
And add the script at the end of page | |
<script> | |
document.getElementById("accountStatus").addEventListener("click", function login() { | |
if (tp.pianoId.isUserValid()) { | |
tp.pianoId.logout(function () { | |
location.reload(); | |
}); | |
setCookie("_pc_auth0_authenticated", null, -1); | |
setCookie("_pc_bipf", null, -1); | |
setCookie("profile", null, -1); | |
setCookie("bi-token", null, -1); | |
setCookie("token_type", null, -1); | |
setCookie("token_environment", null, -1); | |
setCookie("userJwt", null, -1); | |
setCookie("userToken", null, -1); | |
setCookie("piano-token", null, -1); | |
setCookie("tokenCookie", null, -1); | |
} else { | |
window.location.href = '/login'; | |
} | |
}); | |
</script> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment