Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 4 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1538,7 +1538,7 @@ <h1>Material You New Tab</h1>
type="text">
<div class="bottom">
<a href="https://github.com/Minuga-RC/MYNT-CORS-Bypass-Proxy"
id="HostproxyButton" target="_blank">Host your own proxy</a>
id="HostproxyButton" target="_blank" rel="noopener noreferrer">Host your own proxy</a>
<button class="savebtn" id="saveproxy">Save</button>
</div>
</div>
Expand Down Expand Up @@ -1622,7 +1622,7 @@ <h1>Material You New Tab</h1>

<div class="bottom">
<a href="https://prem-k-r.github.io/MaterialYouNewTab/privacy-policy.html"
id="PrivacyPolicy" target="_blank">Privacy policy</a>
id="PrivacyPolicy" target="_blank" rel="noopener noreferrer">Privacy policy</a>
<button class="savebtn" id="saveLoc">Save</button>
</div>
</div>
Expand All @@ -1648,7 +1648,7 @@ <h1>Material You New Tab</h1>
<input id="userAPI" placeholder="Your weatherAPI key" type="text">
<div class="bottom">
<a href="https://prem-k-r.github.io/MaterialYouNewTab/docs/Get_WeatherAPI_Key.html"
id="LearnMoreButton" target="_blank">Learn more</a>
id="LearnMoreButton" target="_blank" rel="noopener noreferrer">Learn more</a>
<button class="savebtn" id="saveAPI">Save</button>
</div>
</div>
Expand Down Expand Up @@ -1905,7 +1905,7 @@ <h1>Material You New Tab</h1>
<div class="infoText" id="updateFirefoxHomepageInfo">To change your homepage
like the new tab as well, visit <a
href="https://github.com/prem-k-r/MaterialYouNewTab#-firefox"
target="_blank">this link</a> and follow the instructions.
target="_blank" rel="noopener noreferrer">this link</a> and follow the instructions.
</div>
</div>
</div>
Expand Down
2 changes: 0 additions & 2 deletions scripts/backup-restore.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ async function backupData() {
document.body.appendChild(link);
link.click();
document.body.removeChild(link);

console.log("Backup completed successfully!");
} catch (error) {
await alertPrompt((translations[currentLanguage]?.failedbackup || translations["en"].failedbackup) + error.message);
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/bookmarks.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const sortAlphabetical = document.getElementById("sortAlphabetical");
const sortTimeAdded = document.getElementById("sortTimeAdded");
let currentSortMethod = localStorage.getItem("bookmarkSortMethod") || 'title';

var bookmarksAPI;
let bookmarksAPI;
if (isFirefox) {
bookmarksAPI = browser.bookmarks;
} else if (isChromiumBased) {
Expand Down Expand Up @@ -300,7 +300,7 @@ function setBookmarkFavicon(faviconElement, pageUrl) {
};

// Try browser-specific favicon first (Chromium only)
if (!isFirefox || !isOpera) {
if (!isFirefox && !isOpera) {
faviconElement.src = `chrome-extension://${chrome.runtime.id}/_favicon/?pageUrl=${encodeURIComponent(pageUrl)}&size=32`;
faviconElement.onerror = googleFallback;
} else {
Expand Down
30 changes: 15 additions & 15 deletions scripts/clock.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ async function initializeClock() {
let isFirstLoad = true;

// Retrieve current time and calculate initial angles
var currentTime = new Date();
var initialSeconds = currentTime.getSeconds();
var initialMinutes = currentTime.getMinutes();
var initialHours = currentTime.getHours();
const currentTime = new Date();
const initialSeconds = currentTime.getSeconds();
const initialMinutes = currentTime.getMinutes();
const initialHours = currentTime.getHours();

// Initialize cumulative rotations
cumulativeSecondRotation = initialSeconds * 6;
Expand All @@ -123,22 +123,22 @@ async function initializeClock() {

function updateDate() {
if (clocktype === "analog") {
var currentTime = new Date();
var dayOfWeek = currentTime.getDay();
var dayOfMonth = currentTime.getDate();
var month = currentTime.getMonth();
const currentTime = new Date();
const dayOfWeek = currentTime.getDay();
const dayOfMonth = currentTime.getDate();
const month = currentTime.getMonth();

// Define the current language
const currentLanguage = getLanguageStatus("selectedLanguage") || "en";

// Get the translated name of the day
var dayName = translations[currentLanguage]?.days?.[dayOfWeek] ?? translations["en"].days[dayOfWeek];
const dayName = translations[currentLanguage]?.days?.[dayOfWeek] ?? translations["en"].days[dayOfWeek];

// Get the translated name of the month
var monthName = translations[currentLanguage]?.months?.[month] ?? translations["en"].months[month];
const monthName = translations[currentLanguage]?.months?.[month] ?? translations["en"].months[month];

// Localize the day of the month
var localizedDayOfMonth = localizeNumbers(dayOfMonth.toString(), currentLanguage);
const localizedDayOfMonth = localizeNumbers(dayOfMonth.toString(), currentLanguage);

// DATE DISPLAY FOR ANALOG CLOCK
const dateDisplay = {
Expand Down Expand Up @@ -211,10 +211,10 @@ async function initializeClock() {
}

function updateanalogclock() {
var currentTime = new Date();
var currentSeconds = currentTime.getSeconds();
var currentMinutes = currentTime.getMinutes();
var currentHours = currentTime.getHours();
const currentTime = new Date();
const currentSeconds = currentTime.getSeconds();
const currentMinutes = currentTime.getMinutes();
const currentHours = currentTime.getHours();

// Calculate the new rotation values
let newSecondRotation = currentSeconds * 6; // 6Β° per second
Expand Down
2 changes: 1 addition & 1 deletion scripts/search-suggestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ let lastRedditRequestTime = 0;

async function getAutocompleteSuggestions(query) {
const clientParam = getClientParam(); // Get the browser client parameter dynamically
var selectedOption = document.querySelector('input[name="search-engine"]:checked').value;
const selectedOption = document.querySelector('input[name="search-engine"]:checked').value;

// πŸ”’ Throttle Reddit API calls
const now = Date.now();
Expand Down
28 changes: 14 additions & 14 deletions scripts/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,11 @@ function performSearch(query) {
}
} catch (error) {
// Fallback to Google if an error occurs
var fallbackUrl = searchQueryURLs.engine1 + encodeURIComponent(searchTerm);
const fallbackUrl = searchQueryURLs.engine1 + encodeURIComponent(searchTerm);
window.location.href = fallbackUrl;
}
} else {
var searchUrl = searchQueryURLs[selectedOption] + encodeURIComponent(searchTerm);
const searchUrl = searchQueryURLs[selectedOption] + encodeURIComponent(searchTerm);
window.location.href = searchUrl;
}
}
Expand Down Expand Up @@ -259,23 +259,23 @@ if (storedSearchEngine) {
const dropdownItems = document.querySelectorAll(".dropdown-item:not(*[data-default])");
let selectedIndex = -1;

// Function to update the selected item
// Attach mouse hover listeners once (not on every keydown)
dropdownItems.forEach((item) => {
item.addEventListener("mouseenter", () => {
item.classList.add("selected");
});
item.addEventListener("mouseleave", () => {
item.classList.remove("selected");
});
});
Comment on lines +262 to +270

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚑ Quick win

Clear existing .selected before applying mouse hover selection.

Hover now only adds/removes class per item, so multiple dropdown items can stay .selected; Enter may then pick the wrong one via querySelector(".selected").

Suggested fix
 dropdownItems.forEach((item) => {
     item.addEventListener("mouseenter", () => {
+        dropdownItems.forEach((el) => el.classList.remove("selected"));
         item.classList.add("selected");
+        selectedIndex = Array.from(dropdownItems).indexOf(item);
     });
     item.addEventListener("mouseleave", () => {
         item.classList.remove("selected");
     });
 });
πŸ€– Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/search.js` around lines 262 - 270, The mouseenter handler on
dropdownItems currently only adds the "selected" class to the hovered item,
allowing multiple items to remain selected and breaking lookup by
document.querySelector(".selected"); update the handlers for the dropdownItems
loop so that on "mouseenter" you first remove "selected" from any currently
selected item (e.g., document.querySelectorAll or
document.querySelector(".selected") and remove the class) and then add
"selected" to the hovered item, and ensure "mouseleave" still removes the class
from the hovered item; reference the dropdownItems.forEach loop and the
"mouseenter"/"mouseleave" handlers to locate where to change behavior.


// Function to update the selected item (keyboard navigation only)
function updateSelection() {
// let hasSelected = [];
dropdownItems.forEach((item, index) => {

item.addEventListener("mouseenter", () => {
item.classList.add("selected");
})
item.addEventListener("mouseleave", () => {
item.classList.remove("selected");
})

if (index === selectedIndex) {
item.focus()
item.focus();
item.classList.add("selected");
} else {
item.focus()
item.classList.remove("selected");
}
});
Expand Down