Skip to content

Commit 3f2c31e

Browse files
committed
Rebranding, cache improvement and overall cleaning
1 parent 0558022 commit 3f2c31e

File tree

13 files changed

+64
-27
lines changed

13 files changed

+64
-27
lines changed

.github/branding_banner.png

-28.9 KB
Binary file not shown.

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
![Image](.github/branding_banner.png)
2-
1+
# Homepage++
32
A web browser extension that allows you to customize your new tab/homepage with themes, weather and more. I made this many years ago when I was still learning web development, since many people still loved it back in the days when it was first released.
43

54
Goal is to make it as lightweight as possible, meaning no unnecessary bloat or dependency. Just a simple and clean homepage, made to be using most of the vanilla web technologies.
65

76
> [!NOTE]
8-
> If you want to test it out before downloading it, you can visit https://alexflipnote.dev/homepage which is the demo page. Some of the functions are available to test, but not all of them for obvious reasons.
7+
> If you want to test it out before downloading it, you can visit https://alexflipnote.dev/homepageplusplus which is the demo page. Some of the functions are available to test, but not all of them for obvious reasons.
98
109
## Platforms
1110
- [Chrome](https://chromewebstore.google.com/detail/alexflipnotehomepage/npagigfpfilcemncemkphndcaigegcbk) (or literally any* Chromium-based browser)
@@ -26,7 +25,7 @@ If you want to contribute with translations, feel free to do so by following the
2625
## Development
2726
In order to set up the development environment, you need to have [NodeJS](https://nodejs.org/) installed on your machine. After that, you can clone the repository and install the dependencies using npm or yarn.
2827
```bash
29-
git clone https://github.com/AlexFlipnote/homepage
28+
git clone https://github.com/AlexFlipnote/homepageplusplus
3029
cd homepage
3130
npm install
3231
```

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "alexflipnote_homepage",
2+
"name": "homepageplusplus",
33
"author": "AlexFlipnote",
4-
"homepage": "https://alexflipnote.dev/homepage/",
4+
"homepage": "https://alexflipnote.dev/homepageplusplus/",
55
"type": "module",
66
"scripts": {
77
"clean": "node build.js clean",

src/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--
22
Created by AlexFlipnote
3-
https://github.com/AlexFlipnote/homepage
3+
https://github.com/AlexFlipnote/homepageplusplus
44
-->
55
<!DOCTYPE html>
66
<html>
@@ -12,7 +12,7 @@
1212

1313
<!-- Meta data for public demo -->
1414
<link rel="icon" type="image/x-icon" href="./images/favicon.ico">
15-
<meta content="AlexFlipnote/Homepage" property="og:title">
15+
<meta content="Homepage++" property="og:title">
1616
<meta content="A website that gives you a clean homepage." property="og:description">
1717
<meta content="A website that gives you a clean homepage." name="description">
1818
<meta name="revisit-after" content="2 days">

src/js/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ function createBookmark(
3434
) {
3535
const container = document.createElement("a")
3636
container.href = url
37+
container.title = name
3738

3839
if (isAuto) {
3940
container.setAttribute("data-auto", "true")
@@ -191,7 +192,7 @@ if (isExtension) {
191192

192193
// Create some boiler plate bookmarks
193194
const bookmarksList = document.getElementById("bookmarks")
194-
createBookmark(bookmarksList, "Github", "https://github.com/AlexFlipnote/homepage", {
195+
createBookmark(bookmarksList, "Github", "https://github.com/AlexFlipnote/homepageplusplus", {
195196
localFavicon: "images/icons/github.png"
196197
})
197198
createBookmark(bookmarksList, "Discord", "https://discord.gg/yqb7vATbjH", {

src/js/utils/cache.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,33 @@ export class Cache {
1212
return result[this.rootKey] || {}
1313
}
1414

15+
/**
16+
* Purge expired items from the cache
17+
*/
18+
async purgeExpired() {
19+
const store = await this._getStore()
20+
const now = Date.now()
21+
let modified = false
22+
for (const key in store) {
23+
const item = store[key]
24+
if (item.expiry && now > item.expiry) {
25+
delete store[key]
26+
modified = true
27+
}
28+
}
29+
if (modified) {
30+
await chrome.storage.local.set({ [this.rootKey]: store })
31+
}
32+
}
33+
1534
/**
1635
* Get a value inside the cache object
1736
* @param {string} key - The sub-key (e.g., 'profile')
1837
* @returns {any} The cached data or null if not found/expired
1938
*/
2039
async get(key) {
40+
await this.purgeExpired()
41+
2142
const store = await this._getStore()
2243
const item = store[key]
2344

src/js/utils/http.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export async function http(method, url) {
1414
headers: {
1515
"Content-Type": "application/json",
1616
// The only reason I use X-* headers is because some browsers refuse to set custom "unsafe headers"
17-
"X-Referer": "https://alexflipnote.dev/homepage",
17+
"X-Referer": "https://alexflipnote.dev/homepageplusplus",
1818
"X-User-Agent": `AlexFlipnoteHomepage/${manifest.version}`
1919
}
2020
})

src/js/utils/settings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
export const extensionSettings = {
44
language: "",
55
searchbar: false,
6-
animations: true,
6+
animations: false,
77
custombg: [],
88
show_time: true,
99
show_date: true,

src/js/utils/weather.js

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ class WeatherData {
1818

1919
export async function getWeather(items, position, lang) {
2020
const cache = new Cache()
21+
2122
const pos = position.coords
22-
const cacheKey = `weatherLocation_${pos.latitude}_${pos.longitude}`
23+
const posPrefix = `${pos.latitude.toFixed(2)},${pos.longitude.toFixed(2)}`
24+
25+
const weatherCacheKey = `weatherData_${posPrefix}`
26+
const locationCacheKey = `weatherLocation_${posPrefix}`
2327

2428
const wtemp = document.getElementById("wtemp")
2529
const wname = document.getElementById("wname")
@@ -32,12 +36,24 @@ export async function getWeather(items, position, lang) {
3236
}
3337
}
3438

35-
const weatherResponse = await http(
36-
"GET",
37-
`https://api.met.no/weatherapi/locationforecast/2.0/compact?lat=${pos.latitude}&lon=${pos.longitude}`
38-
)
39+
// Check if weather data is cached (5 minutes)
40+
const cachedWeather = await cache.get(weatherCacheKey)
41+
42+
let weatherData
43+
if (cachedWeather) {
44+
console.log("📦 Cache: Fetched weather data from cache")
45+
weatherData = new WeatherData(cachedWeather, lang || "en")
46+
} else {
47+
const weatherResponse = await http(
48+
"GET",
49+
`https://api.met.no/weatherapi/locationforecast/2.0/compact?lat=${pos.latitude}&lon=${pos.longitude}`
50+
)
51+
const weatherDataRaw = weatherResponse.properties.timeseries[0].data
52+
weatherData = new WeatherData(weatherDataRaw, lang || "en")
53+
// Cache weather data for 5 minutes (300 seconds)
54+
cache.set(weatherCacheKey, weatherDataRaw, 300)
55+
}
3956

40-
const weatherData = new WeatherData(weatherResponse.properties.timeseries[0].data, lang || "en")
4157
document.getElementById("wicon").src = `images/weather/${weatherData.symbol_code}.png`
4258
document.getElementById("wdescription").innerText = weatherData.prettyName()
4359
if (items.temp_type === "fahrenheit") {
@@ -48,7 +64,7 @@ export async function getWeather(items, position, lang) {
4864
showWeatherContainer()
4965

5066
// OpenStreetMap API can be rate limited, so we cache the location name for 1 hour
51-
const weatherLocation = await cache.get(cacheKey)
67+
const weatherLocation = await cache.get(locationCacheKey)
5268

5369
if (weatherLocation) {
5470
console.log("📦 Cache: Fetched location name from cache")
@@ -65,7 +81,7 @@ export async function getWeather(items, position, lang) {
6581
"Unknown Location"
6682
)
6783
showWeatherContainer()
68-
cache.set(cacheKey, wname.innerText)
84+
cache.set(locationCacheKey, wname.innerText)
6985

7086
}
7187

src/manifest.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"manifest_version": 3,
33

4-
"name": "AlexFlipnote/Homepage",
4+
"name": "Homepage++",
55
"description": "A website that gives you a clean homepage.",
6-
"homepage_url": "https://alexflipnote.dev/homepage/",
7-
"version": "2.4.3",
6+
"homepage_url": "https://alexflipnote.dev/homepageplusplus/",
7+
"version": "2.5.0",
88

99
"chrome_url_overrides": {
1010
"newtab": "index.html"

0 commit comments

Comments
 (0)