add caching to search as well lol

This commit is contained in:
Ashley 2023-03-26 12:24:57 +00:00
parent e148de3560
commit d81d66b461

View file

@ -571,6 +571,34 @@ function toggleAudio() {
} }
} }
const urls = document.querySelectorAll('a[href*="/watch?v="]'); // get all links with "/watch?v=" in href attribute
urls.forEach(link => {
const url = new URL(link.href);
if (url.host !== 'www.youtube.com' && url.host !== 'youtube.com') {
console.log(`Fetching ${url.origin}`);
fetch(url.href)
.then(response => {
if (response.status === 500) {
// do nothing
}
console.log(`Fetched ${url.origin}`);
// Do something with the response
})
.catch(error => {
// Ignore network errors
if (!(error instanceof TypeError && error.message.includes('Failed to fetch'))) {
console.error(`Error fetching ${url.origin}: ${error}`);
}
});
}
});
if (audioToggled === null || audioToggled === undefined) { if (audioToggled === null || audioToggled === undefined) {
audioToggled = true; audioToggled = true;
} }