-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.js
More file actions
59 lines (44 loc) · 1.53 KB
/
main.js
File metadata and controls
59 lines (44 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
let sidebar = document.getElementById("sidebar")
function showSidebar(){
sidebar.style.display = 'flex'
}
function closeSidebar(){
sidebar.style.display = "none"
}
// Download Button
// email: outertune@protonmail.com
const owner = "DD3Boh";
const repo = "OuterTune";
const apiUrl = `https://api.github.com/repos/${owner}/${repo}/releases/latest`;
let downloadBtn = document.getElementById("download-btn")
downloadBtn.addEventListener("click", async function(){
try{
const response = await fetch(apiUrl)
if(!response.ok){throw new Error("Error! failed to fetch data!")}
const data = await response.json()
const apkFile = data.assets.find(assets => assets.name.endsWith(".apk"))
if(apkFile){
window.location.href = apkFile.browser_download_url
}
else{
alert("no apk file found in the latest release!")
}
}
catch{
console.error("error fetching latest release", error)
alert("failed to get the latest apk")
}
})
// Copy email button
function copyEmail(email) {
navigator.clipboard.writeText(email)
.then(() => alert("Email copied to clipboard!"))
.catch(err => console.error("Error copying email: ", err));
}
let githubPic = document.getElementById("github-pic")
function redirectGithub(github){
window.open(github,"_blank");
}
githubPic.addEventListener("click", function(){
redirectGithub("https://github.com/juraijAhmed")
} )