InterLinked1 / chromefill

Automatically injects polyfills for old Chromium into webpages
Apache License 2.0
15 stars 1 forks source link

Intl.RelativeTimeFormat needs a polyfill #1

Closed InterLinked1 closed 2 years ago

InterLinked1 commented 2 years ago

This needs a polyfill: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat

Vangelis66 commented 2 years ago

Unfortunately :cry: , this has now become the reason the Spotify Web Player is currently producing a blank page in [Chromium<71]-based web browsers:

360EEv11_spotifyWP

Above is with 360EEv11, Chromium 69 based, popular among XP+Vista users :stuck_out_tongue_winking_eye: ...

Sample URI: "https://open.spotify.com/show/2XHy0waKckPLULstsawBwP"

FWIW, "Spotify Web" used to load fine ca. 2 months ago, so that's a recent change implemented by them :angry: ; why can't they just let "sleeping dogs lie" ? :rage:

InterLinked1 commented 2 years ago

There do actually seem to be a couple polyfills out there for this, e.g.:

However, my attempts at integrating them into this extension thus far have failed. If anyone has the time to figure it out before I do, pull requests are always welcome.

Vangelis66 commented 2 years ago

my attempts at integrating them into this extension thus far have failed.

... Same here :disappointed: :cry: - and I'm not a coder! However, as I am an obstinate person :stuck_out_tongue_winking_eye: , in the end I concocted a Violentmonkey userscript that uses the polyfill.io online service, achieving the desired effect:

// ==UserScript==
// @name        Add Intl.RelativeTimeFormat support
// @version     0.0.1
// @description Polyfills 'Intl.RelativeTimeFormat()', first implemented in Chromium 71
// @namespace   polyfill.io
// @include     *
// @run-at      document-start
// @require     https://polyfill.io/v3/polyfill.min.js?features=Intl.RelativeTimeFormat,Intl.RelativeTimeFormat.~locale.en
// @grant       none
// ==/UserScript==

<!-- Polyfill Intl.RelativeTimeFormat, its dependencies & 'en' locale data -->

Now the Spotify Web Player does load and function in my Chromium 69 derived browser:

spot2

The Spotify ServiceWorker still doesn't register, but that's a small price to pay...

From my testing, Violentmonkey v2.13.0 is the last fully compatible with Chromium 69; the last fully compatible BETA release is v2.13.0.10; haven't tested how Tampermonkey fares... :wink:

InterLinked1 commented 2 years ago

Interestingly, I no longer seem to get this error on the link provided above. Do you know of any other sites that triggered this error? I don't remember off hand.

Vangelis66 commented 2 years ago

I no longer seem to get this error on the link provided above.

On May 31st, ca. two days after I posted 2, Spotify revisited their Web Player; minimum browser requirements have been somewhat lowered, to Firefox 60.0 & Chrome 66.0:

https://support.spotify.com/gr/article/web-player-help/

sw

Two observations:

  1. On such "old" browser versions (at least), the Web Player no longer requires the Intl.RelativeTimeFormat() constructor, so yes, your latest post is right (if you tested in Chrome 70.0). 😜
  2. Given that 98.0% of Spotify content for registered users is DRM'ed (😠), I find it a tad surprising they've chosen to support as low a Fx version as 60.0 and as low a Chrome version as 66.0; in-browser DRM demands Google's Widevine CDM, its latest version (4.10.2449.0?) itself requires at least FirefoxESR 91.x.x and Chrome 69.0 - but at least non-DRM content (mostly Podcasts) can be played-back in older Chromium and Firefox forks; even UXP browsers (Pale Moon, Serpent 52, etc.) work for non-DRM Spotify content, that doesn't require a log-in: https://open.spotify.com/show/2XHy0waKckPLULstsawBwP

Do you know of any other sites that triggered this error? I don't remember off hand.

Another site was recently reported in the MSFN forums: https://socialclub.rockstargames.com/

In my Chromium 69.0 fork, the URL yields a blank tab, JS console reports:

Uncaught (in promise) TypeError: Intl.Locale is not a constructor  VM388 6340.js:1
    at VM388 6340.js:1
    at Set.forEach (<anonymous>)
    at e.BestFitMatcher (VM388 6340.js:1)
    at e.ResolveLocale (VM388 6340.js:1)
    at e.match (VM388 6340.js:1)
    at e.shouldPolyfill (VM389 intl-should-polyfill.js:1)
    at u (VM287 app.js:62)

The URL loads as expected if Intl.RelativeTimeFormat() support is "introduced" via the userscript I posted in 4 😜 : rsg