From fac1a84dc0d47e2aaed3036fa69f0d452c54c44c Mon Sep 17 00:00:00 2001 From: Entrpi <133157614+Entrpi@users.noreply.github.com> Date: Wed, 18 Nov 2026 11:29:18 +1100 Subject: [PATCH 1/4] Fix the weather reload loop with Google icons --- .../ep_weather_provider_google_script.h | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ep_weather_host/ep_weather_provider_google_script.h b/ep_weather_host/ep_weather_provider_google_script.h index 9d43a2a53..d2ad51f81 100644 --- a/ep_weather_host/ep_weather_provider_google_script.h +++ b/ep_weather_host/ep_weather_provider_google_script.h @@ -4,10 +4,18 @@ // many thanks to https://stackoverflow.com/questions/23202966/google-weather-widget-on-my-website #define EP_WEATHER_PROVIDER_GOOGLE_SCRIPT_LEN 30000 -LPCWSTR ep_weather_provider_google_script10 = L"var final_im = 0; function ep_weather_part0() { return \"run_part_0\"; }; ep_weather_part0();"; +#define EP_WEATHER_GOOGLE_ICON_HELPER \ + L"function ep_weather_icon() {\n" \ + L" var im = document.querySelector('#wob_wc img') || document.querySelector('img.YQ4gaf.zr758c');\n" \ + L" if (!im) { throw new Error('Google weather icon not found; page layout may have changed'); }\n" \ + L" return im;\n" \ + L"}\n" + +LPCWSTR ep_weather_provider_google_script10 = EP_WEATHER_GOOGLE_ICON_HELPER + L"var final_im = 0; function ep_weather_part0() { return \"run_part_0\"; }; ep_weather_part0();"; // reference: https://github.com/Triggertrap/sun-js -LPCWSTR ep_weather_provider_google_script00 = L"\ +LPCWSTR ep_weather_provider_google_script00 = EP_WEATHER_GOOGLE_ICON_HELPER L"\ Date.prototype.sunrise = function(latitude, longitude, zenith) {\n\ return this.sunriseSet(latitude, longitude, true, zenith);\n\ }\n\ @@ -101,11 +109,6 @@ Math.mod = function(a, b) {\n\ }\n\ \n\ \n\ -function ep_weather_icon() {\n\ - var im = document.querySelector('#wob_wc img') || document.querySelector('img.YQ4gaf.zr758c');\n\ - if (!im) { throw new Error('Google weather icon not found; page layout may have changed'); }\n\ - return im;\n\ -}\n\ var is_first_time = 1;\n\ var final_im = 0;\n\ var final_img2 = 0;\n\ @@ -386,4 +389,4 @@ let slim_appbar = document.getElementById(\"slim_appbar\"); if (slim_appbar) { s scrolldisable();\n\ ep_weather_part2();\n\ "; -#endif \ No newline at end of file +#endif From 8c82fee78651a431886abdf6d90c0d44dea524ef Mon Sep 17 00:00:00 2001 From: Entrpi <133157614+Entrpi@users.noreply.github.com> Date: Wed, 18 Nov 2026 11:44:15 +1100 Subject: [PATCH 2/4] Add an original ExplorerPatcher weather icon pack --- ep_gui/resources/settings.reg | 3 +- ep_gui/resources/settings10.reg | 3 +- ep_weather_host/ep_weather.h | 1 + ep_weather_host/ep_weather_host.c | 95 +++-- ep_weather_host/ep_weather_host.rc | 4 + ep_weather_host/ep_weather_host.vcxproj | 6 +- .../ep_weather_provider_google_script.h | 19 +- ep_weather_host/open_icons/CC0-1.0.txt | 121 ++++++ ep_weather_host/open_icons/README.md | 7 + ep_weather_host/open_icons/artwork.js | 130 ++++++ ep_weather_host/open_icons/conditions.js | 386 ++++++++++++++++++ ep_weather_host/open_icons/render.js | 80 ++++ ep_weather_host/resource.h | 5 +- 13 files changed, 816 insertions(+), 44 deletions(-) create mode 100644 ep_weather_host/open_icons/CC0-1.0.txt create mode 100644 ep_weather_host/open_icons/README.md create mode 100644 ep_weather_host/open_icons/artwork.js create mode 100644 ep_weather_host/open_icons/conditions.js create mode 100644 ep_weather_host/open_icons/render.js diff --git a/ep_gui/resources/settings.reg b/ep_gui/resources/settings.reg index a6e8f18b2..afb644cbd 100644 --- a/ep_gui/resources/settings.reg +++ b/ep_gui/resources/settings.reg @@ -549,9 +549,10 @@ ;x 3 %R:1542% ;x 1 %R:1543% "WeatherWindowCornerPreference"=dword:00000002 -;c 2 %R:1544% +;c 3 %R:1544% ;x 0 %R:1545% ;x 1 %R:1546% +;x 2 ExplorerPatcher "WeatherIconPack"=dword:00000000 ;c 2 %R:1547% ;x 0 %R:1548% diff --git a/ep_gui/resources/settings10.reg b/ep_gui/resources/settings10.reg index e479e767d..b8be0734b 100644 --- a/ep_gui/resources/settings10.reg +++ b/ep_gui/resources/settings10.reg @@ -436,9 +436,10 @@ ;x 1 %R:1538% ;x 2 %R:1539% "WeatherTheme"=dword:00000000 -;c 2 %R:1544% +;c 3 %R:1544% ;x 0 %R:1545% ;x 1 %R:1546% +;x 2 ExplorerPatcher "WeatherIconPack"=dword:00000000 ;c 2 %R:1547% ;x 0 %R:1548% diff --git a/ep_weather_host/ep_weather.h b/ep_weather_host/ep_weather.h index 21a5367f6..39ac109e4 100644 --- a/ep_weather_host/ep_weather.h +++ b/ep_weather_host/ep_weather.h @@ -75,4 +75,5 @@ DEFINE_GUID(IID_IEPWeather, #define EP_WEATHER_ICONPACK_MICROSOFT 0 #define EP_WEATHER_ICONPACK_GOOGLE 1 +#define EP_WEATHER_ICONPACK_OPEN 2 #endif diff --git a/ep_weather_host/ep_weather_host.c b/ep_weather_host/ep_weather_host.c index cd9adbb5f..0473c78c0 100644 --- a/ep_weather_host/ep_weather_host.c +++ b/ep_weather_host/ep_weather_host.c @@ -1,4 +1,5 @@ #include "ep_weather_host.h" +#include "resource.h" #include "ep_weather_provider_google_html.h" #include "ep_weather_provider_google_script.h" #include "ep_weather_error_html.h" @@ -363,6 +364,46 @@ HRESULT STDMETHODCALLTYPE _epw_Weather_NavigateToProvider(EPWeather* _this) return hr; } +static LPWSTR _epw_Weather_BuildOpenIconScript(void) +{ + const WORD resourceIds[] = {IDR_WEATHER_OPEN_ARTWORK, IDR_WEATHER_OPEN_CONDITIONS, IDR_WEATHER_OPEN_RENDER}; + const WCHAR prefix[] = EP_WEATHER_GOOGLE_ICON_HELPER L"(() => {\n"; + const WCHAR suffix[] = L"\n})();"; + const char* resources[ARRAYSIZE(resourceIds)]; + DWORD lengths[ARRAYSIZE(resourceIds)]; + size_t capacity = ARRAYSIZE(prefix) + ARRAYSIZE(suffix); + + for (size_t i = 0; i < ARRAYSIZE(resourceIds); ++i) + { + HRSRC resource = FindResourceW(epw_hModule, MAKEINTRESOURCEW(resourceIds[i]), RT_RCDATA); + if (!resource) return NULL; + HGLOBAL contents = LoadResource(epw_hModule, resource); + resources[i] = contents ? LockResource(contents) : NULL; + lengths[i] = SizeofResource(epw_hModule, resource); + if (!resources[i] || !lengths[i] || lengths[i] > INT_MAX) return NULL; + capacity += lengths[i] + 1; + } + + LPWSTR script = malloc(capacity * sizeof(WCHAR)); + if (!script) return NULL; + size_t offset = ARRAYSIZE(prefix) - 1; + memcpy(script, prefix, offset * sizeof(WCHAR)); + for (size_t i = 0; i < ARRAYSIZE(resourceIds); ++i) + { + int chars = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, resources[i], (int)lengths[i], + script + offset, (int)lengths[i]); + if (!chars) + { + free(script); + return NULL; + } + offset += chars; + script[offset++] = L'\n'; + } + memcpy(script + offset, suffix, sizeof(suffix)); + return script; +} + HRESULT STDMETHODCALLTYPE _epw_Weather_ExecuteDataScript(EPWeather* _this) { HRESULT hr = S_OK; @@ -372,39 +413,35 @@ HRESULT STDMETHODCALLTYPE _epw_Weather_ExecuteDataScript(EPWeather* _this) } else if (dwProvider == EP_WEATHER_PROVIDER_GOOGLE) { - LPWSTR wszScriptData = malloc(sizeof(WCHAR) * EP_WEATHER_PROVIDER_GOOGLE_SCRIPT_LEN); - if (wszScriptData) + LONG64 dwIconPack = InterlockedAdd64(&_this->dwIconPack, 0); + LPWSTR customScript = NULL; + if (dwIconPack == EP_WEATHER_ICONPACK_OPEN) { - LONG64 dwIconPack = InterlockedAdd(&_this->dwIconPack, 0); - if (dwIconPack == EP_WEATHER_ICONPACK_MICROSOFT) - { - swprintf_s(wszScriptData, EP_WEATHER_PROVIDER_GOOGLE_SCRIPT_LEN, L"%s%s%s%s%s%s", ep_weather_provider_google_script00, ep_weather_provider_google_script010, ep_weather_provider_google_script011, ep_weather_provider_google_script020, ep_weather_provider_google_script021, ep_weather_provider_google_script03); - } - else if (dwIconPack == EP_WEATHER_ICONPACK_GOOGLE) - { - swprintf_s(wszScriptData, EP_WEATHER_PROVIDER_GOOGLE_SCRIPT_LEN, ep_weather_provider_google_script10); - } - //wprintf(L"%s\n", _this->wszScriptData); - if (_this->pCoreWebView2) - { - GenericObjectWithThis* pCoreWebView2ExecuteScriptCompletedHandler = - GenericObjectWithThis_MakeAndInitialize(&EPWeather_ICoreWebView2ExecuteScriptCompletedHandlerVtbl, _this, L"pCoreWebView2ExecuteScriptCompletedHandler"); - if (!pCoreWebView2ExecuteScriptCompletedHandler) hr = E_FAIL; - else hr = _this->pCoreWebView2->lpVtbl->ExecuteScript(_this->pCoreWebView2, wszScriptData, pCoreWebView2ExecuteScriptCompletedHandler); - } - else - { - hr = E_FAIL; - } - if (FAILED(hr)) + customScript = _epw_Weather_BuildOpenIconScript(); + } + else if (dwIconPack == EP_WEATHER_ICONPACK_MICROSOFT) + { + customScript = malloc(sizeof(WCHAR) * EP_WEATHER_PROVIDER_GOOGLE_SCRIPT_LEN); + if (customScript && swprintf_s(customScript, EP_WEATHER_PROVIDER_GOOGLE_SCRIPT_LEN, L"%s%s%s%s%s%s", + ep_weather_provider_google_script00, ep_weather_provider_google_script010, ep_weather_provider_google_script011, + ep_weather_provider_google_script020, ep_weather_provider_google_script021, ep_weather_provider_google_script03) < 0) { - InterlockedExchange64(&_this->bBrowserBusy, FALSE); + free(customScript); + customScript = NULL; } - free(wszScriptData); } - else + LPCWSTR script = customScript ? customScript : ep_weather_provider_google_script10; + hr = E_FAIL; + if (_this->pCoreWebView2) { - hr = E_OUTOFMEMORY; + GenericObjectWithThis* callback = + GenericObjectWithThis_MakeAndInitialize(&EPWeather_ICoreWebView2ExecuteScriptCompletedHandlerVtbl, _this, L"pCoreWebView2ExecuteScriptCompletedHandler"); + if (callback) hr = _this->pCoreWebView2->lpVtbl->ExecuteScript(_this->pCoreWebView2, script, callback); + } + free(customScript); + if (FAILED(hr)) + { + InterlockedExchange64(&_this->bBrowserBusy, FALSE); } } return hr; @@ -1961,4 +1998,4 @@ HRESULT STDMETHODCALLTYPE epw_Weather_GetIconSize(EPWeather* _this, LONG64* cbx, if (cbx) *cbx = InterlockedAdd64(&_this->cbx, 0); if (cby) *cby = InterlockedAdd64(&_this->cby, 0); return S_OK; -} \ No newline at end of file +} diff --git a/ep_weather_host/ep_weather_host.rc b/ep_weather_host/ep_weather_host.rc index bd1f1ca4e..ae9d241b5 100644 --- a/ep_weather_host/ep_weather_host.rc +++ b/ep_weather_host/ep_weather_host.rc @@ -19,6 +19,10 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) +IDR_WEATHER_OPEN_ARTWORK RCDATA "open_icons\\artwork.js" +IDR_WEATHER_OPEN_CONDITIONS RCDATA "open_icons\\conditions.js" +IDR_WEATHER_OPEN_RENDER RCDATA "open_icons\\render.js" + #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // diff --git a/ep_weather_host/ep_weather_host.vcxproj b/ep_weather_host/ep_weather_host.vcxproj index fdb7d961f..06467c45a 100644 --- a/ep_weather_host/ep_weather_host.vcxproj +++ b/ep_weather_host/ep_weather_host.vcxproj @@ -315,6 +315,10 @@ + + + + @@ -327,4 +331,4 @@ - \ No newline at end of file + diff --git a/ep_weather_host/ep_weather_provider_google_script.h b/ep_weather_host/ep_weather_provider_google_script.h index d2ad51f81..690ae355c 100644 --- a/ep_weather_host/ep_weather_provider_google_script.h +++ b/ep_weather_host/ep_weather_provider_google_script.h @@ -350,6 +350,7 @@ function ep_weather_getData(image, w, h, ch) {\n\ return res;\n\ }\n\ var ep_result;\n\ +function ep_weather_part1() {\n\ let unit = Array.from(document.getElementsByClassName('wob-unit')[0].getElementsByTagName('span')).filter(e => e.className == 'wob_t')[0].innerText;\n\ let p = '%c';\n\ if (!unit.includes(p)) {\n\ @@ -357,7 +358,6 @@ if (!unit.includes(p)) {\n\ unit = 'x';\n\ }\n\ ep_result = ep_weather_getData(\n(final_im != 0) ? final_im : ep_weather_icon(), %d, %d, unit);\n\ -function ep_weather_part1() {\n\ return \"run_part_2\";\n\ }\n\ ep_weather_part1();\n\ @@ -372,21 +372,18 @@ window.scrollTo(LeftScroll, TopScroll);\n\ };\n\ }\n\ function ep_weather_part2() {\n\ -let h = document.getElementsByClassName(\"ULSxyf\")[0].offsetHeight;\n\ -////document.getElementsByClassName(\"google-weather-place\")[0].style.height = h + 'px';\n\ -////document.getElementsByClassName(\"google-weather-crop\")[0].style.height = h + 'px';\n\ -//if (1) for (let j = 0; j < document.styleSheets.length; j++) changeCSSStyle(j, '.wob_ds', 'background-color', '#303134');\n\ -document.getElementsByClassName(\"KFFQ0c\")[0].style.display = 'none';\n\ -if (document.getElementsByClassName(\"QS5gu sy4vM\").length > 1) { document.getElementsByClassName(\"QS5gu sy4vM\")[1].click(); return \"run_part_1\"; }\n\ -if (document.getElementsByClassName(\"Gfzyee VDgVie DKlyaf Loxgyb\").length > 1) { document.getElementsByClassName(\"Gfzyee VDgVie DKlyaf Loxgyb\")[1].click(); return \"run_part_1\"; }\n\ -//document.getElementById(\"search\").scrollIntoView(true);\n\ -return ep_result;\n\ -}\n\ let banner1 = document.getElementById(\"taw\"); if (banner1) { banner1.style = \"display: none\"; }\n\ let wob_gsp = document.getElementById(\"wob_gsp\"); if (wob_gsp) { wob_gsp.style = \"width: 648.04px\"; }\n\ let weird_line = document.getElementsByClassName(\"v5jHUb\")[0]; if (weird_line) { weird_line.style = \"display: none\"; }\n\ let slim_appbar = document.getElementById(\"slim_appbar\"); if (slim_appbar) { slim_appbar.style = \"display: none\"; }\n\ scrolldisable();\n\ +const header = document.getElementsByClassName('KFFQ0c')[0];\n\ +if (header) header.style.display = 'none';\n\ +if (document.getElementsByClassName(\"QS5gu sy4vM\").length > 1) { document.getElementsByClassName(\"QS5gu sy4vM\")[1].click(); return \"run_part_1\"; }\n\ +if (document.getElementsByClassName(\"Gfzyee VDgVie DKlyaf Loxgyb\").length > 1) { document.getElementsByClassName(\"Gfzyee VDgVie DKlyaf Loxgyb\")[1].click(); return \"run_part_1\"; }\n\ +//document.getElementById(\"search\").scrollIntoView(true);\n\ +return ep_result;\n\ +}\n\ ep_weather_part2();\n\ "; #endif diff --git a/ep_weather_host/open_icons/CC0-1.0.txt b/ep_weather_host/open_icons/CC0-1.0.txt new file mode 100644 index 000000000..0e259d42c --- /dev/null +++ b/ep_weather_host/open_icons/CC0-1.0.txt @@ -0,0 +1,121 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. diff --git a/ep_weather_host/open_icons/README.md b/ep_weather_host/open_icons/README.md new file mode 100644 index 000000000..cd22d7329 --- /dev/null +++ b/ep_weather_host/open_icons/README.md @@ -0,0 +1,7 @@ +# ExplorerPatcher weather artwork + +The **ExplorerPatcher** option in the weather icon picker uses the original shapes in `artwork.js` for the taskbar, current conditions, and daily forecast. The same 48 × 48 vector geometry can be used to export standalone SVGs. + +The artwork in `artwork.js` is dedicated under [CC0 1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/). See `CC0-1.0.txt` for the legal text. The integration code follows the project license. + +`conditions.js` maps known Google filenames and inline image fingerprints to artwork IDs. To register an inline image, compute its base64 payload length and its 32-bit FNV-1a hash, encoded as eight lowercase hexadecimal digits. Use the neutral `unknown` icon if the image cannot be identified reliably. Keep the original forecast text and image accessibility labels. diff --git a/ep_weather_host/open_icons/artwork.js b/ep_weather_host/open_icons/artwork.js new file mode 100644 index 000000000..45e7de60e --- /dev/null +++ b/ep_weather_host/open_icons/artwork.js @@ -0,0 +1,130 @@ +// SPDX-License-Identifier: CC0-1.0 +// Original weather artwork. Shapes use a 48 by 48 grid. +const epOpenWeatherArtwork = (() => { + const ink = '#182c3b'; + const cloudColor = '#bce6e9'; + const water = '#36addf'; + const snowColor = '#e2f6ff'; + const sunColor = '#ffbe54'; + const amber = '#f28940'; + const violet = '#c6b7f3'; + const teal = '#52c9bb'; + + const solid = (path, color) => ({ path, fill: color, stroke: ink, width: 2 }); + const line = (path, color, width = 2.6) => ({ path, fill: null, stroke: color, width }); + const layer = (shapes, x = 0, y = 0, scale = 1) => ({ shapes, x, y, scale }); + + const sun = [ + line('M24 3v5m0 32v5M3 24h5m32 0h5M9 9l4 4m22 22 4 4M39 9l-4 4M13 35l-4 4', amber, 3.3), + solid('M24 11a13 13 0 1 1 0 26 13 13 0 0 1 0-26Z', sunColor), + line('M18 20a7 7 0 0 1 6-3.6', '#fff2ac', 2), + ]; + const moon = [ + solid('M30 9c-2.9 4.1-3.1 9.9-.1 14.4 2.7 4 7 6.2 11.9 5.4-2.4 7.4-9.1 11.8-16.7 10.4C16.9 37.7 11.8 30.3 13 22c1.3-8.5 8.7-13.9 17-13Z', violet), + line('M35 7v8m-4-4h8m2 6v4m-2-2h4', '#f7d881', 1.9), + line('M18.8 27.6c.5 2.7 2.2 4.6 4.9 5.7', '#f1eaff', 1.7), + ]; + const cloudShape = 'M12 31.5a7 7 0 1 1 .9-13.9 10.7 10.7 0 0 1 20.1 1.9 6.1 6.1 0 1 1 3.3 12H12Z'; + const cloud = [ + solid(cloudShape, cloudColor), + line('M13.1 25.3h19.1c2.9 0 4.3-1.1 4.8-2.3', '#83bcc8', 1.7), + line('M16.4 17.4a6.6 6.6 0 0 1 4.7-2.9', '#f4ffff', 1.8), + ]; + const backCloud = [solid(cloudShape, '#84b2c4')]; + const drop = 'M0-3.8c-1.8 2.3-2.8 3.7-2.8 5.1a2.8 2.8 0 0 0 5.6 0C2.8-.1 1.8-1.5 0-3.8Z'; + const dropShape = [solid(drop, water)]; + const flake = [ + line('M0-4v8m-3.5-6L3.5 2m0-4-7 4', ink, 3.2), + line('M0-4v8m-3.5-6L3.5 2m0-4-7 4', snowColor, 1.6), + ]; + const pellet = [solid('M0-3 2.8-1.4v2.8L0 3l-2.8-1.6v-2.8Z', violet)]; + const bolt = [solid('m22 27-5 10h6l-1 8 11-13h-7l3-5Z', sunColor)]; + const gusts = [ + line('M5 16h20c6 0 6-7 1-7-2 0-3.4 1.1-3.9 2.6M3 23h33c8 0 8-10 1-10-2.5 0-3.8 1.5-4.5 3.1M8 31h21c6 0 6 7 1 7-2 0-3.5-1.1-4-2.8', ink, 5.4), + line('M5 16h20c6 0 6-7 1-7-2 0-3.4 1.1-3.9 2.6M3 23h33c8 0 8-10 1-10-2.5 0-3.8 1.5-4.5 3.1M8 31h21c6 0 6 7 1 7-2 0-3.5-1.1-4-2.8', teal, 3), + ]; + const lowCloud = layer(cloud, 0, -3); + const dayTop = layer(sun, 0, -4, .63); + const nightTop = layer(moon, -7, -6, .73); + const mixedCloud = layer(cloud, 6, 6, .9); + const drops = (positions) => positions.map(([x, y, scale = 1]) => layer(dropShape, x, y, scale)); + const flakes = (positions) => positions.map(([x, y, scale = 1]) => layer(flake, x, y, scale)); + const threeRain = [[13, 37], [24, 40], [35, 36]]; + const threeSnow = [[13, 36], [24, 40], [35, 35]]; + const fogLines = [ + line('M7 33h34M11 39h26M16 44h16', ink, 4.4), + line('M7 33h34M11 39h26M16 44h16', '#9ccbd9', 2.5), + ]; + const thermometer = (color) => [ + solid('M20 29V11a4 4 0 0 1 8 0v18a8.4 8.4 0 1 1-8 0Z', '#e2f2f5'), + line('M24 15v20', color, 3.2), + {path: 'M24 32a4 4 0 1 1 0 8 4 4 0 0 1 0-8Z', fill: color, stroke: null}, + line('M30 13h3m-3 5h3m-3 5h3', ink, 1.4), + ]; + + return { + 'clear-day': [layer(sun)], + 'clear-night': [layer(moon)], + 'mostly-clear-day': [layer(sun, 0, -2, .84), layer(cloud, 19, 17, .58)], + 'mostly-clear-night': [layer(moon, -6, -2, .95), layer(cloud, 20, 18, .55)], + 'partly-cloudy-day': [dayTop, mixedCloud], + 'partly-cloudy-night': [nightTop, mixedCloud], + 'mostly-cloudy-day': [layer(sun, 13, -1, .57), layer(backCloud, -1, 1, .84), layer(cloud, 3, 7, .97)], + 'mostly-cloudy-night': [layer(moon, 13, -3, .63), layer(backCloud, -1, 1, .84), layer(cloud, 3, 7, .97)], + 'overcast': [layer(backCloud, -1, -2, .83), layer(cloud, 3, 4, .98)], + 'fog': [layer(cloud, 4, -1, .83), layer(fogLines)], + 'haze': [layer(sun, 9, -2, .62), layer([ + line('M8 28h32m-27 6h22M7 40h34', ink, 4.4), + line('M8 28h32m-27 6h22M7 40h34', '#edb381', 2.5), + ])], + 'wind': [layer(gusts)], + 'drizzle': [lowCloud, ...drops([[16, 35, .64], [24, 39, .64], [32, 35, .64]])], + 'rain': [lowCloud, ...drops(threeRain)], + 'heavy-rain': [lowCloud, ...drops([[11, 35], [20, 41], [28, 35], [37, 41]])], + 'rain-showers': [layer(cloud, 3, -6, .94), ...drops([[15, 33, .8], [24, 39, .85], [33, 34, .8]])], + 'rain-showers-day': [dayTop, layer(cloud, 5, 2, .92), ...drops([[19, 37, .9], [30, 40, .9], [39, 36, .85]])], + 'rain-showers-night': [nightTop, layer(cloud, 5, 2, .92), ...drops([[19, 37, .9], [30, 40, .9], [39, 36, .85]])], + 'freezing-rain': [lowCloud, ...drops([[13, 36], [33, 36]]), layer(pellet, 23, 41)], + 'icy': [layer([ + solid('M24 5 41 17v18l-17 9L7 35V17Z', '#b6e6f5'), + line('m24 6 4 15 12-3M8 18l15 7 1 18m4-22 12 13M8 34l14-9', '#65aecb', 2.2), + line('m12 18 12-8 1 7', '#f3fdff', 2.1), + ])], + 'rain-and-snow': [lowCloud, ...drops([[13, 37], [33, 36]]), layer(flake, 23, 40)], + 'sleet-hail': [lowCloud, layer(pellet, 13, 36), layer(pellet, 24, 41), layer(pellet, 35, 36)], + 'flurries': [lowCloud, ...flakes([[17, 35, .73], [28, 40, .73]])], + 'snow': [lowCloud, ...flakes(threeSnow)], + 'heavy-snow': [lowCloud, ...flakes([[10, 36], [20, 41], [29, 35], [38, 41]])], + 'snow-showers': [layer(cloud, 3, -6, .94), ...flakes(threeSnow)], + 'snow-showers-day': [dayTop, layer(cloud, 5, 2, .92), ...flakes([[19, 37], [30, 40], [39, 36]])], + 'snow-showers-night': [nightTop, layer(cloud, 5, 2, .92), ...flakes([[19, 37], [30, 40], [39, 36]])], + 'blowing-snow': [layer(gusts, 0, -1, .85), ...flakes([[14, 38], [29, 39], [40, 31, .8]])], + 'blizzard': [layer(backCloud, 0, -4, .94), layer(cloud, 6, 1, .85), + ...flakes([[11, 34], [20, 42], [31, 35], [39, 42]]), layer([line('m4 37 6-3m20 8 7-4', teal, 2)])], + 'isolated-storm-day': [dayTop, layer(cloud, 5, 1, .92), layer(bolt, 5, 0, .96)], + 'isolated-storm-night': [nightTop, layer(cloud, 5, 1, .92), layer(bolt, 5, 0, .96)], + 'thunderstorms': [lowCloud, ...drops([[11, 36], [37, 37]]), layer(bolt)], + 'severe-thunderstorms': [layer(backCloud, 0, -3, .89), layer(cloud, 2, -2, .95), + layer(bolt, -6, 1, .95), layer(bolt, 12, 1, .9)], + 'tropical-storm': [layer([ + solid('M43 10c-5.9 9.4-9.1 11.4-13.5 10 2.4 2.7 2.6 6.2.5 9C25.7 35.1 13 38.8 5 38c6.4-9.1 9.6-11.8 14-10.3-2.2-2.9-2.4-6.6-.2-9.3C23.5 12.8 35.4 8.7 43 10Z', teal), + solid('M24 20a4 4 0 1 1 0 8 4 4 0 0 1 0-8Z', '#effefb'), + ])], + 'tornado': [layer([ + solid('M5 13c1.6-5.4 32.3-6.9 37 0 1.9 2.7-3.4 5.5-8.1 6.6-3.8 1 2.9 1.5.4 5.4-1.4 2.3-7.7 3.9-8.4 5.7-.7 1.6 3.1 1.5 1.6 4.2-1.1 1.9-4.6 4.4-8 6.9 1-2.1 2.5-5 .2-5.5-4-.8-7.7-3.2-4.1-6.1 1.7-1.4 1.5-2.1-2.7-3.6-4.6-1.7-5.8-4.6-.9-6.2C8.1 19.7 3.6 16.8 5 13Z', '#a2c0d6'), + line('M10 13c4 2.5 19.5 3.2 28.5-.6M15 23c4.1 1.4 9.6 1.1 15.3-.6', '#e8f4fb', 1.9), + ])], + 'hot': [layer(sun, 1, 2, .67), layer(thermometer('#e36e51'), 9, 5, .94)], + 'cold': [layer(thermometer('#55a9dd'), -3, 2, .96), layer(flake, 35, 12, 1.45)], + 'umbrella': [layer([ + solid('M5 25c1.1-8.7 9.2-15.1 19-15.1S41.9 16.3 43 25c-3.1-1.7-6.6-1.7-9.7 0-3-1.7-6.4-1.7-9.3 0-3.2-1.7-6.5-1.7-9.7 0-3-1.7-6.4-1.7-9.3 0Z', teal), + line('M24 7v3m0 16v12c0 5.4 7 5.1 7 .3', ink, 4.2), + line('M24 7v3m0 16v12c0 5.4 7 5.1 7 .3', teal, 2), + line('M14 23c1.2-6 4.6-9.5 10-12m9 12c-1.2-6-4.6-9.5-9-12', '#cafff1', 1.65), + ])], + 'unknown': [layer(cloud, -2, -1, 1), layer([ + solid('M36 24a8.5 8.5 0 1 1 0 17 8.5 8.5 0 0 1 0-17Z', violet), + line('M33.5 29.6c.6-2.1 4.3-2 4.4.2.1 1.5-2 1.7-2 3.6m0 2.9v.1', ink, 1.8), + ])], + }; +})(); diff --git a/ep_weather_host/open_icons/conditions.js b/ep_weather_host/open_icons/conditions.js new file mode 100644 index 000000000..821def4c0 --- /dev/null +++ b/ep_weather_host/open_icons/conditions.js @@ -0,0 +1,386 @@ +// Google Search icon names observed on the image CDN and known condition aliases. +const epOpenWeatherNames = { + "sunny": "clear-day", + "clear_day": "clear-day", + "clear_night": "clear-night", + "mostly_sunny": "mostly-clear-day", + "mostly_clear_day": "mostly-clear-day", + "mostly_clear_night": "mostly-clear-night", + "sunny_s_cloudy": "mostly-clear-day", + "sunny_with_cloudy": "mostly-clear-day", + "partly_sunny": "partly-cloudy-day", + "partly_cloudy": "partly-cloudy-day", + "partly_cloudy_day": "partly-cloudy-day", + "partly_cloudy_night": "partly-cloudy-night", + "cloudy_s_sunny": "mostly-cloudy-day", + "cloudy_with_sunny": "mostly-cloudy-day", + "mostly_cloudy_day": "mostly-cloudy-day", + "mostly_cloudy_night": "mostly-cloudy-night", + "mostly_cloudy": "mostly-cloudy-day", + "cloudy": "overcast", + "overcast": "overcast", + "fog": "fog", + "haze": "haze", + "dust": "haze", + "smoke": "haze", + "haze_fog_dust_smoke": "haze", + "windy": "wind", + "wind": "wind", + "windy_breezy": "wind", + "drizzle": "drizzle", + "rain_light": "drizzle", + "cloudy_s_rain": "drizzle", + "rain_s_cloudy": "drizzle", + "cloudy_with_rain": "drizzle", + "rain_with_cloudy": "drizzle", + "light_rain": "drizzle", + "rain": "rain", + "heavy_rain": "heavy-rain", + "rain_heavy": "heavy-rain", + "rain_showers": "rain-showers", + "showers_rain": "rain-showers", + "light_rain_showers": "rain-showers", + "heavy_rain_showers": "heavy-rain", + "scattered_showers_day": "rain-showers-day", + "scattered_showers_night": "rain-showers-night", + "sunny_s_rain": "rain-showers-day", + "rain_s_sunny": "rain-showers-day", + "sunny_with_rain": "rain-showers-day", + "rain_with_sunny": "rain-showers-day", + "freezing_rain": "freezing-rain", + "freezing_drizzle": "freezing-rain", + "icy": "icy", + "icy_sleet": "sleet-hail", + "ice_pellets": "sleet-hail", + "wintry_mix": "rain-and-snow", + "wintry_mix_rain_snow": "rain-and-snow", + "rain_and_snow": "rain-and-snow", + "mixed_rain_snow": "rain-and-snow", + "rain_s_snow": "rain-and-snow", + "snow_s_rain": "rain-and-snow", + "rain_with_snow": "rain-and-snow", + "snow_with_rain": "rain-and-snow", + "sleet_hail": "sleet-hail", + "mixed_rain_hail_sleet": "sleet-hail", + "hail": "sleet-hail", + "sleet": "sleet-hail", + "snow_light": "flurries", + "light_snow": "flurries", + "snow": "snow", + "flurries": "flurries", + "heavy_snow": "heavy-snow", + "snow_heavy": "heavy-snow", + "snow_showers": "snow-showers", + "snow_showers_snow": "snow-showers", + "showers_snow": "snow-showers", + "light_snow_showers": "snow-showers", + "heavy_snow_showers": "heavy-snow", + "cloudy_s_snow": "snow-showers", + "snow_s_cloudy": "snow-showers", + "cloudy_with_snow": "snow-showers", + "snow_with_cloudy": "snow-showers", + "scattered_snow_showers_day": "snow-showers-day", + "scattered_snow_showers_night": "snow-showers-night", + "sunny_with_snow": "snow-showers-day", + "snow_with_sunny": "snow-showers-day", + "blowing_snow": "blowing-snow", + "blizzard": "blizzard", + "isolated_scattered_thunderstorms_day": "isolated-storm-day", + "isolated_scattered_thunderstorms_night": "isolated-storm-night", + "isolated_scattered_tstorms_day": "isolated-storm-day", + "isolated_scattered_tstorms_night": "isolated-storm-night", + "isolated_thunderstorms": "thunderstorms", + "thunderstorms": "thunderstorms", + "strong_thunderstorms": "severe-thunderstorms", + "strong_tstorms": "severe-thunderstorms", + "tropical_storm_hurricane": "tropical-storm", + "tropical_storm": "tropical-storm", + "hurricane": "tropical-storm", + "tornado": "tornado", + "very_hot": "hot", + "very_cold": "cold", + "umbrella": "umbrella", + "unknown": "unknown", + "unavailable": "unknown" +}; + +// Length and FNV-1a fingerprint of a known inline PNG or SVG base64 payload. +// Identical bytes with conflicting condition labels take the neutral icon. +const epOpenWeatherFingerprints = { + "1000:4bf2e984": "mostly-cloudy-night", + "1000:561fad38": "mostly-clear-night", + "1000:7f54c77a": "mostly-clear-night", + "1016:0499de37": "overcast", + "1016:387f211f": "overcast", + "1036:056183e2": "sleet-hail", + "1036:9bd66883": "sleet-hail", + "1052:4f56237b": "heavy-snow", + "1056:2eb7e7ab": "wind", + "1068:29a0a49b": "tornado", + "1068:c04ee002": "tornado", + "1072:19e918f0": "flurries", + "1084:4d59a79e": "wind", + "1084:5cc9b352": "drizzle", + "1084:ce27a72b": "drizzle", + "1100:7311ee29": "severe-thunderstorms", + "1100:f493d73d": "severe-thunderstorms", + "1112:950c0ebd": "tropical-storm", + "1112:fd4419f1": "tropical-storm", + "1124:36453880": "drizzle", + "1124:5691de5b": "drizzle", + "1124:c311f48c": "flurries", + "1136:488f3ccc": "tropical-storm", + "1136:679c2770": "thunderstorms", + "1136:9c894547": "tropical-storm", + "1140:0c75f89c": "flurries", + "1140:a38f524b": "sleet-hail", + "1140:da012fb7": "sleet-hail", + "1160:96c17eb2": "clear-day", + "1164:fd8a0da3": "clear-day", + "1172:d2193429": "clear-day", + "1188:5c38525b": "clear-day", + "1192:cab06be9": "clear-day", + "1196:ad502638": "clear-day", + "1220:5d68be67": "rain-showers", + "1256:30065ba2": "sleet-hail", + "1256:9651de9e": "sleet-hail", + "12580:a136d3aa": "heavy-snow", + "1264:676c6acd": "blowing-snow", + "12684:dcb97e06": "heavy-snow", + "1304:027e3755": "clear-day", + "1320:8fb7afb0": "blowing-snow", + "1324:d05e9bb6": "rain-showers", + "1364:94ecabcb": "rain-and-snow", + "1436:9e978951": "mostly-cloudy-night", + "1448:167af6fe": "rain-and-snow", + "1448:7482277c": "rain-and-snow", + "1452:12e1f41a": "partly-cloudy-night", + "1456:5dba8fef": "blizzard", + "1460:15cf1d97": "mostly-clear-night", + "1460:af191314": "blizzard", + "1464:0c9c71ef": "rain-and-snow", + "1464:34906cea": "flurries", + "1464:69e92352": "mostly-cloudy-night", + "1464:7e1be2ac": "thunderstorms", + "1464:9f63ea81": "thunderstorms", + "1464:b9b88f68": "flurries", + "1472:502a42be": "drizzle", + "1472:8d33df45": "drizzle", + "1480:89119207": "partly-cloudy-night", + "1488:f6de586f": "mostly-clear-night", + "1504:9e37d4e4": "rain-showers-day", + "1504:f964ea1b": "rain-showers-day", + "1520:214352fd": "heavy-rain", + "1520:72f99a21": "heavy-rain", + "1520:86323c41": "rain-showers-day", + "1528:503b6133": "thunderstorms", + "1556:aab26e24": "thunderstorms", + "1560:59201b0e": "partly-cloudy-night", + "1560:8b0e0bdb": "partly-cloudy-night", + "1564:9b03636f": "rain-and-snow", + "1580:b0e19bea": "overcast", + "1584:6e57101d": "mostly-cloudy-night", + "1584:abf19278": "mostly-cloudy-night", + "1600:10b4f624": "mostly-clear-night", + "1600:912ab3cc": "mostly-clear-night", + "1624:1a916eac": "heavy-rain", + "1624:a84de534": "heavy-rain", + "1632:637d63fd": "thunderstorms", + "1644:309005f9": "icy", + "1644:c8699f4e": "icy", + "1648:c03b6d07": "rain-showers-day", + "1656:972a87d1": "thunderstorms", + "1700:c76cb181": "heavy-rain", + "1700:cbd80607": "heavy-rain", + "1704:6fc0dc7f": "snow-showers", + "1704:8641b0b5": "snow-showers", + "1716:2fe16b24": "rain-and-snow", + "1740:7f672427": "rain-showers-day", + "1740:81aa196b": "rain-showers-day", + "1752:992a3ff2": "partly-cloudy-day", + "1756:ba146916": "mostly-cloudy-day", + "1756:d6352238": "mostly-cloudy-day", + "1760:86a9f00c": "icy", + "1760:8f52f1fb": "icy", + "1772:3df379be": "rain-showers-day", + "1780:4c06edb7": "snow-showers", + "1848:77ec5d18": "mostly-clear-day", + "1860:3f6e2617": "partly-cloudy-day", + "1860:7c5ea34c": "partly-cloudy-day", + "1876:3d74d56a": "severe-thunderstorms", + "1876:659212f5": "severe-thunderstorms", + "1884:eb884f97": "snow-showers", + "1900:32c400c4": "rain-showers-day", + "1924:189ba0e7": "snow-showers", + "1924:cd36d133": "icy", + "1924:ee00294f": "icy", + "1948:383bff75": "mostly-clear-day", + "1948:e2bc8c81": "mostly-clear-day", + "1952:c295bbb7": "snow-showers", + "1956:c80963c0": "mostly-clear-day", + "1956:eaf3d53d": "mostly-clear-day", + "1960:f2208656": "partly-cloudy-day", + "1980:4e7b2d43": "partly-cloudy-day", + "1980:67fe695e": "mostly-cloudy-day", + "1980:aa22a4a0": "partly-cloudy-day", + "1980:c49c8b6b": "mostly-clear-day", + "1992:26b28113": "hot", + "1992:e6b0e6c0": "hot", + "2012:18d6a535": "mostly-clear-day", + "2016:1a210f59": "sleet-hail", + "2016:d0be74f0": "sleet-hail", + "2032:37a9a4f5": "drizzle", + "2104:da6812bd": "mostly-cloudy-day", + "2208:0cc9848c": "severe-thunderstorms", + "2224:630be2cc": "partly-cloudy-day", + "2224:f1939b42": "partly-cloudy-day", + "2228:9aa42376": "snow-showers-day", + "2288:3a5d805f": "heavy-snow", + "2288:90e3ca64": "severe-thunderstorms", + "2288:b887e8a6": "heavy-snow", + "2304:ad188c8d": "severe-thunderstorms", + "2360:bdccb039": "snow-showers-day", + "2384:fee6631e": "severe-thunderstorms", + "2412:1dbbf038": "mostly-clear-day", + "2412:3699ff9d": "mostly-clear-day", + "2440:43389152": "snow-showers-night", + "2460:fad6df5b": "heavy-snow", + "2492:3e11aac9": "cold", + "2492:51a2686d": "cold", + "2568:bd6f1703": "heavy-snow", + "2644:1e12136d": "rain-and-snow", + "2644:4182f1e4": "rain-and-snow", + "2708:ccd25781": "icy", + "2708:cf03a556": "icy", + "2744:8d145adb": "drizzle", + "2744:fb3aa119": "drizzle", + "2888:043e603d": "snow-showers-day", + "2904:5dd79dc8": "rain-and-snow", + "2904:b6dcb9de": "rain-and-snow", + "2908:4ac687cc": "partly-cloudy-day", + "3056:39b134ff": "snow-showers", + "3056:ac292dca": "snow-showers", + "3068:2b9727f7": "heavy-snow", + "3068:c534a3f5": "heavy-snow", + "3088:2789c5c3": "flurries", + "3100:933c2d6d": "mostly-clear-day", + "3132:2e91e8c7": "drizzle", + "3160:4d295634": "drizzle", + "3160:9f905065": "rain-and-snow", + "3160:f0ed9ad7": "rain-and-snow", + "3176:31dede11": "mostly-cloudy-day", + "3176:45d8cdb0": "mostly-cloudy-day", + "3212:8966b39a": "tornado", + "3240:2de9ae9b": "tornado", + "3272:79e3e016": "snow-showers-day", + "3284:bc234b62": "snow-showers-day", + "3296:dfc18ad5": "rain-and-snow", + "3368:39c6e5c3": "tornado", + "3372:57ec1bc2": "tornado", + "3396:693fb46d": "tornado", + "3400:bb46feab": "tornado", + "3404:d2e5b830": "snow-showers-day", + "3416:ce567951": "snow-showers-day", + "3428:3b299806": "rain-and-snow", + "3564:18f56424": "mostly-clear-day", + "3668:df225ccc": "mostly-clear-day", + "3708:ae80fb34": "snow-showers-day", + "3772:dae58750": "overcast", + "3796:59d9197d": "overcast", + "3812:80ef6fc9": "tropical-storm", + "3820:f8bfcd1d": "tropical-storm", + "3824:a964a135": "tropical-storm", + "3840:e2a5769e": "snow-showers-day", + "3856:a16a89fe": "heavy-rain", + "3856:cabd899f": "heavy-rain", + "3940:27059ac8": "drizzle", + "3968:4b133faa": "drizzle", + "3988:f2ab8da8": "tropical-storm", + "4140:54ce1738": "flurries", + "4588:638eaa3c": "snow-showers", + "4588:6996002d": "snow-showers", + "492:00c0081e": "clear-night", + "492:bb72f40d": "wind", + "492:cfb3c3ec": "clear-night", + "5092:4030e150": "snow-showers", + "5092:4bb5c07d": "snow-showers", + "520:be728692": "wind", + "564:db1a32aa": "clear-day", + "596:211443f3": "fog", + "600:66a7f2d3": "flurries", + "6184:6e0d34f9": "flurries", + "640:4836bbd0": "blowing-snow", + "660:db41bd8c": "overcast", + "668:f3314c9a": "blowing-snow", + "676:f8d386b6": "overcast", + "720:f51dd00d": "mostly-clear-day", + "724:02b3e26a": "clear-night", + "724:2e128e7c": "clear-night", + "724:5cac18ed": "clear-night", + "724:d06d1957": "clear-night", + "748:00ff3eb0": "rain-and-snow", + "748:7583a779": "rain", + "756:48d8b615": "clear-night", + "756:d2ae81e2": "clear-night", + "800:e21f1220": "snow-showers", + "804:754ff503": "heavy-rain", + "828:14b65533": "overcast", + "832:2d4a716f": "wind", + "832:53494b78": "wind", + "832:58a6bb12": "rain-showers-day", + "832:e0f75b64": "wind", + "832:fe506a17": "wind", + "844:49c6786f": "clear-day", + "844:ec73f8f9": "clear-day", + "852:8f9c6fca": "overcast", + "852:cf4e99f5": "overcast", + "8548:1958d052": "snow-showers-night", + "856:4d6ef135": "mostly-cloudy-day", + "860:3838c302": "snow-showers", + "864:1a1ab4b3": "rain-and-snow", + "868:df86965a": "drizzle", + "880:9c6aa7ca": "rain-showers-day", + "880:cce28abb": "drizzle", + "880:eb483959": "drizzle", + "884:35584187": "partly-cloudy-day", + "8968:7622b343": "snow-showers-day", + "908:4d1690cb": "snow", + "912:6fbfcc7d": "blizzard", + "912:b20de39a": "blizzard", + "916:b91b30b8": "drizzle", + "916:dbf42ba6": "drizzle", + "920:883ce325": "blizzard", + "932:db1fb46f": "drizzle", + "940:4f1a9d98": "blowing-snow", + "940:d219a794": "blowing-snow", + "940:d6cf8248": "blowing-snow", + "948:74f0f0c9": "blizzard", + "960:08b3c448": "partly-cloudy-night", + "960:e5da217f": "partly-cloudy-night", + "984:efba1b7a": "mostly-cloudy-night" +}; + +// Legacy inline PNG suffixes already recognized by the weather host. +const epOpenWeatherLegacyPngs = [ + ['mostly-clear-day', 'AAAAAAAAAAAAAAAA+Pf6Bm5v6/1bJGiwAAAAAElFTkSuQmCC', 'MYe78v+ACIiACIiACJTEEyDCTi8sMWUSAAAAAElFTkSuQmCC'], + ['clear-day', 'Ls8fJgAAAAAAAADg1nkDlR7XfJiH1ggAAAAASUVORK5CYII=', 'NzjYbzHpLqUCFKCAJfkAq7RimK7qUtAAAAAASUVORK5CYII='], + ['overcast', 'AiAAAiAAAiAAAiAAl48fFVnRpiVnD+AAAAAASUVORK5CYII=', 'gAAIgAAIgAAIgAC86wECCuvGtH3EIQAAAABJRU5ErkJggg=='], + ['drizzle', 'CQABIAAEgAAQAAJAAB6iPy4FckaI/hnJAAAAAElFTkSuQmCC', 'lFRe7S+mBtAAGkADeFsvKpKWeAy6FowAAAAASUVORK5CYII='], + ['drizzle', '1S6F6f8CBIAAEAACcEP9AsAciK6YtipuAAAAAElFTkSuQmCC', 'A8DsIAvZ0J98BEAA//oBqG5a70gUjuIAAAAASUVORK5CYII='], + ['drizzle', 'LTAzVDExOjEzOjA0KzAyOjAw/lWSQAAAAABJRU5ErkJggg=='], + ['rain', 'FEABFEABFEABFOB3fgDsHp230RVQOwAAAABJRU5ErkJggg==', 'MeRa9W/WClABKkAFiKofRnoGaQBkK9wAAAAASUVORK5CYII='], + ['heavy-rain', 'oP1rrAFoABqABqAS/QFSaJKDZ1ZY3QAAAABJRU5ErkJggg==', 'U4t1idb1T/0FcAF86g/VgX+0644VVAAAAABJRU5ErkJggg=='], + ['thunderstorms', '6n+NVQAVQAVQAfwS/QNrOJYuXyjUGAAAAABJRU5ErkJggg==', 'DTTcSfRpAO//1L8B/hnAD9B4AcpTDEFdAAAAAElFTkSuQmCC'], + ['mostly-cloudy-day', 'gAAQAAJAAAgAASAATqNfCT6dqrbpoPYAAAAASUVORK5CYII=', 'VwAEQAAEQAAEQAD+KcA3AodABBLnBp0AAAAASUVORK5CYII='], + ['partly-cloudy-day', 'AlAACkABKAAFoABOp1+6Bd0LJ+BorgAAAABJRU5ErkJggg==', 'UD8fqAJVoApUgSrwqfwCJ6xaZshM+xMAAAAASUVORK5CYII='], + ['rain-showers-day', '+/JUWP5fQAAIAAEgAA6iPyWP6kEiMYUSAAAAAElFTkSuQmCC', 'EphMZLo+8U++KBAFpnwBEAqlYwd30/wAAAAASUVORK5CYII='], + ['rain-showers-day', 'gAgQASJABIgAESACXpxfGkmKjZKKoRQAAAAASUVORK5CYII=', 'S30fyJ+YskAWyAJZIIUf+u496Ifu2YkAAAAASUVORK5CYII='], + ['fog', '/wsIQAACEIAABCCAb6hfRzSoz4hgnE4AAAAASUVORK5CYII=', 'EC30ZRbiv5QMwAAM8PF6AtMRIwMJwimNAAAAAElFTkSuQmCC'], + ['snow', 'dMq/xgqAAqAAKABW4g+Q1luByt+ugAAAAABJRU5ErkJggg==', 'kKRD6Xzx+qvBCyCw/ABgjEYCwIT8wQAAAABJRU5ErkJggg=='], + ['heavy-snow', '+jJWB6R/m0sAEoAEIBb7BcA+hV/gbM+pAAAAAElFTkSuQmCC', 'cUH9DYB6xvNfDZ4GIuMbUY1SYGBaleEAAAAASUVORK5CYII='], + ['flurries', 'AP5lhgAEIAABCEAAAnzlBYgKVujL4rwkAAAAAElFTkSuQmCC', '88Tmfn8L1e/EFVABFZA0LkcjEH9Eoxa+AAAAAElFTkSuQmCC'], + ['snow-showers', 'SwMAAAAAAAAAAAAAAFxEL1Fe7CEOIBaKAAAAAElFTkSuQmCC', 'lfcC1L+YKkAFqAAVIFa/mfArO5CvUjAAAAAASUVORK5CYII='], + ['rain-and-snow', '+Lc4AAAAAAAAAAAA+AGv/oIwYDUGyQAAAABJRU5ErkJggg==', '1/kcsNXU/8gqQAWoAGXpGzmRTGmgvhAvAAAAAElFTkSuQmCC'], + ['snow-showers', 'ASAABIAAEAACQABepj8dv4hCnMCVbgAAAABJRU5ErkJggg==', 'EuzIGPqHhgAIgAAIAE1vnG7TKhwgdU4AAAAASUVORK5CYII='], + ['rain-and-snow', 'ABAAAkAACAABIAAEwIfoF/D2gpORVfhJAAAAAElFTkSuQmCC', 'i/HUv5gqQAWoABUgWj/U6dmtXHN0sAAAAABJRU5ErkJggg=='], +]; diff --git a/ep_weather_host/open_icons/render.js b/ep_weather_host/open_icons/render.js new file mode 100644 index 000000000..b296f49a8 --- /dev/null +++ b/ep_weather_host/open_icons/render.js @@ -0,0 +1,80 @@ +function epOpenWeatherIconName(source) { + const inline = /^data:image\/(png|svg\+xml);base64,/.exec(source); + if (inline) { + const payload = source.slice(inline[0].length); + let hash = 2166136261; + for (let i = 0; i < payload.length; ++i) { + hash = Math.imul(hash ^ payload.charCodeAt(i), 16777619); + } + const fingerprint = payload.length + ':' + (hash >>> 0).toString(16).padStart(8, '0'); + const name = epOpenWeatherFingerprints[fingerprint]; + if (name) return name; + if (inline[1] === 'png') { + for (const [legacyName, ...suffixes] of epOpenWeatherLegacyPngs) { + if (suffixes.some(suffix => payload.endsWith(suffix))) return legacyName; + } + } + return 'unknown'; + } + + const match = /^https:\/\/(?:www|ssl)\.gstatic\.com\/(?:weather\/conditions\/v\d+\/svg\/([a-z_]+)_(?:light|dark)\.svg|onebox\/weather\/\d+\/([a-z_]+)\.png)(?:[?#]|$)/.exec(source); + const condition = match && (match[1] || match[2]); + return condition && Object.hasOwn(epOpenWeatherNames, condition) ? epOpenWeatherNames[condition] : 'unknown'; +} + +function epOpenWeatherDraw(name) { + const canvas = document.createElement('canvas'); + canvas.width = canvas.height = 48; + const context = canvas.getContext('2d'); + context.lineCap = 'round'; + context.lineJoin = 'round'; + for (const { shapes, x, y, scale } of epOpenWeatherArtwork[name]) { + context.save(); + context.translate(x, y); + context.scale(scale, scale); + for (const { path, fill, stroke, width } of shapes) { + const outline = new Path2D(path); + if (fill) { + context.fillStyle = fill; + context.fill(outline); + } + if (stroke) { + context.strokeStyle = stroke; + context.lineWidth = width; + context.stroke(outline); + } + } + context.restore(); + } + return { canvas, display: canvas.toDataURL('image/png') }; +} + +const state = window.epOpenWeatherState ||= { images: new WeakMap(), artwork: new Map() }; +state.observer?.disconnect(); + +function epOpenWeatherReplace(image) { + const prior = state.images.get(image); + if (prior?.display === image.src) return prior.canvas; + const name = epOpenWeatherIconName(image.src); + if (!state.artwork.has(name)) state.artwork.set(name, epOpenWeatherDraw(name)); + const artwork = state.artwork.get(name); + state.images.set(image, artwork); + image.src = artwork.display; + return artwork.canvas; +} + +function epOpenWeatherRefresh() { + const current = document.querySelector('#wob_wc img') || document.querySelector('img.YQ4gaf.zr758c'); + if (current) window.final_im = epOpenWeatherReplace(current); + for (const image of document.querySelectorAll('.uW5pk img')) epOpenWeatherReplace(image); +} + +window.final_im = 0; +const current = ep_weather_icon(); +epOpenWeatherRefresh(); +state.observer = new MutationObserver(epOpenWeatherRefresh); +const observe = { subtree: true, childList: true, attributeFilter: ['src'] }; +state.observer.observe(document.getElementById('wob_wc') || current, observe); +const forecast = document.querySelector('.wob_df')?.parentElement; +if (forecast) state.observer.observe(forecast, observe); +return 'run_part_0'; diff --git a/ep_weather_host/resource.h b/ep_weather_host/resource.h index e664c6100..93f7c8f2d 100644 --- a/ep_weather_host/resource.h +++ b/ep_weather_host/resource.h @@ -1,12 +1,15 @@ //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. // Used by ep_weather_host.rc +#define IDR_WEATHER_OPEN_ARTWORK 101 +#define IDR_WEATHER_OPEN_CONDITIONS 102 +#define IDR_WEATHER_OPEN_RENDER 103 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_RESOURCE_VALUE 104 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1001 #define _APS_NEXT_SYMED_VALUE 101 From 2ce620f4c89eb9690cc0d51461e725216018721e Mon Sep 17 00:00:00 2001 From: Entrpi <133157614+Entrpi@users.noreply.github.com> Date: Wed, 18 Nov 2026 12:01:20 +1100 Subject: [PATCH 3/4] Extend original weather icons to compound forecasts --- ep_weather_host/ep_weather_host.c | 2 +- ep_weather_host/ep_weather_host.rc | 1 + ep_weather_host/ep_weather_host.vcxproj | 1 + ep_weather_host/open_icons/artwork.js | 38 ++++ ep_weather_host/open_icons/conditions.js | 3 + ep_weather_host/open_icons/forecast.js | 241 +++++++++++++++++++++++ ep_weather_host/open_icons/render.js | 20 +- ep_weather_host/resource.h | 1 + 8 files changed, 300 insertions(+), 7 deletions(-) create mode 100644 ep_weather_host/open_icons/forecast.js diff --git a/ep_weather_host/ep_weather_host.c b/ep_weather_host/ep_weather_host.c index 0473c78c0..d3d49a837 100644 --- a/ep_weather_host/ep_weather_host.c +++ b/ep_weather_host/ep_weather_host.c @@ -366,7 +366,7 @@ HRESULT STDMETHODCALLTYPE _epw_Weather_NavigateToProvider(EPWeather* _this) static LPWSTR _epw_Weather_BuildOpenIconScript(void) { - const WORD resourceIds[] = {IDR_WEATHER_OPEN_ARTWORK, IDR_WEATHER_OPEN_CONDITIONS, IDR_WEATHER_OPEN_RENDER}; + const WORD resourceIds[] = {IDR_WEATHER_OPEN_ARTWORK, IDR_WEATHER_OPEN_CONDITIONS, IDR_WEATHER_OPEN_FORECAST, IDR_WEATHER_OPEN_RENDER}; const WCHAR prefix[] = EP_WEATHER_GOOGLE_ICON_HELPER L"(() => {\n"; const WCHAR suffix[] = L"\n})();"; const char* resources[ARRAYSIZE(resourceIds)]; diff --git a/ep_weather_host/ep_weather_host.rc b/ep_weather_host/ep_weather_host.rc index ae9d241b5..483bf7d02 100644 --- a/ep_weather_host/ep_weather_host.rc +++ b/ep_weather_host/ep_weather_host.rc @@ -21,6 +21,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US IDR_WEATHER_OPEN_ARTWORK RCDATA "open_icons\\artwork.js" IDR_WEATHER_OPEN_CONDITIONS RCDATA "open_icons\\conditions.js" +IDR_WEATHER_OPEN_FORECAST RCDATA "open_icons\\forecast.js" IDR_WEATHER_OPEN_RENDER RCDATA "open_icons\\render.js" #ifdef APSTUDIO_INVOKED diff --git a/ep_weather_host/ep_weather_host.vcxproj b/ep_weather_host/ep_weather_host.vcxproj index 06467c45a..c71d6a10a 100644 --- a/ep_weather_host/ep_weather_host.vcxproj +++ b/ep_weather_host/ep_weather_host.vcxproj @@ -317,6 +317,7 @@ + diff --git a/ep_weather_host/open_icons/artwork.js b/ep_weather_host/open_icons/artwork.js index 45e7de60e..42f2305ac 100644 --- a/ep_weather_host/open_icons/artwork.js +++ b/ep_weather_host/open_icons/artwork.js @@ -77,6 +77,13 @@ const epOpenWeatherArtwork = (() => { line('M8 28h32m-27 6h22M7 40h34', ink, 4.4), line('M8 28h32m-27 6h22M7 40h34', '#edb381', 2.5), ])], + 'smoke': [layer([ + line('M6 35h28c10 0 12-11 4-14-3-1-6-.5-8 2M9 27h14c8 0 10-10 3-13-3-1-6 0-8 2M10 19c-5-4-1-10 5-9', ink, 7), + line('M6 35h28c10 0 12-11 4-14-3-1-6-.5-8 2M9 27h14c8 0 10-10 3-13-3-1-6 0-8 2M10 19c-5-4-1-10 5-9', '#a1a6b0', 4.5), + ])], + 'blowing-dust': [layer(gusts, 1, -2, .87), layer([ + solid('m9 33 3 2-3 2-2-2Zm9 4 2 2-2 2-2-2Zm12-3 3 2-3 2-2-2Zm7 6 2 1-2 2-2-2Z', amber), + ])], 'wind': [layer(gusts)], 'drizzle': [lowCloud, ...drops([[16, 35, .64], [24, 39, .64], [32, 35, .64]])], 'rain': [lowCloud, ...drops(threeRain)], @@ -85,13 +92,19 @@ const epOpenWeatherArtwork = (() => { 'rain-showers-day': [dayTop, layer(cloud, 5, 2, .92), ...drops([[19, 37, .9], [30, 40, .9], [39, 36, .85]])], 'rain-showers-night': [nightTop, layer(cloud, 5, 2, .92), ...drops([[19, 37, .9], [30, 40, .9], [39, 36, .85]])], 'freezing-rain': [lowCloud, ...drops([[13, 36], [33, 36]]), layer(pellet, 23, 41)], + 'freezing-drizzle': [lowCloud, ...drops([[13, 35, .65], [33, 35, .65]]), layer(pellet, 23, 40)], 'icy': [layer([ solid('M24 5 41 17v18l-17 9L7 35V17Z', '#b6e6f5'), line('m24 6 4 15 12-3M8 18l15 7 1 18m4-22 12 13M8 34l14-9', '#65aecb', 2.2), line('m12 18 12-8 1 7', '#f3fdff', 2.1), ])], 'rain-and-snow': [lowCloud, ...drops([[13, 37], [33, 36]]), layer(flake, 23, 40)], + 'snow-and-rain': [lowCloud, ...flakes([[13, 37], [33, 36]]), layer(dropShape, 23, 40)], + 'wintry-mix': [lowCloud, layer(flake, 13, 36), layer(dropShape, 24, 41), layer(pellet, 35, 36)], 'sleet-hail': [lowCloud, layer(pellet, 13, 36), layer(pellet, 24, 41), layer(pellet, 35, 36)], + 'hail': [lowCloud, layer([ + solid('M10 36a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0Zm11 5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0Zm11-5a3.5 3.5 0 1 1 7 0 3.5 3.5 0 0 1-7 0Z', violet), + ])], 'flurries': [lowCloud, ...flakes([[17, 35, .73], [28, 40, .73]])], 'snow': [lowCloud, ...flakes(threeSnow)], 'heavy-snow': [lowCloud, ...flakes([[10, 36], [20, 41], [29, 35], [38, 41]])], @@ -128,3 +141,28 @@ const epOpenWeatherArtwork = (() => { ])], }; })(); + +function epOpenWeatherLayers(name) { + const [relation, first, second] = name.split(':'); + if (!first) return epOpenWeatherArtwork[name] ?? epOpenWeatherArtwork.unknown; + + const place = (icon, left, top, size) => epOpenWeatherArtwork[icon].map(({ shapes, x, y, scale }) => + ({ shapes, x: left + x * size, y: top + y * size, scale: scale * size })); + + const markers = { + sequence: 'M20 24h8m-3-3 3 3-3 3', + together: 'M21 24h6m-3-3v6', + intermittent: 'M19 30h.1m3.9 0h.1m3.9 0h.1', + brief: 'M23 30h.1', + }; + const marker = markers[relation]; + const smallSecond = relation === 'brief' || relation === 'intermittent'; + return [ + ...place(first, 0, smallSecond ? 7 : 12, smallSecond ? .49 : .43), + ...place(second, smallSecond ? 28 : 27, smallSecond ? 20 : 12, smallSecond ? .38 : .43), + { x: 0, y: 0, scale: 1, shapes: [ + { path: marker, fill: null, stroke: '#182c3b', width: 4.7 }, + { path: marker, fill: null, stroke: '#bce6e9', width: 2.5 }, + ] }, + ]; +} diff --git a/ep_weather_host/open_icons/conditions.js b/ep_weather_host/open_icons/conditions.js index 821def4c0..b4f139696 100644 --- a/ep_weather_host/open_icons/conditions.js +++ b/ep_weather_host/open_icons/conditions.js @@ -107,6 +107,9 @@ const epOpenWeatherNames = { // Length and FNV-1a fingerprint of a known inline PNG or SVG base64 payload. // Identical bytes with conflicting condition labels take the neutral icon. const epOpenWeatherFingerprints = { + // Directional forecast SVGs observed in Kagoshima and Seoul. + "2808:d3682d1f": "sequence:rain:overcast", + "2856:d9a4f478": "sequence:overcast:rain", "1000:4bf2e984": "mostly-cloudy-night", "1000:561fad38": "mostly-clear-night", "1000:7f54c77a": "mostly-clear-night", diff --git a/ep_weather_host/open_icons/forecast.js b/ep_weather_host/open_icons/forecast.js new file mode 100644 index 000000000..5ec4d6577 --- /dev/null +++ b/ep_weather_host/open_icons/forecast.js @@ -0,0 +1,241 @@ +// The Google Weather API vocabulary provides condition identifiers for this table. +// Google Search supplies localized labels. It does not supply these identifiers. +const epOpenWeatherForecastTypes = { + TYPE_UNSPECIFIED: 'unknown', + CLEAR: 'clear-day', + MOSTLY_CLEAR: 'mostly-clear-day', + PARTLY_CLOUDY: 'partly-cloudy-day', + MOSTLY_CLOUDY: 'mostly-cloudy-day', + CLOUDY: 'overcast', + WINDY: 'wind', + WIND_AND_RAIN: 'together:wind:rain', + LIGHT_RAIN_SHOWERS: 'rain-showers', + CHANCE_OF_SHOWERS: 'rain-showers', + SCATTERED_SHOWERS: 'rain-showers', + RAIN_SHOWERS: 'rain-showers', + HEAVY_RAIN_SHOWERS: 'heavy-rain', + LIGHT_TO_MODERATE_RAIN: 'rain', + MODERATE_TO_HEAVY_RAIN: 'rain', + RAIN: 'rain', + LIGHT_RAIN: 'drizzle', + HEAVY_RAIN: 'heavy-rain', + RAIN_PERIODICALLY_HEAVY: 'intermittent:rain:heavy-rain', + LIGHT_SNOW_SHOWERS: 'snow-showers', + CHANCE_OF_SNOW_SHOWERS: 'snow-showers', + SCATTERED_SNOW_SHOWERS: 'snow-showers', + SNOW_SHOWERS: 'snow-showers', + HEAVY_SNOW_SHOWERS: 'heavy-snow', + LIGHT_TO_MODERATE_SNOW: 'snow', + MODERATE_TO_HEAVY_SNOW: 'snow', + SNOW: 'snow', + LIGHT_SNOW: 'flurries', + HEAVY_SNOW: 'heavy-snow', + SNOWSTORM: 'snow', + SNOW_PERIODICALLY_HEAVY: 'intermittent:snow:heavy-snow', + HEAVY_SNOW_STORM: 'heavy-snow', + BLOWING_SNOW: 'blowing-snow', + RAIN_AND_SNOW: 'rain-and-snow', + HAIL: 'hail', + HAIL_SHOWERS: 'hail', + THUNDERSTORM: 'thunderstorms', + THUNDERSHOWER: 'thunderstorms', + LIGHT_THUNDERSTORM_RAIN: 'thunderstorms', + SCATTERED_THUNDERSTORMS: 'thunderstorms', + HEAVY_THUNDERSTORM: 'thunderstorms', + + // Regional forecasts distinguish order, duration, and precipitation mix. + CLEAR_AFTER_FOG_IN_THE_MORNING: 'sequence:fog:clear-day', + CLEAR_BUT_LATER_TURNING_CLOUDY: 'sequence:clear-day:overcast', + CLEAR_BUT_LATER_TURNING_TO_RAIN_AND_SNOW_MAIN_CONSTITUENT_RAIN: 'sequence:clear-day:rain-and-snow', + CLEAR_BUT_LATER_TURNING_TO_SNOW_AND_RAIN_MAIN_CONSTITUENT_SNOW: 'sequence:clear-day:snow-and-rain', + CLEAR_BUT_THUNDERSTORMS_LATER: 'sequence:clear-day:thunderstorms', + CLEAR_IN_THE_MORNING_BUT_CLOUDY_IN_THE_EVENING: 'sequence:clear-day:overcast', + CLEAR_IN_THE_MORNING_WITH_BRIEF_RAIN_IN_THE_EVENING: 'sequence:clear-day:rain-showers', + CLEAR_MORNING_WITH_BRIEF_RAIN: 'brief:clear-day:rain', + CLEAR_WITH_BRIEF_RAIN: 'brief:clear-day:rain', + CLEAR_WITH_BRIEF_RAIN_AND_SNOW_RAIN_AS_MAIN_CONSTITUENT: 'brief:clear-day:rain-and-snow', + CLEAR_WITH_BRIEF_RAIN_LATER: 'sequence:clear-day:rain-showers', + CLEAR_WITH_BRIEF_SNOW: 'brief:clear-day:snow', + CLEAR_WITH_BRIEF_SNOW_AND_RAIN_SNOW_AS_MAIN_CONSTITUENT: 'brief:clear-day:snow-and-rain', + CLEAR_WITH_BRIEF_SNOW_LATER: 'sequence:clear-day:snow-showers', + CLEAR_WITH_PERIODIC_CLOUDS_LATER: 'sequence:clear-day:partly-cloudy-day', + CLEAR_WITH_PERIODIC_RAIN: 'intermittent:clear-day:rain', + CLEAR_WITH_PERIODIC_RAIN_ACCOMPANIED_BY_THUNDER: 'intermittent:clear-day:thunderstorms', + CLEAR_WITH_PERIODIC_RAIN_AND_SNOW_RAIN_AS_MAIN_CONSTITUENT: 'intermittent:clear-day:rain-and-snow', + CLEAR_WITH_PERIODIC_RAIN_LATER: 'sequence:clear-day:rain-showers', + CLEAR_WITH_PERIODIC_SNOW: 'intermittent:clear-day:snow', + CLEAR_WITH_PERIODIC_SNOW_AND_RAIN_SNOW_AS_MAIN_CONSTITUENT: 'intermittent:clear-day:snow-and-rain', + CLEAR_WITH_PERIODIC_SNOW_LATER: 'sequence:clear-day:snow-showers', + CLEAR_WITH_RAIN_AFTER_MIDNIGHT: 'sequence:clear-night:rain', + CLEAR_WITH_RAIN_IN_THE_NIGHT: 'sequence:clear-day:rain', + CLEAR_WITH_RAIN_LATER: 'sequence:clear-day:rain', + CLEAR_WITH_SNOW_ALONG_THE_MOUNTAINS: 'together:clear-day:snow', + CLEAR_WITH_SNOW_LATER: 'sequence:clear-day:snow', + CLEAR_WITH_THUNDERSTORMS_ALONG_THE_MOUNTAINS: 'together:clear-day:thunderstorms', + CLEAR_WITH_THUNDERSTORMS_IN_THE_AFTERNOON: 'sequence:clear-day:thunderstorms', + CLOUDY_BUT_CLEAR_LATER: 'sequence:overcast:clear-day', + CLOUDY_BUT_LATER_TURNING_TO_RAIN_AND_SNOW_MAIN_CONSTITUENT_RAIN: 'sequence:overcast:rain-and-snow', + CLOUDY_BUT_LATER_TURNING_TO_SNOW_AND_RAIN_MAIN_CONSTITUENT_SNOW: 'sequence:overcast:snow-and-rain', + CLOUDY_BUT_PERIODICALLY_CLEAR_LATER: 'sequence:overcast:partly-cloudy-day', + CLOUDY_BUT_THUNDERSTORMS_LATER: 'sequence:overcast:thunderstorms', + CLOUDY_MORNING_WITH_BRIEF_RAIN: 'brief:overcast:rain', + CLOUDY_PERIODICALLY_CLEAR: 'intermittent:overcast:clear-day', + CLOUDY_SNOWING_IN_THE_EVENING: 'sequence:overcast:snow', + CLOUDY_SNOWING_IN_THE_NIGHT: 'sequence:overcast:snow', + CLOUDY_WITH_BRIEF_RAIN: 'brief:overcast:rain', + CLOUDY_WITH_BRIEF_RAIN_AND_SNOW_RAIN_AS_MAIN_CONSTITUENT: 'brief:overcast:rain-and-snow', + CLOUDY_WITH_BRIEF_RAIN_LATER: 'sequence:overcast:rain-showers', + CLOUDY_WITH_BRIEF_SNOW: 'brief:overcast:snow', + CLOUDY_WITH_BRIEF_SNOW_AND_RAIN_SNOW_AS_MAIN_CONSTITUENT: 'brief:overcast:snow-and-rain', + CLOUDY_WITH_BRIEF_SNOW_LATER: 'sequence:overcast:snow-showers', + CLOUDY_WITH_BRIEF_THUNDERSTORM: 'brief:overcast:thunderstorms', + CLOUDY_WITH_FOG_ON_THE_OCEAN_AND_AT_THE_SEASHORE: 'together:overcast:fog', + CLOUDY_WITH_PERIODIC_RAIN: 'intermittent:overcast:rain', + CLOUDY_WITH_PERIODIC_RAIN_ACCOMPANIED_BY_THUNDER: 'intermittent:overcast:thunderstorms', + CLOUDY_WITH_PERIODIC_RAIN_AND_SNOW_RAIN_AS_MAIN_CONSTITUENT: 'intermittent:overcast:rain-and-snow', + CLOUDY_WITH_PERIODIC_RAIN_LATER: 'sequence:overcast:rain-showers', + CLOUDY_WITH_PERIODIC_SNOW: 'intermittent:overcast:snow', + CLOUDY_WITH_PERIODIC_SNOW_ACCOMPANIED_BY_THUNDER: 'together:snow-showers:thunderstorms', + CLOUDY_WITH_PERIODIC_SNOW_AND_RAIN_SNOW_AS_MAIN_CONSTITUENT: 'intermittent:overcast:snow-and-rain', + CLOUDY_WITH_PERIODIC_SNOW_LATER: 'sequence:overcast:snow-showers', + CLOUDY_WITH_RAIN_AFTER_MIDNIGHT: 'sequence:overcast:rain', + CLOUDY_WITH_RAIN_FROM_ABOUT_NOON: 'sequence:overcast:rain', + CLOUDY_WITH_RAIN_FROM_EVENING: 'sequence:overcast:rain', + CLOUDY_WITH_RAIN_LATER: 'sequence:overcast:rain', + CLOUDY_WITH_SNOW_FROM_AROUND_NOON: 'sequence:overcast:snow', + CLOUDY_WITH_SNOW_LATER: 'sequence:overcast:snow', + FOG: 'fog', + RAINSNOW_MIX_LATER_BECOMING_CLEAR_RAIN_AS_MAIN: 'sequence:rain-and-snow:clear-day', + RAINSNOW_MIX_RAIN_AS_MAIN: 'rain-and-snow', + RAINY_BUT_PERIODICALLY_CLEAR: 'intermittent:rain:clear-day', + RAIN_ACCOMPANIED_BY_LIGHTNING: 'thunderstorms', + RAIN_ACCOMPANIED_BY_WINDSTORM: 'together:wind:rain', + RAIN_CLEAR_AT_NIGHT: 'sequence:rain:clear-night', + RAIN_CLEAR_FROM_AROUND_EVENING: 'sequence:rain:clear-night', + RAIN_CLEAR_FROM_AROUND_NOON: 'sequence:rain:clear-day', + RAIN_LATER_BECOMING_CLEAR: 'sequence:rain:clear-day', + RAIN_LATER_BECOMING_CLOUDY: 'sequence:rain:overcast', + RAIN_LATER_BECOMING_SNOW: 'sequence:rain:snow', + RAIN_LATER_WITH_PERIODIC_SNOW: 'sequence:rain:snow-showers', + RAIN_SNOW_AT_NIGHT: 'rain-and-snow', + RAIN_SNOW_IN_THE_EVENING: 'rain-and-snow', + RAIN_TEMPORARILY_BECOMING_SLEET: 'brief:rain:sleet-hail', + RAIN_THAT_PERIODICALLY_STOPS: 'rain-showers', + RAIN_WITH_BRIEF_SNOW: 'brief:rain:snow', + RAIN_WITH_PERIODIC_SNOW: 'intermittent:rain:snow', + SNOWRAIN_MIX_LATER_BECOMING_CLEAR_SNOW_AS_MAIN: 'sequence:snow-and-rain:clear-day', + SNOWRAIN_MIX_LATER_BECOMING_CLOUDY_SNOW_AS_MAIN: 'sequence:snow-and-rain:overcast', + SNOWRAIN_MIX_SNOW_AS_MAIN: 'snow-and-rain', + SNOW_ACCOMPANIED_BY_LIGHTNING: 'together:snow:thunderstorms', + SNOW_BECOMING_SLEET: 'sequence:snow:sleet-hail', + SNOW_LATER_CLEAR: 'sequence:snow:clear-day', + SNOW_LATER_CLOUDY: 'sequence:snow:overcast', + SNOW_LATER_RAIN: 'sequence:snow:rain', + SNOW_PERIODICALLY_CLEAR: 'intermittent:snow:clear-day', + SNOW_THAT_PERIODICALLY_STOPS: 'snow-showers', + SNOW_TURNING_TO_RAIN_AROUND_NOON: 'sequence:snow:rain', + SNOW_TURNING_TO_RAIN_IN_THE_EVENING: 'sequence:snow:rain', + SNOW_TURNING_TO_RAIN_IN_THE_NIGHT: 'sequence:snow:rain', + SNOW_WITH_BRIEF_RAIN: 'brief:snow:rain', + SNOW_WITH_BRIEF_SLEET: 'brief:snow:sleet-hail', + SNOW_WITH_PERIODIC_RAIN: 'intermittent:snow:rain', + VERY_HOT: 'hot', + SLEET: 'sleet-hail', + HEAVY_RAIN_TO_RAINSTORM: 'heavy-rain', +}; + +// Normalized Search labels and common weather terms that differ from the identifiers. +const epOpenWeatherForecastAliases = { + SUNNY: 'clear-day', + MOSTLY_SUNNY: 'mostly-clear-day', + PARTLY_SUNNY: 'partly-cloudy-day', + OVERCAST: 'overcast', + DRIZZLE: 'drizzle', + FREEZING_DRIZZLE: 'freezing-drizzle', + FREEZING_RAIN: 'freezing-rain', + RAIN_SNOW: 'rain-and-snow', + RAIN_SLEET: 'together:rain:sleet-hail', + RAIN_AND_SLEET: 'together:rain:sleet-hail', + WINTRY_MIX: 'wintry-mix', + FLURRIES: 'flurries', + BLOWING_DRIFTING_SNOW: 'blowing-snow', + BLOWING_DUST: 'blowing-dust', + DUST: 'blowing-dust', + SANDSTORM: 'blowing-dust', + BLOWING_DUST_SANDSTORM: 'blowing-dust', + FOGGY: 'fog', + HAZE: 'haze', + SMOKE: 'smoke', + STRONG_STORMS: 'severe-thunderstorms', + THUNDERSTORMS: 'thunderstorms', + ISOLATED_THUNDERSTORMS: 'isolated-storm-day', + BLIZZARD: 'blizzard', + MIXED_RAIN_AND_HAIL: 'together:rain:hail', + TORNADO: 'tornado', + TROPICAL_STORM: 'tropical-storm', + HURRICANE: 'tropical-storm', + BREEZY: 'wind', + HOT: 'hot', + VERY_COLD: 'cold', + FRIGID_ICE_CRYSTALS: 'cold', + FAIR_MOSTLY_CLEAR: 'mostly-clear-night', + FAIR_MOSTLY_SUNNY: 'mostly-clear-day', + SHOWERS: 'rain-showers', + NOT_AVAILABLE_N_A: 'unknown', + CLOUDY_WITH_PERIODIC_RAIN_SHOWERS: 'intermittent:overcast:rain', + CLOUDY_WITH_BRIEF_SNOW_SHOWERS: 'brief:overcast:snow', + CLEAR_WITH_PERIODIC_SNOW_SHOWERS: 'intermittent:clear-day:snow', + SNOW_WITH_PERIODIC_RAIN_SHOWERS: 'intermittent:snow:rain', + RAIN_BECOMING_CLOUDY_LATER: 'sequence:rain:overcast', + CLOUDY_WITH_SNOW_IN_THE_EVENING: epOpenWeatherForecastTypes.CLOUDY_SNOWING_IN_THE_EVENING, + CLOUDY_WITH_SNOW_AT_NIGHT: epOpenWeatherForecastTypes.CLOUDY_SNOWING_IN_THE_NIGHT, + RAIN_CLEARING_AT_NIGHT: epOpenWeatherForecastTypes.RAIN_CLEAR_AT_NIGHT, + RAIN_CLEARING_FROM_AROUND_EVENING: epOpenWeatherForecastTypes.RAIN_CLEAR_FROM_AROUND_EVENING, + RAIN_CLEARING_FROM_AROUND_NOON: epOpenWeatherForecastTypes.RAIN_CLEAR_FROM_AROUND_NOON, + RAIN_AND_SNOW_AT_NIGHT: epOpenWeatherForecastTypes.RAIN_SNOW_AT_NIGHT, + RAIN_AND_SNOW_IN_THE_EVENING: epOpenWeatherForecastTypes.RAIN_SNOW_IN_THE_EVENING, + SNOW_LATER_CLEARING: epOpenWeatherForecastTypes.SNOW_LATER_CLEAR, + SNOW_LATER_BECOMING_CLOUDY: epOpenWeatherForecastTypes.SNOW_LATER_CLOUDY, + SNOW_LATER_BECOMING_RAIN: epOpenWeatherForecastTypes.SNOW_LATER_RAIN, + SNOW_PERIODICALLY_CLEARING: epOpenWeatherForecastTypes.SNOW_PERIODICALLY_CLEAR, + SNOW_TURNING_TO_RAIN_AT_NIGHT: epOpenWeatherForecastTypes.SNOW_TURNING_TO_RAIN_IN_THE_NIGHT, +}; + +const epOpenWeatherJapaneseIcons = { + '晴': 'clear-day', '晴れ': 'clear-day', '曇': 'overcast', '曇り': 'overcast', 'くもり': 'overcast', + '雨': 'rain', '雪': 'snow', '霧': 'fog', 'みぞれ': 'rain-and-snow', '猛暑': 'hot', +}; +const epOpenWeatherKoreanIcons = { + '맑음': 'clear-day', '맑은': 'clear-day', '맑으나': 'clear-day', '맑고': 'clear-day', + '흐림': 'overcast', '흐린': 'overcast', '흐리고': 'overcast', '비': 'rain', '눈': 'snow', +}; + +function epOpenWeatherRegionalIcon(key) { + const japanese = key.split(/(のち|後|時々|時どき|一時)/); + const korean = key.split(/_(후|이후|때때로|가끔|한때)_/); + const useKorean = korean.length > 1 || Object.hasOwn(epOpenWeatherKoreanIcons, key); + const [first, connector, second] = useKorean ? korean : japanese; + const icons = useKorean ? epOpenWeatherKoreanIcons : epOpenWeatherJapaneseIcons; + if (!Object.hasOwn(icons, first)) return null; + if (!connector) return icons[first]; + if ((useKorean ? korean.length : japanese.length) !== 3 || !Object.hasOwn(icons, second)) return null; + const relation = /^(のち|後|후|이후)$/.test(connector) ? 'sequence' + : /^(一時|한때)$/.test(connector) ? 'brief' : 'intermittent'; + return `${relation}:${icons[first]}:${icons[second]}`; +} + +function epOpenWeatherForecastIcon(label, sourceIcon) { + const key = label.normalize('NFKC').toUpperCase().replace(/[^\p{L}\p{N}]+/gu, '_').replace(/^_|_$/g, '') + .replace(/(_BUT_LATER_TURNING_TO_(?:RAIN_AND_SNOW|SNOW_AND_RAIN))_WITH_(RAIN|SNOW)_AS_THE_MAIN_CONSTITUENT$/, '$1_MAIN_CONSTITUENT_$2') + .replace(/_WITH_(RAIN|SNOW)_AS_THE_MAIN_CONSTITUENT$/, '_$1_AS_MAIN_CONSTITUENT') + .replace(/^(RAIN|SNOW)_(SNOW|RAIN)_MIX_(.+)_AS_MAIN_CONSTITUENT$/, '$1$2_MIX_$3_AS_MAIN'); + const forecastIcon = Object.hasOwn(epOpenWeatherForecastTypes, key) ? epOpenWeatherForecastTypes[key] + : Object.hasOwn(epOpenWeatherForecastAliases, key) ? epOpenWeatherForecastAliases[key] : epOpenWeatherRegionalIcon(key); + + // The icon can carry the time of day even if the label is unchanged. + if (forecastIcon?.endsWith('-day') && sourceIcon === forecastIcon.replace(/-day$/, '-night')) return sourceIcon; + if (forecastIcon === 'rain-showers' || forecastIcon === 'snow-showers') { + if (sourceIcon === `${forecastIcon}-day` || sourceIcon === `${forecastIcon}-night`) return sourceIcon; + } + return forecastIcon ?? sourceIcon; +} diff --git a/ep_weather_host/open_icons/render.js b/ep_weather_host/open_icons/render.js index b296f49a8..0cadfc88b 100644 --- a/ep_weather_host/open_icons/render.js +++ b/ep_weather_host/open_icons/render.js @@ -28,7 +28,7 @@ function epOpenWeatherDraw(name) { const context = canvas.getContext('2d'); context.lineCap = 'round'; context.lineJoin = 'round'; - for (const { shapes, x, y, scale } of epOpenWeatherArtwork[name]) { + for (const { shapes, x, y, scale } of epOpenWeatherLayers(name)) { context.save(); context.translate(x, y); context.scale(scale, scale); @@ -54,12 +54,20 @@ state.observer?.disconnect(); function epOpenWeatherReplace(image) { const prior = state.images.get(image); - if (prior?.display === image.src) return prior.canvas; - const name = epOpenWeatherIconName(image.src); + const label = image.alt; + const painted = prior?.artwork.display === image.src; + if (painted && prior.label === label) return prior.artwork.canvas; + const source = painted ? prior.source : image.src; + const name = epOpenWeatherForecastIcon(label, epOpenWeatherIconName(source)); if (!state.artwork.has(name)) state.artwork.set(name, epOpenWeatherDraw(name)); const artwork = state.artwork.get(name); - state.images.set(image, artwork); - image.src = artwork.display; + const tooltip = image.getAttribute('title'); + if (!tooltip || tooltip === prior?.label) { + if (label) image.title = label; + else if (tooltip) image.removeAttribute('title'); + } + state.images.set(image, { artwork, source, label, name }); + if (image.src !== artwork.display) image.src = artwork.display; return artwork.canvas; } @@ -73,7 +81,7 @@ window.final_im = 0; const current = ep_weather_icon(); epOpenWeatherRefresh(); state.observer = new MutationObserver(epOpenWeatherRefresh); -const observe = { subtree: true, childList: true, attributeFilter: ['src'] }; +const observe = { subtree: true, childList: true, attributeFilter: ['src', 'alt'] }; state.observer.observe(document.getElementById('wob_wc') || current, observe); const forecast = document.querySelector('.wob_df')?.parentElement; if (forecast) state.observer.observe(forecast, observe); diff --git a/ep_weather_host/resource.h b/ep_weather_host/resource.h index 93f7c8f2d..9aaf8ffda 100644 --- a/ep_weather_host/resource.h +++ b/ep_weather_host/resource.h @@ -4,6 +4,7 @@ #define IDR_WEATHER_OPEN_ARTWORK 101 #define IDR_WEATHER_OPEN_CONDITIONS 102 #define IDR_WEATHER_OPEN_RENDER 103 +#define IDR_WEATHER_OPEN_FORECAST 104 // Next default values for new objects // From f704be4de6626f8927e63d899282b0074684c31b Mon Sep 17 00:00:00 2001 From: Entrpi <133157614+Entrpi@users.noreply.github.com> Date: Wed, 18 Nov 2026 12:04:01 +1100 Subject: [PATCH 4/4] Document forecast artwork and reserve the next resource ID --- ep_weather_host/open_icons/README.md | 4 +++- ep_weather_host/resource.h | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ep_weather_host/open_icons/README.md b/ep_weather_host/open_icons/README.md index cd22d7329..15915eaa1 100644 --- a/ep_weather_host/open_icons/README.md +++ b/ep_weather_host/open_icons/README.md @@ -4,4 +4,6 @@ The **ExplorerPatcher** option in the weather icon picker uses the original shap The artwork in `artwork.js` is dedicated under [CC0 1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/). See `CC0-1.0.txt` for the legal text. The integration code follows the project license. -`conditions.js` maps known Google filenames and inline image fingerprints to artwork IDs. To register an inline image, compute its base64 payload length and its 32-bit FNV-1a hash, encoded as eight lowercase hexadecimal digits. Use the neutral `unknown` icon if the image cannot be identified reliably. Keep the original forecast text and image accessibility labels. +`forecast.js` maps recognized forecast labels to individual icons and compositions. An arrow marks a change later in the period. Different markers show brief, intermittent, and simultaneous conditions. The forecast table uses names from the [Google Weather API condition reference](https://developers.google.com/maps/documentation/weather/reference/rest/v1/WeatherCondition). Google Search supplies the widget's localized labels and image sources. + +`conditions.js` maps known Google filenames and inline image fingerprints to artwork IDs. To register an inline image, use the base64 payload's length, a colon, and its 32-bit FNV-1a hash as eight lowercase hexadecimal digits. When both the label and image are unfamiliar, `render.js` draws the neutral `unknown` icon and preserves the forecast label. diff --git a/ep_weather_host/resource.h b/ep_weather_host/resource.h index 9aaf8ffda..4003cb2c7 100644 --- a/ep_weather_host/resource.h +++ b/ep_weather_host/resource.h @@ -10,7 +10,7 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 104 +#define _APS_NEXT_RESOURCE_VALUE 105 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1001 #define _APS_NEXT_SYMED_VALUE 101