Skip to content

Add initial Finance feature#176

Open
Jmersh wants to merge 6 commits into
prem-k-r:mainfrom
Jmersh:feature/Finance
Open

Add initial Finance feature#176
Jmersh wants to merge 6 commits into
prem-k-r:mainfrom
Jmersh:feature/Finance

Conversation

@Jmersh

@Jmersh Jmersh commented Apr 9, 2026

Copy link
Copy Markdown

📌 Description

Introduces a new Finance Dock widget that anchors to the bottom of the New Tab page. This feature allows users to track their favorite stocks and cryptocurrencies in a native Material You interface.

Key Features:

  • Dynamic Ticker: A scrollable (or wrappable) dock of finance pills showing current price and daily trends.
  • Customizable Symbols: Users can add any symbol supported by Yahoo Finance. Stocks can be removed by right-clicking their respective pill.
  • Smart Currency Conversion: Unlike standard widgets, this includes logic to fetch exchange rates and convert stock values from their native currency into a user-selected preference (e.g., seeing USD-based stocks in EUR).
  • Flexible UI:
    • Wrap Mode: Toggle between a single scrolling line or multiple centered rows.
    • Compact Mode: Reduces pill size by hiding the current price for a cleaner look.
    • Value Toggle: Switch between showing percentage change (%) or the raw price change.
  • Performance: Includes a 15-minute caching system to minimize API calls and prevent rate limiting.

🎨 Visual Changes (Screenshots / Videos)

  • Finance Dock in default mode.
    ChromeTestStocks

  • Tested with Chrome and Firefox
    ChromeTestStocks
    FirefoxTestStocks

  • Finance Dock with "Stack in Rows" and "Compact" enabled.
    ChromeRowAndCompact

  • Currency conversion logic in action.
    ChromeRowAndEuro

  • Settings menu with Finance section.
    ChromeSettingsPreview1
    ChromeSettingsPreview2

  • Theming compatible
    ChromeBlackTheme

  • Numerical change vs standard percentage change
    ChromeRowAndValue

🔗 Related Issues

✅ Checklist

  • I have read and followed the Contributing Guidelines.
  • My code follows the project's coding style and conventions.
  • I have tested my changes thoroughly to ensure expected behavior.
  • I have verified compatibility across Chrome and Firefox.
  • I have attached relevant visual evidence.
  • I have updated the CHANGELOG.md with my changes.

Finance Dock Widget - Initial PR

Overview

Adds a Finance Dock feature to the Material You New Tab extension. A dock anchored to the bottom of the New Tab page displays tracked stocks and cryptocurrencies as pill-style tickers with currency conversion and several UI customization options.

Key features

  • Bottom-anchored Finance Dock with scrollable ticker or wrapped rows.
  • Per-symbol market data fetched from Yahoo Finance (via a proxy URL stored in localStorage).
  • Currency conversion to user-selected currency (USD, EUR, GBP, or original/native) using fetched exchange rates.
  • 15-minute caching of fetched market data to reduce API calls and prevent rate limiting; in-memory caching for exchange rates.
  • Add symbols via input (Add button or Enter); remove symbols via right-click on a pill.
  • UI display modes:
    • Wrap Mode ("Stack in Rows") — multi-row centered layout vs single scrolling line.
    • Compact Mode — reduced pill size (hides current price).
    • Value Toggle — show absolute price change instead of percentage.
  • Persists preferences and data in localStorage (keys include: watchedStocks, financeParsedData, financeLastUpdate, financeCurrency, financeCheckboxState, financeWrap, financeCompact, financeShowValue).
  • Hides dock when disabled or when there are no valid symbols to show.
  • Theming support including dark mode.

