Choose your proxy method from the tabs above
// Tab Switching Function
function switchProxyMethod(method) {
// Update button styles
document.querySelectorAll('.method-btn').forEach(btn => {
btn.style.background = 'rgba(255, 0, 255, 0.2)';
btn.style.border = '1px solid #ff00ff';
btn.style.color = '#fff';
});
// Hide all method sections
document.querySelectorAll('.proxy-method-section').forEach(section => {
section.style.display = 'none';
});
// Show selected method section and update button
const selectedBtn = document.querySelector(`.method-btn[onclick*="${method}"]`);
if (selectedBtn) {
selectedBtn.style.background = 'linear-gradient(45deg, #ff00ff, #00ffff)';
selectedBtn.style.border = 'none';
selectedBtn.style.color = '#000';
}
// Show the selected method section
const methodSection = document.getElementById(`${method}-method`);
if (methodSection) {
methodSection.style.display = 'block';
}
}
// ClassLink Proxy Function
function encodeAndLoadClassLinkUrl() {
const urlInput = document.getElementById('classlink-url-input');
const proxyContent = document.getElementById('classlink-content');
let url = urlInput.value.trim();
if (!url) {
alert('Please enter a URL');
return;
}
// Add https:// if no protocol is specified
if (!url.startsWith('http://') && !url.startsWith('https://')) {
url = 'https://' + url;
}
console.log('Original URL:', url);
try {
// Show loading message
proxyContent.innerHTML = `
Loading...
Attempting to load: ${url}
`;
// Create a container for the iframe
const container = document.createElement('div');
container.style.width = '100%';
container.style.height = '100%';
container.style.position = 'relative';
// Create the iframe
const iframe = document.createElement('iframe');
// Set up iframe attributes
iframe.style.width = '100%';
iframe.style.height = '100vh';
iframe.style.border = 'none';
iframe.style.position = 'absolute';
iframe.style.top = '0';
iframe.style.left = '0';
iframe.allow = 'fullscreen';
iframe.referrerPolicy = 'no-referrer';
// Set the source URL directly to the Cloudflare worker with the target URL as a parameter
const targetUrl = encodeURIComponent(url);
iframe.src = `https://classlink.derekter127.workers.dev/proxy?url=${targetUrl}`;
// Add load event listener
iframe.addEventListener('load', function() {
console.log('iframe loaded');
const loadingDiv = proxyContent.querySelector('div');
if (loadingDiv) {
loadingDiv.remove();
}
});
// Add error event listener
iframe.addEventListener('error', function(error) {
console.error('iframe error:', error);
proxyContent.innerHTML = `
Failed to load content. Try About:Blank method instead.
Error loading: ${url}
`;
});
// Clear the content and add the new iframe
container.appendChild(iframe);
proxyContent.innerHTML = '';
proxyContent.appendChild(container);
} catch (error) {
console.error('Error in proxy function:', error);
proxyContent.innerHTML = `
An error occurred: ${error.message}
Failed URL: ${url}
`;
}
}
// Modified About:Blank function to accept URL parameter
function useAboutBlank(encodedUrl = null) {
const url = encodedUrl ?
decodeURIComponent(encodedUrl) :
document.getElementById('aboutblank-url-input').value.trim();
if (!url) {
alert('Please enter a URL');
return;
}
const win = window.open('about:blank', '_blank');
if (win) {
win.document.documentElement.innerHTML = `
`;
} else {
alert('Please allow popups for this site');
}
}
// iFrame Proxy Function
function useIframe() {
const urlInput = document.getElementById('iframe-url-input');
let url = urlInput.value.trim();
const iframeContent = document.getElementById('iframe-content');
if (!url) {
alert('Please enter a URL');
return;
}
// Add https:// if no protocol is specified
if (!url.startsWith('http://') && !url.startsWith('https://')) {
url = 'https://' + url;
}
// Show loading message
iframeContent.innerHTML = 'Loading...';
// Create and append iframe
const iframe = document.createElement('iframe');
iframe.src = url;
iframe.style.width = '100%';
iframe.style.height = '100%';
iframe.style.border = 'none';
// Add load event listener
iframe.onload = function() {
iframeContent.querySelector('div')?.remove();
};
iframe.onerror = function() {
iframeContent.innerHTML = 'Failed to load content. Please try again.';
};
iframeContent.appendChild(iframe);
}