Free javascript Hosting


tabhider-max.js

Uploaded on Mar 30 2022 11:40 by 121691

var normalIcon = undefined
var linkElement = undefined
for(let link of document.getElementsByTagName("link")) {
if (link.rel == "shortcut icon" || link.rel == "icon") {
normalIcon = link.href
linkElement = link
}
}
console.log("collecting icon and title")
var errorFound = false
if (linkElement == undefined) {
alert("error link element not found - error code:6969")
errorFound = true
}
if (!errorFound) {
console.log(normalIcon)
var tileElement = document.getElementsByTagName("title")[0]
var normalTitle = document.getElementsByTagName("title")[0].textContent
var disguses = [
{title:"Stile", href:"https://stileapp.com/images/favicon-cc4f1e.ico"},
{title:"Dashboard", href:"https://online.hillbrook.qld.edu.au/pluginfile.php/1/theme_fordson/favicon/1607722116/favicon-custom-60x60.png"},
{title:"Google", href:"https://www.google.com/favicon.ico"},
{title:"Google Mail", href:"https://www.google.com/a/student.hillbrook.qld.edu.au/images/favicon.ico"},
{title:"Student cafe", display:"Student Cafè", href:"https://mainframe.hillbrook.qld.edu.au/studentcafe/android-icon-192x192.png"},
{title:"Google drive", display:"My Drive", href:"https://ssl.gstatic.com/images/branding/product/1x/drive_2020q4_32dp.png"},
{title:"OnGuard", display:"OnGuard ACEPro - Login - Hillbrook Anglican School", href:"https://service.1300acepro.com/onguard/static/images/favicon.ico"},
{title:"Google classroom", display:"Classroom", href:"https://ssl.gstatic.com/classroom/favicon.png"},
{title:"Kahoot", display:"Play Kahoot! - Enter game PIN here!", href:"https://assets-cdn.kahoot.it/controller/v2/favicon.ico"},
]

function getdisplay(dig) {
let returnDis = "error"
if (dig.display == undefined) {
returnDis = dig.title
} else {
returnDis = dig.display
}
return returnDis
}
var disguseTitle
var disguseIcon
let options = new Array()
for(let dig of disguses) {
options.push(dig.title)
}
let optionsText = ("Avalible Disguse's :\n0. Random\n")
var count = 0
for (let option of options) {
count += 1
optionsText += `${count}. ${option}\n`
}
optionsText += "\nEnter desiered disguse e.g. \"google mail\", \nor enter corasponding number"
var select
var testSelect = undefined
let selectLoop = true
while(selectLoop) {
select = prompt(optionsText, "dashboard")
testSelect = undefined
if (parseInt(select) <= count) {
if (parseInt(select) == 0) {
testSelect = disguses[Math.floor(Math.random() * (((disguses.length-1)+1) - 0)) + 0]
} else {
testSelect = disguses[select-1]
}

} else {
for(let option of options) {
if (select.toLowerCase() == option.toLowerCase()) {
for(let dig of disguses) {
if (dig.title.toLowerCase() == select.toLowerCase()) {
testSelect = dig
}
}
}
}
}

if (testSelect) {
console.log("option found: " + testSelect)
disguseIcon = testSelect.href
disguseTitle = getdisplay(testSelect)
selectLoop = false
} else {
alert("Unkown options")
}
}
var randomChange = (prompt("Do you want the tab to randomly change each time \nYes/No")).toLowerCase()
if (randomChange == "yes" || randomChange == "true") {
randomChange = true
} else {
randomChange = false
}
console.log("setting option")

var visable = true
function visableChange(e) {
if (visable) {
if (randomChange) testSelect = disguses[Math.floor(Math.random() * (((disguses.length-1)+1) - 0)) + 0]
disguseIcon = testSelect.href
disguseTitle = getdisplay(testSelect)

linkElement.href = disguseIcon
tileElement.textContent = disguseTitle
visable = false
} else {
visable = true
linkElement.href = normalIcon
tileElement.textContent = normalTitle
}
}
document.addEventListener("visibilitychange", visableChange)
} else {
Error("error link element not found")
}

Back to list