Jump to content

Recommended Posts


Posted
32 minutes ago, NotHereToPlayGames said:

I use Tampermonkey.

Is there a "leaner" option which only embeds polyfills?

Posted

I'm finding that having "too many" polyfill injections cause more problems then they solve (breaks Sedecordle, breaks MS Teams, just the first two I've found).

For now, I just keep my list of polyfills disabled by default then enable them when needed as opposed to just injecting them all "just in case" they might be needed.

Technically, I've yet to encounter these on any web site I ever visit.

image.png.294de58e9b92babd81f1c996754dc275.png

Posted
1 hour ago, NotHereToPlayGames said:

(breaks Sedecordle, breaks MS Teams, just the first two I've found)

In both cases, it was only this polyfill that broke the page  --

if (!Array.prototype.findLastIndex) {
  Array.prototype.findLastIndex = function (callback, thisArg) {
    for (let i = this.length - 1; i >= 0; i--) {
      if (callback.call(thisArg, this, i, this)) return i;
    }
    return -1;
  };
}

Posted (edited)

https://msfn.org/board/topic/184624-arcticfoxienotheretoplaygames-360chrome-v1352036-rebuild-1/?do=findComment&comment=1245462
https://msfn.org/board/topic/184624-arcticfoxienotheretoplaygames-360chrome-v1352036-rebuild-1/?do=findComment&comment=1245468
https://msfn.org/board/topic/184624-arcticfoxienotheretoplaygames-360chrome-v1352036-rebuild-1/?do=findComment&comment=1245522
my posts for "Array.prototype.findLastIndex" ,  "Array.prototype.at"  and "Array.prototype.findLast" polyfills have been edited.
got it wrong the first time ...

source : https://github.com/behnammodi/polyfill/blob/master/array.polyfill.js
only the first three that i posted are needed to pass the tests on https://developer.mozilla.org/
all other arrays already work in 13.5.2036.
no tests available yet for the latest four very new ones.

Edited by rereser
Posted (edited)

test : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/at
chrome 92 : https://caniuse.com/mdn-javascript_builtins_string_at

// ==UserScript==
// @name Inject String.at Polyfill
// @version 0.0.1
// @match *://*/*
// @run-at document-start
// @grant none
// ==/UserScript==

if (!String.prototype.at) {
  Object.defineProperty(String.prototype, "at",
    {
      value: function (n) {
        // ToInteger() abstract op
        n = Math.trunc(n) || 0;
        // Allow negative indexing from the end
        if (n < 0) n += this.length;
        // OOB access is guaranteed to return undefined
        if (n < 0 || n >= this.length) return undefined;
        // Otherwise, this is just normal property access
        return this[n];
      },
      writable: true,
      enumerable: false,
      configurable: true
    });
}

Edited by rereser
Posted
6 hours ago, rereser said:

my posts for "Array.prototype.findLastIndex" ,  "Array.prototype.at"  and "Array.prototype.findLast" polyfills have been edited.

Awesome, thanks!

I did miss the edit and also somehow missed the findLast.

I can now keep all enabled without any page breaks.

Posted
6 hours ago, rereser said:

no tests available yet for the latest four very new ones.

I'm opting for this polyfill but do have the four "smaller" ones included-but-disabled in my Tampermonkey set of userscripts.

Won't really know the best option until we can find an example web site or two.

Posted

the last new four are in chrome 110.
the link you posted is a replacement for those four ?
a lot more lines ...

Posted

The 2ality post specifically states "this blog post only demonstrates the new methods with Arrays, but they are also available for Typed Arrays".

Typed Arrays are -
   Int8Array
   Uint8Array
   Uint8ClampedArray
   Int16Array
   Uint16Array
   Int32Array
   Uint32Array
   Float32Array
   Float64Array
   BigInt64Array
   BigUint64Array

This (same link as earlier post) polyfill should work for Arrays and Typed Arrays.

Posted (edited)

understand and thank you for the link.
had a look at the readme.md , makes more sense now.
added that polyfill and disabled the four others.
will see what this does in the future.
it does not slow down the browser so that is good.

Edited by rereser

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...