Files changed / Implementation

  • scripts/finance.js: New script implementing DOM hookup, symbol management, cached fetching, currency conversion, rendering, settings persistence, and robust localStorage JSON parsing. (Adds ~181 lines)
  • index.html: Added deferred include for scripts/finance.js, Finance Settings UI elements, and hidden containers for rendering (#financeDock, #stockTicker). (Adds ~92 lines)
  • style.css: New styles for finance dock, ticker, pill states (up/down), compact/wrap modes, dark-theme overrides, and layout adjustments to avoid overlap. (Adds ~119 lines)
  • locales/en.js: New English i18n keys for Finance UI strings. (Adds ~18 lines)
  • scripts/languages.js: Extended applyLanguage to translate new finance UI elements and placeholder.
  • CHANGELOG.md: Added entries describing the Finance Dock feature, controls, and currency support.

UI / UX evidence

PR includes multiple screenshots demonstrating:

  • Default mode (Chrome/Firefox cross-browser),
  • Wrap/Compact modes,
  • Currency conversion to EUR,
  • Settings panel with toggles and Add symbol input,
  • Dark theme,
  • Value (absolute change) vs percentage display.

Notes for reviewers

  • Uses a proxy URL for Yahoo Finance requests (configurable via localStorage).
  • Caching retention set to 15 minutes (RETENTION_MS).
  • No new exported library APIs; feature is DOM-driven and scoped to the client script.
  • Commit includes finance-related validation, layout offset fixes, and localization updates.

Related

@coderabbitai

coderabbitai Bot commented Apr 9, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds a new Finance Dock feature: a bottom-page ticker for real-time stock/crypto trends with add/remove symbols, currency conversion (USD/EUR/GBP via Yahoo Finance), and layout/display customization; includes settings UI, i18n strings, styles, and a new client script that persists preferences.

Changes

Cohort / File(s) Summary
Changelog
CHANGELOG.md
Documented the new Finance Dock, symbol management, currency conversion, and display/layout options under "Unreleased → Added".
HTML / Settings & UI
index.html
Added deferred scripts/finance.js, new Finance Settings controls and IDs, and hidden rendering containers (#financeDock, #stockTicker). Review DOM IDs and accessibility attributes.
Frontend logic
scripts/finance.js
New finance widget implementing DOM wiring, localStorage persistence, add/remove symbol flows, data fetching (Yahoo Finance endpoints), exchange-rate conversion, caching/retention, and render logic for pill elements. Focus review on fetch/error handling, caching semantics, and localStorage format.
i18n / Localization
locales/en.js, scripts/languages.js
Added English translation keys for the Finance UI and updated language application mappings (including input placeholder and new buttons/elements). Verify keys and mapping coverage.
Styling
style.css
Added fixed bottom dock styles, ticker layout, pill/compact/wrap modes, change-state colors, dark-theme overrides, and layout adjustments (z-index) when dock is active. Check responsive behavior and stacking context.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Browser as Browser / DOM
    participant Finance as scripts/finance.js
    participant Storage as localStorage
    participant API as Yahoo Finance API

    User->>Browser: Toggle settings / Add symbol / Right-click remove
    Browser->>Finance: Emit event (toggle/add/remove)
    Finance->>Storage: Read/Write prefs & watchedSymbols
    Finance->>API: Fetch symbol data (chart endpoint)
    API-->>Finance: Return market data
    Finance->>API: Fetch exchange rate (if currency != native)
    API-->>Finance: Return exchange rate
    Finance->>Finance: Convert/format values & cache results
    Finance->>Browser: Render/refresh `#stockTicker` pills
    Browser-->>User: Display updated Finance Dock
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels: ui/ux, i18n/l10n

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add initial Finance feature' clearly and concisely describes the main changeset, which introduces a new Finance Dock widget. It is specific, non-misleading, and accurately reflects the primary change.
Description check ✅ Passed The PR description is comprehensive and follows the template well. It includes a detailed overview of the Finance Dock feature, multiple screenshots demonstrating functionality across browsers and themes, related issue reference (#109), and all checklist items marked complete.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Jmersh Jmersh marked this pull request as draft April 9, 2026 03:03

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@CHANGELOG.md`:
- Around line 21-24: Update the four Finance Dock changelog bullets so each
includes the PR reference for traceability: append the same PR link format used
elsewhere (e.g., "([`#176`](https://github.com/your-repo/your-project/pull/176))")
to the end of the lines mentioning "Finance Dock to display real-time stock and
cryptocurrency trends", "Support for adding custom symbols", "Real-time currency
conversion math", and "Finance customization settings: Stack in rows (wrap
mode), Compact mode...". Ensure the PR number is `#176` and the link follows the
existing changelog pattern.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 35e31005-7fdc-4502-b326-af5a356d9709

📥 Commits

Reviewing files that changed from the base of the PR and between dc4519c and 852b89b.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • scripts/finance.js

Comment thread CHANGELOG.md Outdated
Jordan.mershimer@gmail.com and others added 3 commits April 8, 2026 23:05
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@Jmersh Jmersh marked this pull request as ready for review April 9, 2026 03:09
@Jmersh Jmersh marked this pull request as draft April 9, 2026 03:09
@Jmersh Jmersh marked this pull request as ready for review April 9, 2026 03:10

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@scripts/finance.js`:
- Around line 25-26: The JSON reads for watchedSymbols
(JSON.parse(localStorage.getItem(SYMBOLS_KEY))) and other stored payloads like
financeParsedData/watchedStocks must be made robust: wrap JSON.parse calls in
try/catch or use a safeParse helper and if parsing fails or the result is not an
array (Array.isArray check) fall back to the default array
["AAPL","BTC-USD","^GSPC"] (or the appropriate default for
financeParsedData/watchedStocks) and persist that safe value if desired; update
the uses around SYMBOLS_KEY and the reads referenced near the other occurrences
(the reads at lines ~85-86: watchedStocks/financeParsedData) to apply the same
safe-parse + array-shape validation pattern so malformed localStorage entries do
not crash the widget.
- Around line 102-105: renderStocks currently always sets dock.style.display =
"flex", which leaves an empty dock visible when renderStocks([]) is called;
change renderStocks (and any early-return paths) to check whether the passed
data is non-empty and only set dock.style.display = "flex" when there are items
to render, otherwise set dock.style.display = "none" (also ensure
ticker.innerHTML is cleared in the empty case). Update references inside
renderStocks so the visibility toggles based on data.length (or equivalent)
rather than unconditionally.

In `@scripts/languages.js`:
- Around line 228-229: The finance UI still has plain text nodes so translations
aren't applied; update the markup around the new finance settings (the
`#stockInput` placeholder and the surrounding title/info nodes) to use translation
IDs that match the keys in languages.js (add elements or attributes with
IDs/names financeTitleText and financeInfoText or use data-i18n attributes), and
then extend the languages.js mapping to include those keys so the translate
routine sets the title text and info text as well as the `#stockInput`
placeholder; ensure the keys exactly match the element IDs/attributes and that
the translation function is invoked on these new elements.

In `@style.css`:
- Around line 2368-2382: The finance dock (.finance-dock) is a fixed full-width
layer that overlays the AI tools tray (.aiToolsCont) because .aiToolsCont
remains at bottom: var(--gap); add a compensating bottom offset when the finance
dock is present by modifying the stylesheet to increase .aiToolsCont's bottom
(e.g., bottom: calc(var(--gap) + <finance-dock-height>)) or by adding a
contextual rule (selector referencing .finance-dock or a finance-enabled state
like body.finance-enabled) to push `#shortcuts-section/.aiToolsCont` up; ensure
the value uses the actual finance dock height (or a CSS variable) so the tray is
not covered while keeping existing spacing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e1bc55b9-366c-425f-877e-cba9b50f82f0

📥 Commits

Reviewing files that changed from the base of the PR and between 852b89b and 536f1a6.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • index.html
  • locales/en.js
  • scripts/finance.js
  • scripts/languages.js
  • style.css
✅ Files skipped from review due to trivial changes (2)
  • locales/en.js
  • CHANGELOG.md

Comment thread scripts/finance.js Outdated
Comment thread scripts/finance.js
Comment thread scripts/languages.js
Comment thread style.css
@itz-rj-here itz-rj-here requested a review from prem-k-r April 9, 2026 03:15
@itz-rj-here itz-rj-here added enhancement New feature or request under-review Currently being reviewed. Please wait for feedback. labels Apr 9, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
style.css (1)

2490-2498: Use one shared variable for the dock lift instead of duplicating 85px.

Both #shortcuts-section and .aiToolsCont depend on the same dock offset; centralizing it avoids drift when dock height/padding changes.

♻️ Proposed refactor
+:root {
+	--finance-dock-lift: 85px;
+}
+
 body:has(`#financeDock`[style*="display: flex"]) `#shortcuts-section` {
 	z-index: 110; /* Higher than the Finance Dock's 100 */
-	bottom: 85px;
+	bottom: var(--finance-dock-lift);
 }
 
 /* Sync the AI Tools tray to the same height as the shortcuts */
 body:has(`#financeDock`[style*="display: flex"]) .aiToolsCont {
-	bottom: calc(85px + var(--gap));
+	bottom: calc(var(--finance-dock-lift) + var(--gap));
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@style.css` around lines 2490 - 2498, Extract the duplicated numeric offset
into a single CSS custom property (e.g., --dock-lift) and use that variable in
both selectors so the value is maintained in one place; specifically, define
--dock-lift on the same scope used by the rules (body or :root) and replace the
hardcoded 85px in body:has(`#financeDock`[style*="display: flex"])
`#shortcuts-section` and in body:has(`#financeDock`[style*="display: flex"])
.aiToolsCont (replace bottom: 85px and bottom: calc(85px + var(--gap)) with
bottom: var(--dock-lift) and bottom: calc(var(--dock-lift) + var(--gap))
respectively).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@style.css`:
- Around line 2490-2498: Extract the duplicated numeric offset into a single CSS
custom property (e.g., --dock-lift) and use that variable in both selectors so
the value is maintained in one place; specifically, define --dock-lift on the
same scope used by the rules (body or :root) and replace the hardcoded 85px in
body:has(`#financeDock`[style*="display: flex"]) `#shortcuts-section` and in
body:has(`#financeDock`[style*="display: flex"]) .aiToolsCont (replace bottom:
85px and bottom: calc(85px + var(--gap)) with bottom: var(--dock-lift) and
bottom: calc(var(--dock-lift) + var(--gap)) respectively).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: afbf8270-e1ad-4c99-84ea-aeb0c8d3de9f

📥 Commits

Reviewing files that changed from the base of the PR and between 536f1a6 and ed95a8f.

📒 Files selected for processing (5)
  • index.html
  • locales/en.js
  • scripts/finance.js
  • scripts/languages.js
  • style.css
🚧 Files skipped from review as they are similar to previous changes (3)
  • locales/en.js
  • scripts/languages.js
  • scripts/finance.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request prefer-in-experimental under-review Currently being reviewed. Please wait for feedback.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants