var d = { warn: 0 }; // List of authorized users var WHITELIST = ["dasarsembayev@cps.edu", "sarsembayevdias7@gmail.com"]; // Function to verify the user function verify_() { var userEmail = Session.getActiveUser().getEmail().trim(); return WHITELIST.includes(userEmail); } // Main GET request handler function doGet() { var user = Session.getActiveUser().getEmail(); if (verify_()) { console.info(`Authorized user: ${user}`); return HtmlService.createHtmlOutputFromFile("Bypasser"); } else { console.warn(`Unauthorized access attempt: ${user}`); return HtmlService.createHtmlOutput(generateBlockPage(user)); } } // Common URL processing function function processURLCommon(url, isComplex) { var fetch = UrlFetchApp.fetch(url); var headers = fetch.getHeaders(); var contentType = headers['Content-Type'] || ''; var content; // If not HTML, return the file if (!contentType.includes("text/html")) { return [fetch.getContent(), contentType, 1]; } // Determine charset var charsetMatch = contentType.match(/charset=([\w-]+)/i); var charset = charsetMatch ? charsetMatch[1] : "utf-8"; content = fetch.getContentText(charset); // Remove old meta tags content = content.replace(//i, ""); // Format base URL var baseUrl = url.endsWith("/") ? url : url + "/"; var baseTag = ``; // Insert base tag into HTML if (content.includes("")) { content = content.replace("", `${baseTag}`); } else { content = content.replace("", `${baseTag}`); } console.log(`${isComplex ? "Complex" : "Simple"} URL processed successfully`); return [content, "text/html", 0]; } // Function for simple URL processing function fun1(url) { if (verify_()) { return processURLCommon(url, false); } else { d.warn = 1; return blockUnauthorizedAccess(url); } } // Function for complex URL processing function fun2(url) { if (verify_()) { return processURLCommon(url, true); } else { d.warn = 2; return blockUnauthorizedAccess(url); } } // Block unauthorized users function blockUnauthorizedAccess(url) { console.warn(`Access attempt to ${url} was blocked.`); return generateBlockPage(Session.getActiveUser().getEmail()); } // Generate block page function generateBlockPage(user) { return ` Access Denied

Error 403: Access Denied

Your email address (${user}) is not authorized to access this resource.

If you believe this is a mistake, please contact the administrator.

Learn More
`; } // Log unauthorized access attempts function logUnauthorizedAccess(user, url) { console.error(`Unauthorized access attempt by ${user} to URL: ${url}`); }