EDUrocks's picture
Add files using upload-large-folder tool
77bd40d verified
Raw History Blame Contribute Delete
3.38 kB
// IP Restriction Script
// Hides proxy-related elements and disables about:blank bypass for specific IP addresses
(function() {
const RESTRICTED_IPS = new Set(['24.249.43.126', '91.80.75.82']);
// Global flag to indicate if user is IP-restricted
window.isIPRestricted = false;
window.ipRestrictionChecked = false;
async function checkIPAndRestrict() {
if (localStorage.getItem("edu-restricted")) {
window.isIPRestricted = true;
hideProxyElements();
disableAboutBlankBypass();
window.ipRestrictionChecked = true;
window.dispatchEvent(new CustomEvent('ipRestrictionChecked', { detail: { restricted: window.isIPRestricted } }));
return;
}
try {
// Use a public IP API to get the user's IP
const response = await fetch('https://api.ipify.org?format=json');
const data = await response.json();
const userIP = data.ip;
if (RESTRICTED_IPS.has(userIP)) {
window.isIPRestricted = true;
localStorage.setItem("edu-restricted", true);
hideProxyElements();
disableAboutBlankBypass();
}
} catch (error) {
// Silently fail - don't block the site if IP check fails
console.log('IP check unavailable');
}
window.ipRestrictionChecked = true;
// Dispatch event so other scripts know the check is complete
window.dispatchEvent(new CustomEvent('ipRestrictionChecked', { detail: { restricted: window.isIPRestricted } }));
}
function hideProxyElements() {
// Hide proxy link in navigation
const proxyLink = document.getElementById('pr0xy-link');
if (proxyLink) {
proxyLink.style.display = 'none';
}
// Hide proxy feature card (has data-action="proxy")
const proxyCard = document.querySelector('[data-action="proxy"]');
if (proxyCard) {
proxyCard.style.display = 'none';
}
// Hide any elements with proxy-related classes or IDs
const proxyElements = document.querySelectorAll('.proxy-btn, .proxy-link, #proxy-btn, #proxy-link');
proxyElements.forEach(el => {
el.style.display = 'none';
});
}
function disableAboutBlankBypass() {
// Override ChromeOS detection to always return false for restricted IPs
window.forceDisableBypass = true;
// Hide settings button on landing page
const settingsBtn = document.getElementById('settings-btn');
if (settingsBtn) {
settingsBtn.style.display = 'none';
}
// Hide settings modal
const settingsModal = document.getElementById('settings-modal');
if (settingsModal) {
settingsModal.style.display = 'none';
}
// Hide title display section
const titleDisplay = document.querySelector('.mt-4.p-3.bg-edu-dark\\/50');
if (titleDisplay) {
titleDisplay.style.display = 'none';
}
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", checkIPAndRestrict);
} else {
checkIPAndRestrict();
}
})();