Skip to content

Commit

Permalink
force proxy without checking for time to load
Browse files Browse the repository at this point in the history
  • Loading branch information
unixfox committed Dec 8, 2024
1 parent a4bdb5d commit c0c118c
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions public/js/proxyneededcheck.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
// This check if the browser can't load pbs.twimg.com domain.
// If it can't then we force proxy on videos and pictures.
if (!document.cookie.includes("proxyPics") && !document.cookie.includes("proxyVideos")) {
var time = Date.now();
var img = new Image();
img.onerror = function () {
if ((Date.now() - time) < 100) {
var expires = (new Date(Date.now() + 360 * 24 * 60 * 60 * 1000)).toUTCString();
if (location.protocol === 'https:') {
document.cookie = "proxyPics=on; path=/; Secure; expires=" + expires;
document.cookie = "proxyVideos=on; path=/; Secure; expires=" + expires;
} else {
document.cookie = "proxyPics=on; path=/; expires=" + expires;
document.cookie = "proxyVideos=on; path=/; expires=" + expires;
}
location.reload();
var expires = (new Date(Date.now() + 360 * 24 * 60 * 60 * 1000)).toUTCString();
if (location.protocol === 'https:') {
document.cookie = "proxyPics=on; path=/; Secure; expires=" + expires;
document.cookie = "proxyVideos=on; path=/; Secure; expires=" + expires;
} else {
document.cookie = "proxyPics=on; path=/; expires=" + expires;
document.cookie = "proxyVideos=on; path=/; expires=" + expires;
}
location.reload();
};
img.src = 'https://pbs.twimg.com/favicon.ico';
}

0 comments on commit c0c118c

Please sign in to comment.