Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the Proxy Disclaimer Cancel Button Issue #211

Merged
merged 2 commits into from
Nov 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 39 additions & 27 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -1185,30 +1185,33 @@ document.getElementById("searchQ").addEventListener("input", async function () {
const resultBox = document.getElementById("resultBox");

if (query.length > 0) {
// Fetch autocomplete suggestions
const suggestions = await getAutocompleteSuggestions(query);
try {
// Fetch autocomplete suggestions
const suggestions = await getAutocompleteSuggestions(query);

if (suggestions == "") {
hideResultBox();
} else {
// Clear the result box
resultBox.innerHTML = '';

// Add suggestions to the result box
suggestions.forEach((suggestion, index) => {
const resultItem = document.createElement("div");
resultItem.classList.add("resultItem");
resultItem.textContent = suggestion;
resultItem.setAttribute("data-index", index);
resultItem.onclick = () => {
var resultlink = searchEngines[selectedOption] + encodeURIComponent(suggestion);
window.location.href = resultlink;
};
resultBox.appendChild(resultItem);
});
showResultBox();
if (suggestions == "") {
hideResultBox();
} else {
// Clear the result box
resultBox.innerHTML = '';

// Add suggestions to the result box
suggestions.forEach((suggestion, index) => {
const resultItem = document.createElement("div");
resultItem.classList.add("resultItem");
resultItem.textContent = suggestion;
resultItem.setAttribute("data-index", index);
resultItem.onclick = () => {
var resultlink = searchEngines[selectedOption] + encodeURIComponent(suggestion);
window.location.href = resultlink;
};
resultBox.appendChild(resultItem);
});
showResultBox();
}
} catch (error) {
// Handle the error (if needed)
}

} else {
hideResultBox();
}
Expand Down Expand Up @@ -1962,7 +1965,7 @@ document.addEventListener("DOMContentLoaded", function () {
function showProxyDisclaimer() {
const message = "All proxy features are off by default.\n\nIf you enable search suggestions and CORS bypass proxy, it is strongly recommended to host your own proxy for enhanced privacy.\n\nBy default, the proxy will be set to https://mynt-proxy.rhythmcorehq.com, meaning all your data will go through this service, which may pose privacy concerns.";

confirm(message);
return confirm(message);
}

/* ------ Event Listeners ------ */
Expand Down Expand Up @@ -2047,12 +2050,21 @@ document.addEventListener("DOMContentLoaded", function () {
updatedigiClock();
});
useproxyCheckbox.addEventListener("change", function () {
saveCheckboxState("useproxyCheckboxState", useproxyCheckbox);
if (useproxyCheckbox.checked) {
showProxyDisclaimer();
proxyinputField.classList.remove("inactive");
saveActiveStatus("proxyinputField", "active");
// Show the disclaimer and check the user's choice
const userConfirmed = showProxyDisclaimer();
if (userConfirmed) {
// Only enable the proxy if the user confirmed
saveCheckboxState("useproxyCheckboxState", useproxyCheckbox);
proxyinputField.classList.remove("inactive");
saveActiveStatus("proxyinputField", "active");
} else {
// Revert the checkbox state if the user did not confirm
useproxyCheckbox.checked = false;
}
} else {
// If the checkbox is unchecked, disable the proxy
saveCheckboxState("useproxyCheckboxState", useproxyCheckbox);
proxyinputField.classList.add("inactive");
saveActiveStatus("proxyinputField", "inactive");
}
Expand Down