activity-oauth-svr/templates/google_redirect.ejs
2023-12-15 11:16:13 +08:00

46 lines
1.3 KiB
Plaintext

<!DOCTYPE html>
<html>
<head>
<title>Google Redirect</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
padding: 20px;
}
.form-label i {
color: green;
}
</style>
</head>
<body>
<script>
function getAllParameterFromHash() {
var pairs;
var obj = {};
if (location.hash.startsWith('#') && location.hash.length > 1) {
pairs = window.location.hash.substring(1).split("&");
} else if (location.search.startsWith('?') && location.search.length > 1) {
pairs = window.location.search.substring(1).split("&");
}
for (let i in pairs ) {
if ( pairs[i] === "" ) continue;
let pair = pairs[i].split("=");
obj[ decodeURIComponent( pair[0] ) ] = decodeURIComponent( pair[1] );
}
return obj
}
(function() {
let params = getAllParameterFromHash();
let url = 'com.googleusercontent.apps.53206975661-ih3r0ubph3rqejdq97b029difbrk2bqj://'
let paramsStr = Object.keys(params)
.sort()
.map(key => `${key}=${encodeURIComponent(params[key])}`)
.join('&')
url += `?${paramsStr}`
console.log(url);
window.location.href = url;
})();
</script>
</body>
</html>