Skip to content

Commit

Permalink
review pass 1
Browse files Browse the repository at this point in the history
  • Loading branch information
GarboMuffin committed Jun 30, 2023
1 parent fa51c99 commit 247bb38
Showing 1 changed file with 13 additions and 36 deletions.
49 changes: 13 additions & 36 deletions extensions/NexusKitten/browserutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,9 @@
]
};
}
async isonline() {
try {
const response = await Scratch.fetch('https://extensions.turbowarp.org/hello.txt');
return true;
} catch (error){
return false;
}
isonline() {
// TODO: we want to do better, but no good reliable way for us to do that right now
return navigator.onLine;
}
ismobile () {
const userAgent = navigator.userAgent;
Expand All @@ -140,56 +136,37 @@
}
}
geturl () {
try {
const currentUrl = window.location.href;
return currentUrl;
} catch (error){
return '';
}
return location.href;
}

settitle (args) {
try {
document.title = args.TITLE;
} catch (error){
}
document.title = args.TITLE;
}

setfavicon (args) {
try {
// Not sure why this code shows up with errors in visual studio, however it works.
var link = document.querySelector("link[rel~='icon']");
async setfavicon (args) {
// This can cause a network request, so we need to get permission
if (await Scratch.canFetch(args.ICO)) {
/** @type {HTMLLinkElement} */
let link = document.querySelector("link[rel~='icon']");
if (!link) {
link = document.createElement('link');
link.rel = 'icon';
document.head.appendChild(link);
}
link.href = args.ICO;
} catch (error){
}
}

reload () {
try {
location.reload();
} catch (error){
}
location.reload();
}

tabactive () {
try {
return !document.hidden;
} catch (error){
return true;
}
return !document.hidden;
}

darkmode () {
try {
return window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
} catch (error){
return false;
}
return window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
}

// The following blocks were originally from LMS Utilities, repurposed with permission.
Expand Down

0 comments on commit 247bb38

Please sign in to comment.