diff --git a/chrome/background.js b/chrome/background.js index f0c05a7..8aa8a80 100644 --- a/chrome/background.js +++ b/chrome/background.js @@ -10,16 +10,16 @@ function toLocalISOString(date) { function addArticleToTree(title, url, parentUrl) { // If there's no parent, this is a root article if (!parentUrl) { - articlesTree[url] = articlesTree[url] || { title, children: {} }; + articlesTree[url] = articlesTree[url] || { title, url, children: {} }; } else { // Recursively search for the parent node in the tree const parentNode = findParentNode(articlesTree, parentUrl); if (parentNode) { // Add the article under its parent - parentNode.children[url] = parentNode.children[url] || { title, children: {} }; + parentNode.children[url] = parentNode.children[url] || { title, url, children: {} }; } else { // If the parent node is not found, treat it as a root article - articlesTree[url] = articlesTree[url] || { title, children: {} }; + articlesTree[url] = articlesTree[url] || { title, url, children: {} }; } } // Save the updated tree to storage diff --git a/chrome/popup.js b/chrome/popup.js index 481427c..638d658 100644 --- a/chrome/popup.js +++ b/chrome/popup.js @@ -82,14 +82,17 @@ document.addEventListener('DOMContentLoaded', function() { .attr("fill", d => d.children ? "#555" : "#999") .attr("r", 2.5); - node.append("text") - .attr("dy", "0.31em") - .attr("x", d => d.children ? -6 : 6) - .attr("text-anchor", d => d.children ? "end" : "start") - .text(d => d.data.title) - .attr("fill", "black") // Set the text color - .clone(true).lower() - .attr("stroke", "white"); // Remove the stroke or set to a contrasting color if needed + node.append("a") + .attr("xlink:href", d => d.data.url || null) + .attr("target", "_blank") // Opens link in a new tab + .append("text") + .attr("dy", "0.31em") + .attr("x", d => d.children ? -6 : 6) + .attr("text-anchor", d => d.children ? "end" : "start") + .text(d => d.data.title) + .attr("fill", "black") // Set the text color + .clone(true).lower() + .attr("stroke", "white"); // Remove the stroke or set to a contrasting color if needed // Add this SVG to your popup diff --git a/firefox/background.js b/firefox/background.js index 3d56289..30cfe1a 100644 --- a/firefox/background.js +++ b/firefox/background.js @@ -10,16 +10,16 @@ function toLocalISOString(date) { function addArticleToTree(title, url, parentUrl) { // If there's no parent, this is a root article if (!parentUrl) { - articlesTree[url] = articlesTree[url] || { title, children: {} }; + articlesTree[url] = articlesTree[url] || { title, url, children: {} }; } else { // Recursively search for the parent node in the tree const parentNode = findParentNode(articlesTree, parentUrl); if (parentNode) { // Add the article under its parent - parentNode.children[url] = parentNode.children[url] || { title, children: {} }; + parentNode.children[url] = parentNode.children[url] || { title, url, children: {} }; } else { // If the parent node is not found, treat it as a root article - articlesTree[url] = articlesTree[url] || { title, children: {} }; + articlesTree[url] = articlesTree[url] || { title, url, children: {} }; } } // Save the updated tree to storage diff --git a/firefox/popup.js b/firefox/popup.js index 98f3784..dc4fc97 100644 --- a/firefox/popup.js +++ b/firefox/popup.js @@ -82,14 +82,17 @@ document.addEventListener('DOMContentLoaded', function() { .attr("fill", d => d.children ? "#555" : "#999") .attr("r", 2.5); - node.append("text") - .attr("dy", "0.31em") - .attr("x", d => d.children ? -6 : 6) - .attr("text-anchor", d => d.children ? "end" : "start") - .text(d => d.data.title) - .attr("fill", "black") // Set the text color - .clone(true).lower() - .attr("stroke", "white"); // Remove the stroke or set to a contrasting color if needed + node.append("a") + .attr("xlink:href", d => d.data.url || null) + .attr("target", "_blank") // Opens link in a new tab + .append("text") + .attr("dy", "0.31em") + .attr("x", d => d.children ? -6 : 6) + .attr("text-anchor", d => d.children ? "end" : "start") + .text(d => d.data.title) + .attr("fill", "black") // Set the text color + .clone(true).lower() + .attr("stroke", "white"); // Remove the stroke or set to a contrasting color if needed // Add this SVG to your popup