Skip to content

Prepare for Chrome User-Agent reduction #225

@prsdthkr

Description

@prsdthkr

Description

Chrome is changing how much userAgent data they expose to the browser. Usage of navigator.userAgent in https://github.com/remarkablemark/html-dom-parser/blob/master/lib/client/utilities.js#L138 will throw browser warnings in the future.

Possible solution

something like

function isIE() {
  const reducedUAString = navigator?.userAgentData?.brands
              ?.map?.(
                  ({ brand, version }) => (`${brand}/${version}`),
              )?.join?.(' ');
  
  // for other browsers
  if( !reducedUAString ) {
      return  /(MSIE |Trident\/|Edge\/)/.test(navigator.userAgent);
  } else {
    // for chrome
    return  /(MSIE |Trident\/|Edge\/)/.test(reducedUAString);
  }
}

Additional context

User-Agent (UA) reduction is the effort to minimize the identifying information shared in the User-Agent string which may be used for passive fingerprinting. As these changes are rolled out, all resource requests will have a reduced User-Agent header. As a result, the return values from certain Navigator interfaces will be reduced, including: navigator.userAgent, navigator.appVersion, and navigator.platform.

https://developer.chrome.com/docs/privacy-sandbox/user-agent/

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions