1
0
forked from sent/waves

Small Update

This commit is contained in:
sent 2025-05-18 16:26:05 -07:00
parent 27277d1ec3
commit 4d78a56903

View File

@ -72,14 +72,11 @@ document.addEventListener('DOMContentLoaded', function() {
if (isValidUrl(url)) { if (isValidUrl(url)) {
currentWispUrl = url; currentWispUrl = url;
localStorage.setItem('customWispUrl', url); localStorage.setItem('customWispUrl', url);
document.dispatchEvent(new CustomEvent('wispUrlChanged', { document.dispatchEvent(new CustomEvent('wispUrlChanged', { detail: currentWispUrl }));
detail: currentWispUrl
}));
wispInput.value = currentWispUrl; wispInput.value = currentWispUrl;
showToast('success', `WISP URL successfully updated to: ${currentWispUrl}`); showToast('success', `WISP URL successfully updated to: ${currentWispUrl}`);
location.reload(); location.reload();
} else { } else {
console.log("%c[❌]%c Invalid WISP URL. Please enter a valid one.", "color: red; font-weight: bold;", "color: inherit;");
currentWispUrl = defaultWispUrl; currentWispUrl = defaultWispUrl;
localStorage.setItem('customWispUrl', defaultWispUrl); localStorage.setItem('customWispUrl', defaultWispUrl);
wispInput.value = defaultWispUrl; wispInput.value = defaultWispUrl;
@ -88,68 +85,51 @@ document.addEventListener('DOMContentLoaded', function() {
} }
} }
saveButton.addEventListener('click', () => { saveButton.addEventListener('click', () => {
const customUrl = wispInput.value.trim(); updateWispServerUrl(wispInput.value.trim());
updateWispServerUrl(customUrl);
}); });
settingsIcon.addEventListener('click', (event) => { settingsIcon.addEventListener('click', (event) => {
event.preventDefault(); event.preventDefault();
toggleSettingsMenu(); toggleSettingsMenu();
}); });
closeSettingsButton.addEventListener('click', () => { closeSettingsButton.addEventListener('click', toggleSettingsMenu);
toggleSettingsMenu();
});
function toggleSettingsMenu() { function toggleSettingsMenu() {
const icon = document.querySelector('#settings-icon i.settings-icon'); const icon = document.querySelector('#settings-icon i.settings-icon');
if (settingsMenu.classList.contains('open')) { if (settingsMenu.classList.contains('open')) {
settingsMenu.classList.add('close'); settingsMenu.classList.add('close');
icon.classList.remove('fa-solid'); icon.classList.replace('fa-solid', 'fa-regular');
icon.classList.add('fa-regular'); setTimeout(() => settingsMenu.classList.remove('open', 'close'), 300);
setTimeout(() => {
settingsMenu.classList.remove('open', 'close');
}, 300);
} else { } else {
settingsMenu.classList.add('open'); settingsMenu.classList.add('open');
icon.classList.remove('fa-regular'); icon.classList.replace('fa-regular', 'fa-solid');
icon.classList.add('fa-solid'); setTimeout(() => settingsMenu.classList.remove('close'), 300);
setTimeout(() => {
settingsMenu.classList.remove('close');
}, 300);
} }
} }
transportSelected.addEventListener('click', function(e) { transportSelected.addEventListener('click', function(e) {
e.stopPropagation(); e.stopPropagation();
transportOptions.classList.toggle('transport-show'); transportOptions.classList.toggle('transport-show');
this.classList.toggle('transport-arrow-active'); this.classList.toggle('transport-arrow-active');
}); });
const optionDivs = transportOptions.getElementsByTagName('div'); Array.from(transportOptions.getElementsByTagName('div')).forEach(option => {
for (let i = 0; i < optionDivs.length; i++) { option.addEventListener('click', function(e) {
optionDivs[i].addEventListener('click', function(e) {
e.stopPropagation(); e.stopPropagation();
const selectedValue = this.innerHTML; const selectedValue = this.textContent;
transportSelected.innerHTML = selectedValue; transportSelected.textContent = selectedValue;
localStorage.setItem('transport', selectedValue.toLowerCase()); localStorage.setItem('transport', selectedValue.toLowerCase());
transportOptions.classList.remove('transport-show'); transportOptions.classList.remove('transport-show');
transportSelected.classList.remove('transport-arrow-active'); transportSelected.classList.remove('transport-arrow-active');
const event = new Event('newTransport', { document.dispatchEvent(new Event('newTransport', { detail: selectedValue.toLowerCase() }));
detail: selectedValue.toLowerCase()
});
document.dispatchEvent(event);
showToast('success', `Transport successfully changed to ${selectedValue}`); showToast('success', `Transport successfully changed to ${selectedValue}`);
location.reload(); location.reload();
}); });
} });
document.getElementById('proxy-content').classList.add('active'); document.getElementById('proxy-content').classList.add('active');
function switchTab(tabId, contentId, otherTabId1, otherContentId1, otherTabId2, otherContentId2, otherTabId3, otherContentId3) { function switchTab(activeTabId, activeContentId, ...others) {
document.getElementById(otherContentId1).classList.remove('active'); [others[1], others[3], others[5]].forEach(id => document.getElementById(id).classList.remove('active'));
document.getElementById(otherContentId2).classList.remove('active'); [others[0], others[2], others[4]].forEach(id => document.getElementById(id).classList.remove('active'));
document.getElementById(otherContentId3).classList.remove('active'); document.getElementById(activeContentId).classList.add('active');
document.getElementById(otherTabId1).classList.remove('active'); document.getElementById(activeTabId).classList.add('active');
document.getElementById(otherTabId2).classList.remove('active');
document.getElementById(otherTabId3).classList.remove('active');
document.getElementById(contentId).classList.add('active');
document.getElementById(tabId).classList.add('active');
} }
document.getElementById('proxy-tab').addEventListener('click', function() { document.getElementById('proxy-tab').addEventListener('click', function() {
switchTab('proxy-tab', 'proxy-content', 'appearance-tab', 'appearance-content', 'cloak-tab', 'cloak-content', 'info-tab', 'info-content'); switchTab('proxy-tab', 'proxy-content', 'appearance-tab', 'appearance-content', 'cloak-tab', 'cloak-content', 'info-tab', 'info-content');
@ -163,51 +143,36 @@ document.addEventListener('DOMContentLoaded', function() {
document.getElementById('info-tab').addEventListener('click', function() { document.getElementById('info-tab').addEventListener('click', function() {
switchTab('info-tab', 'info-content', 'proxy-tab', 'proxy-content', 'appearance-tab', 'appearance-content', 'cloak-tab', 'cloak-content'); switchTab('info-tab', 'info-content', 'proxy-tab', 'proxy-content', 'appearance-tab', 'appearance-content', 'cloak-tab', 'cloak-content');
}); });
navbarToggle.addEventListener('change', function() { document.querySelectorAll('.tab-button').forEach(btn => {
if (this.checked) { btn.addEventListener('click', function() {
showToast('success', 'Navigation Bar is now enabled.'); const icon = this.querySelector('i');
} else { if (icon.classList.contains('fa-bounce')) return;
showToast('error', 'Navigation Bar is now disabled.'); icon.classList.add('fa-bounce');
} setTimeout(() => icon.classList.remove('fa-bounce'), 750);
});
});
navbarToggle.addEventListener('change', function() {
showToast(this.checked ? 'success' : 'error', `Navigation Bar is now ${this.checked ? 'enabled' : 'disabled'}.`);
}); });
function runScriptIfChecked() { function runScriptIfChecked() {
let inFrame; let inFrame;
try { try { inFrame = window !== top; } catch (e) { inFrame = true; }
inFrame = window !== top;
} catch (e) {
inFrame = true;
}
const aboutBlankChecked = JSON.parse(localStorage.getItem("aboutBlankChecked")) || false; const aboutBlankChecked = JSON.parse(localStorage.getItem("aboutBlankChecked")) || false;
if (!aboutBlankChecked || inFrame) { if (!aboutBlankChecked || inFrame) return;
return; const title = localStorage.getItem("siteTitle") || "Google.";
} const icon = localStorage.getItem("faviconURL") || "https://www.google.com/favicon.ico";
const defaultTitle = "Google.";
const defaultIcon = "https://www.google.com/favicon.ico";
const title = localStorage.getItem("siteTitle") || defaultTitle;
const icon = localStorage.getItem("faviconURL") || defaultIcon;
const iframeSrc = "/";
const popup = window.open("", "_blank"); const popup = window.open("", "_blank");
if (!popup || popup.closed) { if (!popup || popup.closed) {
alert("Failed to load automask. Please allow popups and try again."); alert("Failed to load automask. Please allow popups and try again.");
return; return;
} }
popup.document.head.innerHTML = ` popup.document.head.innerHTML = `<title>${title}</title><link rel="icon" href="${icon}">`;
<title>${title}</title> popup.document.body.innerHTML = `<iframe style="height:100%;width:100%;border:none;position:fixed;top:0;right:0;left:0;bottom:0;" src="/"></iframe>`;
<link rel="icon" href="${icon}">
`;
popup.document.body.innerHTML = `
<iframe style="height: 100%; width: 100%; border: none; position: fixed; top: 0; right: 0; left: 0; bottom: 0;" src="${iframeSrc}"></iframe>
`;
window.location.replace("https://bisd.schoology.com/home"); window.location.replace("https://bisd.schoology.com/home");
} }
document.getElementById("aboutblank-toggle").addEventListener("change", function() { document.getElementById("aboutblank-toggle").addEventListener("change", function() {
localStorage.setItem("aboutBlankChecked", JSON.stringify(this.checked)); localStorage.setItem("aboutBlankChecked", JSON.stringify(this.checked));
if (this.checked) { showToast(this.checked ? 'success' : 'error', `About:Blank is now ${this.checked ? 'enabled' : 'disabled'}.`);
showToast('success', 'About:Blank is now enabled.');
} else {
showToast('error', 'About:Blank is now disabled.');
}
runScriptIfChecked(); runScriptIfChecked();
}); });
window.addEventListener("load", function() { window.addEventListener("load", function() {
@ -215,39 +180,31 @@ document.addEventListener('DOMContentLoaded', function() {
document.getElementById("aboutblank-toggle").checked = aboutBlankChecked; document.getElementById("aboutblank-toggle").checked = aboutBlankChecked;
runScriptIfChecked(); runScriptIfChecked();
}); });
function showToast(type, message) { function showToast(type, message) {
const toast = document.createElement('div'); const toast = document.createElement('div');
toast.className = `toast ${type} show`; toast.className = `toast ${type} show`;
const icons = { const icons = {
success: '<i class="fa-regular fa-check-circle" style="margin-right: 8px;"></i>', success: '<i class="fa-regular fa-check-circle" style="margin-right:8px;"></i>',
error: '<i class="fa-regular fa-times-circle" style="margin-right: 8px;"></i>', error: '<i class="fa-regular fa-times-circle" style="margin-right:8px;"></i>',
info: '<i class="fa-regular fa-info-circle" style="margin-right: 8px;"></i>', info: '<i class="fa-regular fa-info-circle" style="margin-right:8px;"></i>',
warning: '<i class="fa-regular fa-exclamation-triangle" style="margin-right: 8px;"></i>' warning: '<i class="fa-regular fa-exclamation-triangle" style="margin-right:8px;"></i>'
}; };
const icon = icons[type] || ''; toast.innerHTML = `${icons[type] || ''}${message}`;
toast.innerHTML = `${icon}${message}`;
const progressBar = document.createElement('div'); const progressBar = document.createElement('div');
progressBar.className = 'progress-bar'; progressBar.className = 'progress-bar';
toast.appendChild(progressBar); toast.appendChild(progressBar);
const closeBtn = document.createElement('button'); const closeBtn = document.createElement('button');
closeBtn.className = 'toast-close'; closeBtn.className = 'toast-close';
closeBtn.innerHTML = '<i class="fa-regular fa-xmark" style="margin-left: 8px; font-size: 0.8em;"></i>'; closeBtn.innerHTML = '<i class="fa-regular fa-xmark" style="margin-left:8px;font-size:0.8em;"></i>';
closeBtn.addEventListener('click', () => { closeBtn.addEventListener('click', () => {
toast.classList.remove('show'); toast.classList.replace('show', 'hide');
toast.classList.add('hide'); setTimeout(() => toast.remove(), 500);
setTimeout(() => {
toast.remove();
}, 500);
}); });
toast.appendChild(closeBtn); toast.appendChild(closeBtn);
document.body.appendChild(toast); document.body.appendChild(toast);
setTimeout(() => { setTimeout(() => {
toast.classList.remove('show'); toast.classList.replace('show', 'hide');
toast.classList.add('hide'); setTimeout(() => toast.remove(), 500);
setTimeout(() => {
toast.remove();
}, 500);
}, 3000); }, 3000);
} }
}); });